[Linting] Make PyLint happy with the current code

This commit is contained in:
Gergely Polonkai 2018-07-09 18:04:12 +02:00
parent 9af673666c
commit 69f2a0d9cc
2 changed files with 24 additions and 4 deletions

View File

@ -298,6 +298,9 @@ class CalendarSocialApp(Flask):
@staticmethod @staticmethod
@route('/notifications') @route('/notifications')
def notifications(): def notifications():
"""View to list the notifications for the current user
"""
from .models import Notification from .models import Notification
if current_user.is_authenticated: if current_user.is_authenticated:

View File

@ -37,6 +37,12 @@ users_roles = db.Table(
def generate_uuid(): def generate_uuid():
"""Generate a UUID (version 4)
:returns: the hexadecimal representation of the generated UUID
:rtype: str
"""
from uuid import uuid4 from uuid import uuid4
return uuid4().hex return uuid4().hex
@ -52,10 +58,14 @@ def _(translate): # pylint: disable=invalid-name
class NotificationAction(Enum): class NotificationAction(Enum):
"""The possible values for notification actions
"""
#: A user followed another
follow = 1 follow = 1
notification_action_messages = { NOTIFICATION_ACTION_MESSAGES = {
NotificationAction.follow: (_('%(actor)s followed you'), _('%(actor)s followed %(item)s')) NotificationAction.follow: (_('%(actor)s followed you'), _('%(actor)s followed %(item)s'))
} }
@ -205,7 +215,11 @@ class Profile(db.Model): # pylint: disable=too-few-public-methods
@property @property
def fqn(self): def fqn(self):
ret = '' """The fully qualified name of the profile
For local profiles, this is in the form ``@username``; for remote users, its in the form
``@username@domain``.
"""
if self.user: if self.user:
return f'@{self.user.username}' return f'@{self.user.username}'
@ -452,7 +466,7 @@ class AuditLog(db.Model):
logger.info(message) logger.info(message)
class UserFollow(db.Model): class UserFollow(db.Model): # pylint: disable=too-few-public-methods
"""Database model for user follows """Database model for user follows
""" """
@ -510,6 +524,9 @@ class Notification(db.Model):
@property @property
def item(self): def item(self):
"""The subject of the notification
"""
item_class = self._decl_class_registry.get(self.item_type) item_class = self._decl_class_registry.get(self.item_type)
if item_class is None: if item_class is None:
@ -531,7 +548,7 @@ class Notification(db.Model):
from flask_security import current_user from flask_security import current_user
messages = notification_action_messages.get(self.action) messages = NOTIFICATION_ACTION_MESSAGES.get(self.action)
message = messages[0 if self.item == current_user.profile else 1] message = messages[0 if self.item == current_user.profile else 1]
return lazy_gettext(message, actor=self.actor, item=self.item) return lazy_gettext(message, actor=self.actor, item=self.item)