products/CPSSubscriptions

changeset 1105:893082b34cec CPS-3.5

Subscriptions: flake8 incl a minor inconsistency
author Georges Racinet on ishtar <gracinet@anybox.fr>
date Tue, 13 May 2014 13:05:22 +0200
parents cda8dc57d114
children 6f03aa92d1fa
files Subscription.py
diffstat 1 files changed, 30 insertions(+), 27 deletions(-) [+]
line diff
     1.1 --- a/Subscription.py
     1.2 +++ b/Subscription.py
     1.3 @@ -33,6 +33,7 @@
     1.4  
     1.5  logger = logging.getLogger('Products.CPSSubscriptions.Subscription')
     1.6  
     1.7 +
     1.8  class Subscription(PortalFolder):
     1.9      """ Subscription
    1.10  
    1.11 @@ -44,28 +45,28 @@
    1.12  
    1.13      security = ClassSecurityInfo()
    1.14  
    1.15 -    _properties = PortalFolder._properties + \
    1.16 -                  ({'id': 'filter_event_types',
    1.17 -                    'type': 'lines',
    1.18 -                    'mode': 'w',
    1.19 -                    'label': 'Filter Event Types'},
    1.20 -                   {'id': 'filter_object_types',
    1.21 -                    'type': 'lines',
    1.22 -                    'mode': 'w',
    1.23 -                    'label': 'Filter Object Types'},
    1.24 -                   {'id': 'recipient_emails_black_list',
    1.25 -                    'type': 'lines',
    1.26 -                    'mode': 'w',
    1.27 -                    'label': 'Recipient Emails Black List'},
    1.28 -                   {'id': 'roles_allowed_to_subscribe',
    1.29 -                    'type':'lines',
    1.30 -                    'mode':'w',
    1.31 -                    'label' : 'Roles Allowed to susbcribe'},
    1.32 -                   {'id': 'notification_type',
    1.33 -                    'type': 'string',
    1.34 -                    'mode': 'w',
    1.35 -                    'label': 'Notification Type'},
    1.36 -                   )
    1.37 +    _properties = PortalFolder._properties + (
    1.38 +        {'id': 'filter_event_types',
    1.39 +         'type': 'lines',
    1.40 +         'mode': 'w',
    1.41 +         'label': 'Filter Event Types'},
    1.42 +        {'id': 'filter_object_types',
    1.43 +         'type': 'lines',
    1.44 +         'mode': 'w',
    1.45 +         'label': 'Filter Object Types'},
    1.46 +        {'id': 'recipient_emails_black_list',
    1.47 +         'type': 'lines',
    1.48 +         'mode': 'w',
    1.49 +         'label': 'Recipient Emails Black List'},
    1.50 +        {'id': 'roles_allowed_to_subscribe',
    1.51 +         'type': 'lines',
    1.52 +         'mode': 'w',
    1.53 +         'label': 'Roles Allowed to susbcribe'},
    1.54 +        {'id': 'notification_type',
    1.55 +         'type': 'string',
    1.56 +         'mode': 'w',
    1.57 +         'label': 'Notification Type'},
    1.58 +        )
    1.59  
    1.60      filter_event_types = []
    1.61      filter_object_types = []
    1.62 @@ -158,8 +159,9 @@
    1.63      def getNotificationRules(self):
    1.64          """ Returns the notification rule associate to this object
    1.65          """
    1.66 -        return [x for x in self.objectValues() if hasattr(x,
    1.67 -                                                       'notifyRecipients')]
    1.68 +        return [x for x in self.objectValues()
    1.69 +                if hasattr(x, 'notifyRecipients')]
    1.70 +
    1.71      def sendEvent(self, event_type, object, infos, with_groups=False):
    1.72          """Send an event to the subscription.
    1.73          """
    1.74 @@ -220,7 +222,7 @@
    1.75          if recipients_rule_type is None:
    1.76              return all_recipients_rules
    1.77          else:
    1.78 -            return [x for x in all_recipients_rules \
    1.79 +            return [x for x in all_recipients_rules
    1.80                      if x.meta_type == recipients_rule_type]
    1.81  
    1.82      def getParentContainer(self):
    1.83 @@ -230,6 +232,7 @@
    1.84  
    1.85  InitializeClass(Subscription)
    1.86  
    1.87 +
    1.88  def addSubscription(self, id=None, title='', REQUEST=None):
    1.89      """Add a Subscriptions object"""
    1.90  
    1.91 @@ -239,7 +242,7 @@
    1.92      if hasattr(aq_base(self), id):
    1.93          return MessageDialog(
    1.94              title='Item Exists',
    1.95 -            message='This object already contains an %s' % ob.id,
    1.96 +            message='This object already contains an %s' % id,
    1.97              action='%s/manage_main' % REQUEST['URL1'])
    1.98  
    1.99      ob = Subscription(id, title=title)
   1.100 @@ -256,5 +259,5 @@
   1.101          'CPSSubscriptions'].addMailNotificationRule()
   1.102  
   1.103      if REQUEST is not None:
   1.104 -        return REQUEST.RESPONSE.redirect(self.absolute_url()+'/manage_main')
   1.105 +        return REQUEST.RESPONSE.redirect(self.absolute_url() + '/manage_main')
   1.106      return subscription