author | sylvain.thenault@logilab.fr |
Mon, 11 May 2009 11:20:38 +0200 | |
branch | tls-sprint |
changeset 1721 | 694f6a50e138 |
parent 1720 | 14c9a0a1aca1 |
child 1722 | 62f3fefb22f4 |
permissions | -rw-r--r-- |
0 | 1 |
"""Specific views for users |
2 |
||
3 |
:organization: Logilab |
|
523 | 4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
0 | 5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 |
""" |
|
7 |
__docformat__ = "restructuredtext en" |
|
8 |
||
523 | 9 |
from logilab.mtconverter import html_escape |
0 | 10 |
|
692
800592b8d39b
replace deprecated cubicweb.common.selectors by its new module path (cubicweb.selectors)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
11 |
from cubicweb.selectors import one_line_rset, implements, match_user_groups |
765
8fda14081686
kill Form, EntityForm and AnyRsetForm
sylvain.thenault@logilab.fr
parents:
753
diff
changeset
|
12 |
from cubicweb.view import EntityView |
1288
0d0f09c36bba
fix some euser rcategories, drop editgroup form which 1. is unused 2. has no advantage vs muledit of users
sylvain.thenault@logilab.fr
parents:
1153
diff
changeset
|
13 |
from cubicweb.web import uicfg, action |
1639 | 14 |
from cubicweb.web.views import primary |
557 | 15 |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
619
diff
changeset
|
16 |
|
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1720
diff
changeset
|
17 |
uicfg.rcategories.tag_attribute('CWUser', 'firstname', 'secondary') |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1720
diff
changeset
|
18 |
uicfg.rcategories.tag_attribute('CWUser', 'surname', 'secondary') |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1720
diff
changeset
|
19 |
uicfg.rcategories.tag_attribute('CWUser', 'last_login_time', 'metadata') |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1720
diff
changeset
|
20 |
uicfg.rcategories.tag_relation('!CWUser', 'in_group', '*', 'primary') |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1720
diff
changeset
|
21 |
uicfg.rcategories.tag_relation('*', 'owned_by', '!CWUser', 'generated') |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1720
diff
changeset
|
22 |
uicfg.rcategories.tag_relation('*', 'created_by', '!CWUser', 'generated') |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1720
diff
changeset
|
23 |
uicfg.rcategories.tag_relation('*', 'bookmarked_by', '!CWUser', 'metadata') |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1720
diff
changeset
|
24 |
|
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1720
diff
changeset
|
25 |
uicfg.rmode.tag_relation('*', 'in_group', '!CWGroup', 'create') |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1720
diff
changeset
|
26 |
uicfg.rmode.tag_relation('*', 'owned_by', '!CWUser', 'link') |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1720
diff
changeset
|
27 |
uicfg.rmode.tag_relation('*', 'created_by', '!CWUser', 'link') |
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1720
diff
changeset
|
28 |
uicfg.rmode.tag_relation('*', 'bookmarked_by', '!CWUser', 'create') |
1508 | 29 |
|
1151 | 30 |
|
1288
0d0f09c36bba
fix some euser rcategories, drop editgroup form which 1. is unused 2. has no advantage vs muledit of users
sylvain.thenault@logilab.fr
parents:
1153
diff
changeset
|
31 |
class UserPreferencesEntityAction(action.Action): |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
619
diff
changeset
|
32 |
id = 'prefs' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1288
diff
changeset
|
33 |
__select__ = (one_line_rset() & implements('CWUser') & |
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
692
diff
changeset
|
34 |
match_user_groups('owners', 'managers')) |
1508 | 35 |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
619
diff
changeset
|
36 |
title = _('preferences') |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
619
diff
changeset
|
37 |
category = 'mainactions' |
1508 | 38 |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
619
diff
changeset
|
39 |
def url(self): |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
619
diff
changeset
|
40 |
login = self.rset.get_entity(self.row or 0, self.col or 0).login |
1545 | 41 |
return self.build_url('cwuser/%s'%login, vid='epropertiesform') |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
619
diff
changeset
|
42 |
|
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
619
diff
changeset
|
43 |
|
523 | 44 |
class FoafView(EntityView): |
45 |
id = 'foaf' |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1288
diff
changeset
|
46 |
__select__ = implements('CWUser') |
1508 | 47 |
|
523 | 48 |
title = _('foaf') |
49 |
templatable = False |
|
50 |
content_type = 'text/xml' |
|
51 |
||
52 |
def call(self): |
|
950 | 53 |
self.w(u'''<?xml version="1.0" encoding="%s"?> |
619
9efa2cc9c02c
adding foaf_usable views to supports reusing foaf fragment in other views (for instance sioc view)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
586
diff
changeset
|
54 |
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
9efa2cc9c02c
adding foaf_usable views to supports reusing foaf fragment in other views (for instance sioc view)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
586
diff
changeset
|
55 |
xmlns:rdfs="http://www.w3org/2000/01/rdf-schema#" |
9efa2cc9c02c
adding foaf_usable views to supports reusing foaf fragment in other views (for instance sioc view)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
586
diff
changeset
|
56 |
xmlns:foaf="http://xmlns.com/foaf/0.1/"> '''% self.req.encoding) |
523 | 57 |
for i in xrange(self.rset.rowcount): |
58 |
self.cell_call(i, 0) |
|
59 |
self.w(u'</rdf:RDF>\n') |
|
60 |
||
61 |
def cell_call(self, row, col): |
|
62 |
entity = self.complete_entity(row, col) |
|
555
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
63 |
self.w(u'''<foaf:PersonalProfileDocument rdf:about=""> |
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
64 |
<foaf:maker rdf:resource="%s"/> |
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
65 |
<foaf:primaryTopic rdf:resource="%s"/> |
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
66 |
</foaf:PersonalProfileDocument>''' % (entity.absolute_url(), entity.absolute_url())) |
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
67 |
self.w(u'<foaf:Person rdf:ID="%s">\n' % entity.eid) |
523 | 68 |
self.w(u'<foaf:name>%s</foaf:name>\n' % html_escape(entity.dc_long_title())) |
69 |
if entity.surname: |
|
555
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
70 |
self.w(u'<foaf:family_name>%s</foaf:family_name>\n' |
523 | 71 |
% html_escape(entity.surname)) |
72 |
if entity.firstname: |
|
555
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
73 |
self.w(u'<foaf:givenname>%s</foaf:givenname>\n' |
523 | 74 |
% html_escape(entity.firstname)) |
75 |
emailaddr = entity.get_email() |
|
76 |
if emailaddr: |
|
586 | 77 |
self.w(u'<foaf:mbox>%s</foaf:mbox>\n' % html_escape(emailaddr)) |
78 |
self.w(u'</foaf:Person>\n') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1288
diff
changeset
|
79 |
|
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1288
diff
changeset
|
80 |
from logilab.common.deprecation import class_renamed |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1288
diff
changeset
|
81 |
EUserPrimaryView = class_renamed('EUserPrimaryView', CWUserPrimaryView) |