web/views/euser.py
branchtls-sprint
changeset 631 99f5852f8604
parent 619 9efa2cc9c02c
child 680 99d0b471cc0c
--- a/web/views/euser.py	Mon Feb 16 16:24:24 2009 +0100
+++ b/web/views/euser.py	Mon Feb 16 18:26:13 2009 +0100
@@ -10,12 +10,30 @@
 from logilab.mtconverter import html_escape
 
 from cubicweb.schema import display_name
+from cubicweb.common.selectors import one_line_rset, implements, match_user_groups
 from cubicweb.web import INTERNAL_FIELD_VALUE
 from cubicweb.web.form import EntityForm
+from cubicweb.web.action import Action
 from cubicweb.web.views.baseviews import PrimaryView, EntityView
 
+
+class UserPreferencesEntityAction(Action):
+    id = 'prefs'
+    __selectors__ = (one_line_rset,
+                     implements('EUser'),
+                     match_user_groups('owners', 'managers'))
+    
+    title = _('preferences')
+    category = 'mainactions'
+    
+    def url(self):
+        login = self.rset.get_entity(self.row or 0, self.col or 0).login
+        return self.build_url('euser/%s'%login, vid='epropertiesform')
+
+
 class EUserPrimaryView(PrimaryView):
-    accepts = ('EUser',)
+    __selectors__ = (implements('EUser'),)
+    
     skip_attrs = ('firstname', 'surname')
     
     def iter_relations(self, entity):
@@ -34,7 +52,8 @@
                                  ]
 class FoafView(EntityView):
     id = 'foaf'
-    accepts = ('EUser',)
+    __selectors__ = (implements('EUser'),)
+    
     title = _('foaf')
     templatable = False
     content_type = 'text/xml'
@@ -54,7 +73,6 @@
                       <foaf:maker rdf:resource="%s"/>
                       <foaf:primaryTopic rdf:resource="%s"/>
                    </foaf:PersonalProfileDocument>''' % (entity.absolute_url(), entity.absolute_url()))
-                      
         self.w(u'<foaf:Person rdf:ID="%s">\n' % entity.eid)
         self.w(u'<foaf:name>%s</foaf:name>\n' % html_escape(entity.dc_long_title()))
         if entity.surname:
@@ -68,11 +86,13 @@
             self.w(u'<foaf:mbox>%s</foaf:mbox>\n' % html_escape(emailaddr))
         self.w(u'</foaf:Person>\n')
 
+
 class FoafUsableView(FoafView):
     id = 'foaf_usable'
   
     def call(self):
         self.cell_call(0, 0)
+
             
 class EditGroups(EntityForm):
     """displays a simple euser / egroups editable table"""