--- a/web/views/euser.py Wed Apr 08 11:33:57 2009 +0200
+++ b/web/views/euser.py Wed Apr 08 11:52:10 2009 +0200
@@ -6,36 +6,29 @@
"""
__docformat__ = "restructuredtext en"
-from logilab.common.decorators import cached
from logilab.mtconverter import html_escape
-from cubicweb.schema import display_name
from cubicweb.selectors import one_line_rset, implements, match_user_groups
from cubicweb.view import EntityView
-from cubicweb.web import INTERNAL_FIELD_VALUE
-from cubicweb.web.form import FormMixIn
-from cubicweb.web.action import Action
-from cubicweb.web.views.baseviews import PrimaryView, EntityView
-from cubicweb.web.views.editforms import AutomaticEntityForm
-from cubicweb.web.views.boxes import EditBox
+from cubicweb.web import uicfg, action
+from cubicweb.web.views.baseviews import PrimaryView
-AutomaticEntityForm.rcategories.set_rtag('secondary', 'firstname', 'subject', 'EUser')
-AutomaticEntityForm.rcategories.set_rtag('secondary', 'surname', 'subject', 'EUser')
-AutomaticEntityForm.rcategories.set_rtag('metadata', 'last_login_time', 'subject', 'EUser')
-AutomaticEntityForm.rcategories.set_rtag('primary', 'in_group', 'subject', 'EUser')
-AutomaticEntityForm.rcategories.set_rtag('generated', 'owned_by', 'object', 'EUser')
-AutomaticEntityForm.rcategories.set_rtag('metadata', 'created_by', 'object', 'EUser')
-AutomaticEntityForm.rcategories.set_rtag('metadata', 'bookmarked_by', 'object', 'EUser')
-AutomaticEntityForm.rinlined.set_rtag(True, 'use_email', 'subject', 'EUser')
-
-EditBox.rmode.set_rtag('create', 'in_group', 'subject', 'EGroup')
-EditBox.rmode.set_rtag('link', 'owned_by', 'object', 'EUser')
-EditBox.rmode.set_rtag('link', 'created_by', 'object', 'EUser')
-EditBox.rmode.set_rtag('create', 'bookmarked_by', 'object', 'EUser')
+uicfg.rcategories.set_rtag('secondary', 'firstname', 'subject', 'EUser')
+uicfg.rcategories.set_rtag('secondary', 'surname', 'subject', 'EUser')
+uicfg.rcategories.set_rtag('metadata', 'last_login_time', 'subject', 'EUser')
+uicfg.rcategories.set_rtag('primary', 'in_group', 'subject', 'EUser')
+uicfg.rcategories.set_rtag('generated', 'owned_by', 'object', otype='EUser')
+uicfg.rcategories.set_rtag('generated', 'created_by', 'object', otype='EUser')
+uicfg.rcategories.set_rtag('metadata', 'bookmarked_by', 'object', otype='EUser')
+uicfg.rinlined.set_rtag(True, 'use_email', 'subject', 'EUser')
+uicfg.rmode.set_rtag('create', 'in_group', 'subject', 'EGroup')
+uicfg.rmode.set_rtag('link', 'owned_by', 'object', 'EUser')
+uicfg.rmode.set_rtag('link', 'created_by', 'object', 'EUser')
+uicfg.rmode.set_rtag('create', 'bookmarked_by', 'object', 'EUser')
-class UserPreferencesEntityAction(Action):
+class UserPreferencesEntityAction(action.Action):
id = 'prefs'
__select__ = (one_line_rset() & implements('EUser') &
match_user_groups('owners', 'managers'))
@@ -66,6 +59,7 @@
def is_side_related(self, rschema, eschema):
return rschema.type in ['interested_in', 'tags',
'todo_by', 'bookmarked_by',
+
]
class FoafView(EntityView):
id = 'foaf'
@@ -102,67 +96,3 @@
if emailaddr:
self.w(u'<foaf:mbox>%s</foaf:mbox>\n' % html_escape(emailaddr))
self.w(u'</foaf:Person>\n')
-
-
-class EditGroups(FormMixIn, EntityView):
- """displays a simple euser / egroups editable table"""
-
- id = 'editgroups'
- __select__ = implements('EUser')
-
- def call(self):
- self.req.add_css('cubicweb.acl.css')
- _ = self.req._
- self.w(u'<form id="editgroup" method="post" action="edit">')
- self.w(u'<table id="groupedit">\n')
- self.w(u'<tr>')
- self.w(u'<th>%s</th>' % display_name(self.req, 'EUser'))
- self.w(u''.join(u'<th>%s</th>' % _(gname) for geid, gname in self.egroups))
- self.w(u'</tr>')
- for row in xrange(len(self.rset)):
- self.build_table_line(row)
- self.w(u'</table>')
- self.w(u'<fieldset>')
- self.w(self.button_cancel())
- self.w(self.button_ok())
- self.w(u'</fieldset>')
- self.w(u'</form>')
-
-
- def build_table_line(self, row):
- euser = self.entity(row)
- euser_groups = [group.name for group in euser.in_group]
- if euser_groups:
- self.w(u'<tr>')
- else:
- self.w(u'<tr class="nogroup">')
- self.w(u'<th><fieldset>')
- self.w(u'<input type="hidden" name="eid" value="%s" />' % euser.eid)
- self.w(u'<input type="hidden" name="__type:%s" value="EUser" />' % euser.eid)
- # this should not occur (for now) since in_group relation is mandatory
- if not euser_groups:
- self.w(u'<input type="hidden" name="edits-in_group:%s" value="%s">' %
- (euser.eid, INTERNAL_FIELD_VALUE))
- self.w(euser.dc_title())
- self.w(u'</fieldset></th>')
- for geid, gname in self.egroups:
- self.w(u'<td><fieldset>')
- if gname in euser_groups:
- self.w(u'<input type="hidden" name="edits-in_group:%s" value="%s" />' %
- (euser.eid, geid))
- self.w(u'<input type="checkbox" name="in_group:%s" value="%s" checked="checked" />' %
- (euser.eid, geid))
- else:
- self.w(u'<input type="checkbox" name="in_group:%s" value="%s" />' %
- (euser.eid, geid))
- self.w(u'</fieldset></td>')
- self.w(u'</tr>\n')
-
-
- @property
- @cached
- def egroups(self):
- groups = self.req.execute('Any G, N ORDERBY N WHERE G is EGroup, G name N')
- return [(geid, gname) for geid, gname in groups.rows if gname != 'owners']
-
-