From 1636a9c838b1f19ac34c537dcab2b473b91da887 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 8 Oct 2013 17:46:23 +0200 Subject: [PATCH] Code cleaning on notification app. --- greenmine/base/notifications/api.py | 20 +++++++++----------- greenmine/base/notifications/models.py | 8 +++++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/greenmine/base/notifications/api.py b/greenmine/base/notifications/api.py index cebc0305..3fbfed6a 100644 --- a/greenmine/base/notifications/api.py +++ b/greenmine/base/notifications/api.py @@ -16,24 +16,22 @@ class NotificationSenderMixin(object): def post_save(self, obj, created=False): users = obj.get_watchers_to_notify(self.request.user) - context = { - "changer": self.request.user, - "object": obj - } + context = {'changer': self.request.user, 'object': obj} if created: - self._send_notification_email(self.create_notification_template, users=users, context=context) + self._send_notification_email(self.create_notification_template, + users=users, context=context) else: context["changed_fields_dict"] = obj.get_changed_fields_dict(self.request.DATA) - self._send_notification_email(self.update_notification_template, users=users, context=context) + self._send_notification_email(self.update_notification_template, + users=users, context=context) def destroy(self, request, *args, **kwargs): obj = self.get_object() users = obj.get_watchers_to_notify(self.request.user) - context = { - 'changer': self.request.user, - 'object': obj - } - self._send_notification_email(self.destroy_notification_template, users=users, context=context) + + context = {'changer': self.request.user, 'object': obj} + self._send_notification_email(self.destroy_notification_template, + users=users, context=context) return super(NotificationSenderMixin, self).destroy(request, *args, **kwargs) diff --git a/greenmine/base/notifications/models.py b/greenmine/base/notifications/models.py index 83467690..cf581f92 100644 --- a/greenmine/base/notifications/models.py +++ b/greenmine/base/notifications/models.py @@ -16,8 +16,9 @@ class WatcherMixin(object): ("no_events", _(u"No events")), ) - notify_level = models.CharField(max_length=32, null=False, blank=False, default="all_owned_projects", - choices=NOTIFY_LEVEL_CHOICES, verbose_name=_(u"notify level")) + notify_level = models.CharField(max_length=32, null=False, blank=False, + default="all_owned_projects", choices=NOTIFY_LEVEL_CHOICES, + verbose_name=_(u"notify level")) notify_changes_by_me = models.BooleanField(null=False, blank=True, default=True, verbose_name=_(u"notify changes made by me")) @@ -65,7 +66,8 @@ class WatchedMixin(object): def get_changed_fields_dict(self, data_dict): if self.notifiable_fields: - changed_data = dict((k, v) for k, v in data_dict.items() if k in self.notifiable_fields) + changed_data = {k: v for k, v in data_dict.items() + if k in self.notifiable_fields} else: changed_data = data_dict