# HG changeset patch
# User sylvain.thenault@logilab.fr
# Date 1233315004 -3600
# Node ID f01cfce2e8d20b3ce1d9d8889975c962ef392765
# Parent 385ce5e0b30b13bbf70ee5c96af227454c7edd0d
foaf euser view
diff -r 385ce5e0b30b -r f01cfce2e8d2 web/views/euser.py
--- a/web/views/euser.py Fri Jan 30 12:29:37 2009 +0100
+++ b/web/views/euser.py Fri Jan 30 12:30:04 2009 +0100
@@ -1,17 +1,18 @@
"""Specific views for users
:organization: Logilab
-:copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__ = "restructuredtext en"
from logilab.common.decorators import cached
+from logilab.mtconverter import html_escape
from cubicweb.schema import display_name
from cubicweb.web import INTERNAL_FIELD_VALUE
from cubicweb.web.form import EntityForm
-from cubicweb.web.views.baseviews import PrimaryView
+from cubicweb.web.views.baseviews import PrimaryView, EntityView
class EUserPrimaryView(PrimaryView):
accepts = ('EUser',)
@@ -32,6 +33,36 @@
'todo_by', 'bookmarked_by',
]
+class FoafView(EntityView):
+ id = 'foaf'
+ accepts = ('EUser',)
+ title = _('foaf')
+ templatable = False
+ content_type = 'text/xml'
+
+ def call(self):
+ self.w(u'\n' % self.req.encoding)
+ self.w(u'\n')
+ for i in xrange(self.rset.rowcount):
+ self.cell_call(i, 0)
+ self.w(u'\n')
+
+ def cell_call(self, row, col):
+ entity = self.complete_entity(row, col)
+ self.w(u'\n')
+ self.w(u'%s\n' % html_escape(entity.dc_long_title()))
+ if entity.surname:
+ self.w(u'%s\n'
+ % html_escape(entity.surname))
+ if entity.firstname:
+ self.w(u'%s\n'
+ % html_escape(entity.firstname))
+ emailaddr = entity.get_email()
+ if emailaddr:
+ self.w(u'%s\n' % html_escape(emailaddr))
+ self.w(u'\n')
+
class EditGroups(EntityForm):
"""displays a simple euser / egroups editable table"""