From d14d32767c1b9b90dca00ed7035aebbf144e4b12 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sun, 8 Jul 2018 19:47:05 +0200 Subject: [PATCH] Make PyLint happy with the models code --- calsocial/__init__.py | 6 ++++-- calsocial/models.py | 11 ++++++++--- calsocial/security.py | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/calsocial/__init__.py b/calsocial/__init__.py index 534b778..8ceb9bd 100644 --- a/calsocial/__init__.py +++ b/calsocial/__init__.py @@ -72,7 +72,7 @@ class CalendarSocialApp(Flask): """The Calendar.social app """ - def __init__(self, name, config=None): + def __init__(self, name, config=None): # pylint: disable=too-many-locals from .forms import LoginForm from .models import db, User, Role from .security import security, AnonymousUser @@ -90,7 +90,9 @@ class CalendarSocialApp(Flask): babel.localeselector(get_locale) user_store = SQLAlchemyUserDatastore(db, User, Role) - security.init_app(self, datastore=user_store, anonymous_user=AnonymousUser, login_form=LoginForm) + security.init_app(self, datastore=user_store, + anonymous_user=AnonymousUser, + login_form=LoginForm) self.context_processor(template_vars) diff --git a/calsocial/models.py b/calsocial/models.py index 8fb8db1..69e3ba1 100644 --- a/calsocial/models.py +++ b/calsocial/models.py @@ -115,6 +115,11 @@ class User(db.Model, UserMixin): @property def timezone(self): + """The user’s time zone + + If the user didn’t set a time zone yet, the application default is used. + """ + from flask import current_app from pytz import timezone from pytz.exceptions import UnknownTimeZoneError @@ -204,9 +209,9 @@ class Event(db.Model): description = db.Column(db.UnicodeText()) def __as_tz(self, timestamp, as_timezone=None): - from pytz import timezone, UTC + from pytz import timezone, utc - utc_timestamp = UTC.localize(timestamp) + utc_timestamp = utc.localize(dt=timestamp) return utc_timestamp.astimezone(as_timezone or timezone(self.time_zone)) @@ -240,7 +245,7 @@ class Event(db.Model): return f'' -class UserSetting(db.Model): +class UserSetting(db.Model): # pylint: disable=too-few-public-methods """Database model for user settings """ diff --git a/calsocial/security.py b/calsocial/security.py index a574ee6..0eab762 100644 --- a/calsocial/security.py +++ b/calsocial/security.py @@ -37,7 +37,7 @@ class AnonymousUser(BaseAnonymousUser): @user_logged_in.connect -def login_handler(app, user): +def login_handler(app, user): # pylint: disable=unused-argument """Signal handler to be called when a user successfully logs in """ @@ -47,7 +47,7 @@ def login_handler(app, user): @user_logged_out.connect -def logout_handler(app, user): +def logout_handler(app, user): # pylint: disable=unused-argument """Signal handler to be called when a user logs out """ -- 2.40.1