web/views/cwuser.py
branchstable
changeset 7806 aa30c665bd06
parent 7777 2764987eb17a
child 7807 f2a5805615f8
child 7879 9aae456abab5
equal deleted inserted replaced
7805:7111bb64b58f 7806:aa30c665bd06
    27 from cubicweb import tags
    27 from cubicweb import tags
    28 from cubicweb.schema import display_name
    28 from cubicweb.schema import display_name
    29 from cubicweb.selectors import one_line_rset, is_instance, match_user_groups
    29 from cubicweb.selectors import one_line_rset, is_instance, match_user_groups
    30 from cubicweb.view import EntityView, StartupView
    30 from cubicweb.view import EntityView, StartupView
    31 from cubicweb.web import action, uicfg, formwidgets
    31 from cubicweb.web import action, uicfg, formwidgets
    32 from cubicweb.web.views import tabs, tableview, actions
    32 from cubicweb.web.views import tabs, tableview, actions, add_etype_button
    33 
    33 
    34 _pvs = uicfg.primaryview_section
    34 _pvs = uicfg.primaryview_section
    35 _pvs.tag_attribute(('CWUser', 'login'), 'hidden')
    35 _pvs.tag_attribute(('CWUser', 'login'), 'hidden')
    36 
    36 
    37 _affk = uicfg.autoform_field_kwargs
    37 _affk = uicfg.autoform_field_kwargs
   180     title = _('users and groups management')
   180     title = _('users and groups management')
   181     cache_max_age = 0 # disable caching
   181     cache_max_age = 0 # disable caching
   182 
   182 
   183     def call(self, **kwargs):
   183     def call(self, **kwargs):
   184         self.w('<h1>%s</h1>' % self._cw._(self.title))
   184         self.w('<h1>%s</h1>' % self._cw._(self.title))
   185         for etype in ('CWUser', 'CWGroup'):
   185         self.w(add_etype_button(self._cw, 'CWUser'))
   186             eschema = self._cw.vreg.schema.eschema(etype)
   186         self.w(add_etype_button(self._cw, 'CWGroup'))
   187             if eschema.has_perm(self._cw, 'add'):
       
   188                 self.w(u'<a href="%s" class="addButton right">%s</a>' % (
       
   189                     self._cw.build_url('add/%s' % eschema),
       
   190                     self._cw.__('New %s' % etype).capitalize()))
       
   191         self.w(u'<div class="clear"></div>')
   187         self.w(u'<div class="clear"></div>')
   192         self.wview('cw.user-table', self._cw.execute(self.rql))
   188         self.wview('cw.user-table', self._cw.execute(self.rql))
   193 
   189 
   194 
   190 
   195 class CWUserTable(tableview.EditableTableView):
   191 class CWUserTable(tableview.EditableTableView):