web/views/cwuser.py
changeset 7807 f2a5805615f8
parent 7802 d0bf71aff4a1
parent 7806 aa30c665bd06
child 7894 ad0eeb0f7a8d
--- a/web/views/cwuser.py	Fri Sep 16 14:01:17 2011 +0200
+++ b/web/views/cwuser.py	Fri Sep 16 17:30:26 2011 +0200
@@ -29,7 +29,7 @@
 from cubicweb.selectors import one_line_rset, is_instance, match_user_groups
 from cubicweb.view import EntityView, StartupView
 from cubicweb.web import action, uicfg, formwidgets
-from cubicweb.web.views import tabs, tableview, actions
+from cubicweb.web.views import tabs, tableview, actions, add_etype_button
 
 _pvs = uicfg.primaryview_section
 _pvs.tag_attribute(('CWUser', 'login'), 'hidden')
@@ -194,7 +194,7 @@
            'U cw_source UDS, US name UDSN')
 
     def call(self, **kwargs):
-        add_button(self, 'CWUser')
+        self.w(add_etype_button(self._cw, 'CWGroup'))
         self.w(u'<div class="clear"></div>')
         self.wview('cw.users-table', self._cw.execute(self.rql))
 
@@ -209,20 +209,13 @@
     cellvids = {}
 
     def call(self, **kwargs):
-        add_button(self, 'CWGroup')
+        self.w('<h1>%s</h1>' % self._cw._(self.title))
+        self.w(add_etype_button(self._cw, 'CWUser'))
         self.w(u'<div class="clear"></div>')
         self.wview('editable-table', self._cw.execute(self.rql),
                    headers=self.headers, cellvids=self.cellvids)
 
 
-def add_button(self, etype):
-    eschema = self._cw.vreg.schema.eschema(etype)
-    if eschema.has_perm(self._cw, 'add'):
-        self.w(u'<a href="%s" class="addButton right">%s</a>' % (
-                self._cw.build_url('add/%s' % eschema),
-                self._cw.__('New %s' % etype).capitalize()))
-
-
 class CWUsersTable(tableview.EditableTableView):
     __regid__ = 'cw.users-table'
     __select__ = is_instance('CWUser')