From 69f2a0d9ccc63cb0535ff7ea90998d0181414403 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 9 Jul 2018 18:04:12 +0200 Subject: [PATCH] [Linting] Make PyLint happy with the current code --- calsocial/__init__.py | 3 +++ calsocial/models.py | 25 +++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/calsocial/__init__.py b/calsocial/__init__.py index a1f0b31..000e2eb 100644 --- a/calsocial/__init__.py +++ b/calsocial/__init__.py @@ -298,6 +298,9 @@ class CalendarSocialApp(Flask): @staticmethod @route('/notifications') def notifications(): + """View to list the notifications for the current user + """ + from .models import Notification if current_user.is_authenticated: diff --git a/calsocial/models.py b/calsocial/models.py index b8ba26b..5d4a68f 100644 --- a/calsocial/models.py +++ b/calsocial/models.py @@ -37,6 +37,12 @@ users_roles = db.Table( def generate_uuid(): + """Generate a UUID (version 4) + + :returns: the hexadecimal representation of the generated UUID + :rtype: str + """ + from uuid import uuid4 return uuid4().hex @@ -52,10 +58,14 @@ def _(translate): # pylint: disable=invalid-name class NotificationAction(Enum): + """The possible values for notification actions + """ + + #: A user followed another follow = 1 -notification_action_messages = { +NOTIFICATION_ACTION_MESSAGES = { 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 def fqn(self): - ret = '' + """The fully qualified name of the profile + + For local profiles, this is in the form ``@username``; for remote users, it’s in the form + ``@username@domain``. + """ if self.user: return f'@{self.user.username}' @@ -452,7 +466,7 @@ class AuditLog(db.Model): logger.info(message) -class UserFollow(db.Model): +class UserFollow(db.Model): # pylint: disable=too-few-public-methods """Database model for user follows """ @@ -510,6 +524,9 @@ class Notification(db.Model): @property def item(self): + """The subject of the notification + """ + item_class = self._decl_class_registry.get(self.item_type) if item_class is None: @@ -531,7 +548,7 @@ class Notification(db.Model): 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] return lazy_gettext(message, actor=self.actor, item=self.item)