Make PyLint happy with the models code

This commit is contained in:
Gergely Polonkai 2018-07-08 19:47:05 +02:00
parent 531faa1ce7
commit d14d32767c
3 changed files with 14 additions and 7 deletions

View File

@ -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)

View File

@ -115,6 +115,11 @@ class User(db.Model, UserMixin):
@property
def timezone(self):
"""The users time zone
If the user didnt 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'<Event {self.id} ({self.title}) of {self.user}>'
class UserSetting(db.Model):
class UserSetting(db.Model): # pylint: disable=too-few-public-methods
"""Database model for user settings
"""

View File

@ -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
"""