cubicweb/sobjects/notification.py
changeset 12567 26744ad37953
parent 12046 9056a41d91ba
child 12843 000cd62eda32
equal deleted inserted replaced
12566:6b3523f81f42 12567:26744ad37953
    19 
    19 
    20 
    20 
    21 from cubicweb import _
    21 from cubicweb import _
    22 
    22 
    23 from itertools import repeat
    23 from itertools import repeat
    24 
       
    25 from six import text_type
       
    26 
    24 
    27 from logilab.common.textutils import normalize_text
    25 from logilab.common.textutils import normalize_text
    28 from logilab.common.registry import yes
    26 from logilab.common.registry import yes
    29 
    27 
    30 from cubicweb.view import Component, EntityView
    28 from cubicweb.view import Component, EntityView
   177         return self._cw._('%(subject)s %(etype)s #%(eid)s (%(login)s)') % locals()
   175         return self._cw._('%(subject)s %(etype)s #%(eid)s (%(login)s)') % locals()
   178 
   176 
   179     def context(self, **kwargs):
   177     def context(self, **kwargs):
   180         entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
   178         entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
   181         for key, val in kwargs.items():
   179         for key, val in kwargs.items():
   182             if val and isinstance(val, text_type) and val.strip():
   180             if val and isinstance(val, str) and val.strip():
   183                 kwargs[key] = self._cw._(val)
   181                 kwargs[key] = self._cw._(val)
   184         kwargs.update({'user': self.user_data['login'],
   182         kwargs.update({'user': self.user_data['login'],
   185                        'eid': entity.eid,
   183                        'eid': entity.eid,
   186                        'etype': entity.dc_type(),
   184                        'etype': entity.dc_type(),
   187                        'url': entity.absolute_url(),
   185                        'url': entity.absolute_url(),
   250         return u'%s #%s (%s)' % (self._cw.__('New %s' % entity.e_schema),
   248         return u'%s #%s (%s)' % (self._cw.__('New %s' % entity.e_schema),
   251                                  entity.eid, self.user_data['login'])
   249                                  entity.eid, self.user_data['login'])
   252 
   250 
   253 
   251 
   254 def format_value(value):
   252 def format_value(value):
   255     if isinstance(value, text_type):
   253     if isinstance(value, str):
   256         return u'"%s"' % value
   254         return u'"%s"' % value
   257     return value
   255     return value
   258 
   256 
   259 
   257 
   260 class EntityUpdatedNotificationView(NotificationView):
   258 class EntityUpdatedNotificationView(NotificationView):