1 """Specific views for users |
1 """Specific views for users |
2 |
2 |
3 :organization: Logilab |
3 :organization: Logilab |
4 :copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 """ |
6 """ |
7 __docformat__ = "restructuredtext en" |
7 __docformat__ = "restructuredtext en" |
8 |
8 |
9 from logilab.common.decorators import cached |
9 from logilab.common.decorators import cached |
|
10 from logilab.mtconverter import html_escape |
10 |
11 |
11 from cubicweb.schema import display_name |
12 from cubicweb.schema import display_name |
12 from cubicweb.web import INTERNAL_FIELD_VALUE |
13 from cubicweb.web import INTERNAL_FIELD_VALUE |
13 from cubicweb.web.form import EntityForm |
14 from cubicweb.web.form import EntityForm |
14 from cubicweb.web.views.baseviews import PrimaryView |
15 from cubicweb.web.views.baseviews import PrimaryView, EntityView |
15 |
16 |
16 class EUserPrimaryView(PrimaryView): |
17 class EUserPrimaryView(PrimaryView): |
17 accepts = ('EUser',) |
18 accepts = ('EUser',) |
18 skip_attrs = ('firstname', 'surname') |
19 skip_attrs = ('firstname', 'surname') |
19 |
20 |
29 |
30 |
30 def is_side_related(self, rschema, eschema): |
31 def is_side_related(self, rschema, eschema): |
31 return rschema.type in ['interested_in', 'tags', |
32 return rschema.type in ['interested_in', 'tags', |
32 'todo_by', 'bookmarked_by', |
33 'todo_by', 'bookmarked_by', |
33 ] |
34 ] |
|
35 |
|
36 class FoafView(EntityView): |
|
37 id = 'foaf' |
|
38 accepts = ('EUser',) |
|
39 title = _('foaf') |
|
40 templatable = False |
|
41 content_type = 'text/xml' |
|
42 |
|
43 def call(self): |
|
44 self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self.req.encoding) |
|
45 self.w(u'<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n') |
|
46 self.w(u'xmlns:foaf="http://xmlns.com/foaf/0.1/">\n') |
|
47 for i in xrange(self.rset.rowcount): |
|
48 self.cell_call(i, 0) |
|
49 self.w(u'</rdf:RDF>\n') |
|
50 |
|
51 def cell_call(self, row, col): |
|
52 entity = self.complete_entity(row, col) |
|
53 self.w(u'<foaf:Person>\n') |
|
54 self.w(u'<foaf:name>%s</foaf:name>\n' % html_escape(entity.dc_long_title())) |
|
55 if entity.surname: |
|
56 self.w(u'<foaf:surname>%s</foaf:surname>\n' |
|
57 % html_escape(entity.surname)) |
|
58 if entity.firstname: |
|
59 self.w(u'<foaf:firstname>%s</foaf:firstname>\n' |
|
60 % html_escape(entity.firstname)) |
|
61 emailaddr = entity.get_email() |
|
62 if emailaddr: |
|
63 self.w(u'<foaf:mbox>%s</foaf:mbox>\n' % html_escape(emailaddr)) |
|
64 self.w(u'</foaf:Person>\n') |
34 |
65 |
35 |
66 |
36 class EditGroups(EntityForm): |
67 class EditGroups(EntityForm): |
37 """displays a simple euser / egroups editable table""" |
68 """displays a simple euser / egroups editable table""" |
38 |
69 |