web/views/euser.py
branchtls-sprint
changeset 1398 5fe84a5f7035
parent 1288 0d0f09c36bba
equal deleted inserted replaced
1397:6cbc7bc8ea6d 1398:5fe84a5f7035
    12 from cubicweb.view import EntityView
    12 from cubicweb.view import EntityView
    13 from cubicweb.web import uicfg, action
    13 from cubicweb.web import uicfg, action
    14 from cubicweb.web.views.baseviews import PrimaryView
    14 from cubicweb.web.views.baseviews import PrimaryView
    15 
    15 
    16 
    16 
    17 uicfg.rcategories.set_rtag('secondary', 'firstname', 'subject', 'EUser')
    17 uicfg.rcategories.set_rtag('secondary', 'firstname', 'subject', 'CWUser')
    18 uicfg.rcategories.set_rtag('secondary', 'surname', 'subject', 'EUser')
    18 uicfg.rcategories.set_rtag('secondary', 'surname', 'subject', 'CWUser')
    19 uicfg.rcategories.set_rtag('metadata', 'last_login_time', 'subject', 'EUser')
    19 uicfg.rcategories.set_rtag('metadata', 'last_login_time', 'subject', 'CWUser')
    20 uicfg.rcategories.set_rtag('primary', 'in_group', 'subject', 'EUser')
    20 uicfg.rcategories.set_rtag('primary', 'in_group', 'subject', 'CWUser')
    21 uicfg.rcategories.set_rtag('generated', 'owned_by', 'object', otype='EUser')
    21 uicfg.rcategories.set_rtag('generated', 'owned_by', 'object', otype='CWUser')
    22 uicfg.rcategories.set_rtag('generated', 'created_by', 'object', otype='EUser')
    22 uicfg.rcategories.set_rtag('generated', 'created_by', 'object', otype='CWUser')
    23 uicfg.rcategories.set_rtag('metadata', 'bookmarked_by', 'object', otype='EUser')
    23 uicfg.rcategories.set_rtag('metadata', 'bookmarked_by', 'object', otype='CWUser')
    24 uicfg.rinlined.set_rtag(True, 'use_email', 'subject', 'EUser')
    24 uicfg.rinlined.set_rtag(True, 'use_email', 'subject', 'CWUser')
    25 uicfg.rmode.set_rtag('create', 'in_group', 'subject', 'EGroup')
    25 uicfg.rmode.set_rtag('create', 'in_group', 'subject', 'CWGroup')
    26 uicfg.rmode.set_rtag('link', 'owned_by', 'object', 'EUser')
    26 uicfg.rmode.set_rtag('link', 'owned_by', 'object', 'CWUser')
    27 uicfg.rmode.set_rtag('link', 'created_by', 'object', 'EUser')
    27 uicfg.rmode.set_rtag('link', 'created_by', 'object', 'CWUser')
    28 uicfg.rmode.set_rtag('create', 'bookmarked_by', 'object', 'EUser')
    28 uicfg.rmode.set_rtag('create', 'bookmarked_by', 'object', 'CWUser')
    29     
    29     
    30 
    30 
    31 class UserPreferencesEntityAction(action.Action):
    31 class UserPreferencesEntityAction(action.Action):
    32     id = 'prefs'
    32     id = 'prefs'
    33     __select__ = (one_line_rset() & implements('EUser') &
    33     __select__ = (one_line_rset() & implements('CWUser') &
    34                   match_user_groups('owners', 'managers'))
    34                   match_user_groups('owners', 'managers'))
    35     
    35     
    36     title = _('preferences')
    36     title = _('preferences')
    37     category = 'mainactions'
    37     category = 'mainactions'
    38     
    38     
    39     def url(self):
    39     def url(self):
    40         login = self.rset.get_entity(self.row or 0, self.col or 0).login
    40         login = self.rset.get_entity(self.row or 0, self.col or 0).login
    41         return self.build_url('euser/%s'%login, vid='epropertiesform')
    41         return self.build_url('euser/%s'%login, vid='epropertiesform')
    42 
    42 
    43 
    43 
    44 class EUserPrimaryView(PrimaryView):
    44 class CWUserPrimaryView(PrimaryView):
    45     __select__ = implements('EUser')
    45     __select__ = implements('CWUser')
    46     
    46     
    47     skip_attrs = ('firstname', 'surname')
    47     skip_attrs = ('firstname', 'surname')
    48     
    48     
    49     def iter_relations(self, entity):
    49     def iter_relations(self, entity):
    50         # don't want to display user's entities
    50         # don't want to display user's entities
    51         for rschema, targetschemas, x in super(EUserPrimaryView, self).iter_relations(entity):
    51         for rschema, targetschemas, x in super(CWUserPrimaryView, self).iter_relations(entity):
    52             if x == 'object' and rschema.type in ('owned_by', 'for_user'):
    52             if x == 'object' and rschema.type in ('owned_by', 'for_user'):
    53                 continue
    53                 continue
    54             yield rschema, targetschemas, x
    54             yield rschema, targetschemas, x
    55 
    55 
    56     def content_title(self, entity):
    56     def content_title(self, entity):
    61                                  'todo_by', 'bookmarked_by',
    61                                  'todo_by', 'bookmarked_by',
    62 
    62 
    63                                  ]
    63                                  ]
    64 class FoafView(EntityView):
    64 class FoafView(EntityView):
    65     id = 'foaf'
    65     id = 'foaf'
    66     __select__ = implements('EUser')
    66     __select__ = implements('CWUser')
    67     
    67     
    68     title = _('foaf')
    68     title = _('foaf')
    69     templatable = False
    69     templatable = False
    70     content_type = 'text/xml'
    70     content_type = 'text/xml'
    71 
    71 
    94                    % html_escape(entity.firstname))
    94                    % html_escape(entity.firstname))
    95         emailaddr = entity.get_email()
    95         emailaddr = entity.get_email()
    96         if emailaddr:
    96         if emailaddr:
    97             self.w(u'<foaf:mbox>%s</foaf:mbox>\n' % html_escape(emailaddr))
    97             self.w(u'<foaf:mbox>%s</foaf:mbox>\n' % html_escape(emailaddr))
    98         self.w(u'</foaf:Person>\n')
    98         self.w(u'</foaf:Person>\n')
       
    99 
       
   100 from logilab.common.deprecation import class_renamed
       
   101 EUserPrimaryView = class_renamed('EUserPrimaryView', CWUserPrimaryView)