author | sylvain.thenault@logilab.fr |
Mon, 04 May 2009 16:04:02 +0200 | |
branch | tls-sprint |
changeset 1658 | 3f3672f76399 |
parent 1641 | 2c80b09d8d86 |
child 1659 | 838eaecaa458 |
permissions | -rw-r--r-- |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1365
diff
changeset
|
1 |
"""Specific views for CWProperty |
0 | 2 |
|
3 |
:organization: Logilab |
|
984 | 4 |
:copyright: 2007-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" |
|
1641 | 8 |
_ = unicode |
0 | 9 |
|
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
10 |
from logilab.mtconverter import html_escape |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
11 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
12 |
from logilab.common.decorators import cached |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
13 |
|
1309 | 14 |
from cubicweb import UnknownProperty |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
15 |
from cubicweb.selectors import (one_line_rset, none_rset, implements, |
1537
788b5ca792bd
fix rfields declaration order
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1533
diff
changeset
|
16 |
match_user_groups) |
984 | 17 |
from cubicweb.view import StartupView |
1658
3f3672f76399
delete-trailing-whitespaces, update import
sylvain.thenault@logilab.fr
parents:
1641
diff
changeset
|
18 |
from cubicweb.web import uicfg, stdmsgs |
1318
50e1a778c5ee
new FormViewMixIn class, cleanup FormMixIn (to remove once cubes doesn't use it anymore)
sylvain.thenault@logilab.fr
parents:
1314
diff
changeset
|
19 |
from cubicweb.web.form import CompositeForm, EntityFieldsForm, FormViewMixIn |
1309 | 20 |
from cubicweb.web.formfields import FIELDS, StringField |
21 |
from cubicweb.web.formwidgets import Select, Button, SubmitButton |
|
1658
3f3672f76399
delete-trailing-whitespaces, update import
sylvain.thenault@logilab.fr
parents:
1641
diff
changeset
|
22 |
from cubicweb.web.views import primaryviews |
1151
b20677336ee6
turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents:
1149
diff
changeset
|
23 |
|
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
24 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
25 |
# some string we want to be internationalizable for nicer display of eproperty |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
26 |
# groups |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
27 |
_('navigation') |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
28 |
_('ui') |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
29 |
_('actions') |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
30 |
_('boxes') |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
31 |
_('components') |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
32 |
_('contentnavigation') |
1641 | 33 |
_('navigation.combobox-limit') |
34 |
_('navigation.page-size') |
|
35 |
_('navigation.related-limit') |
|
36 |
_('navigation.short-line-size') |
|
37 |
_('ui.date-format') |
|
38 |
_('ui.datetime-format') |
|
39 |
_('ui.default-text-format') |
|
40 |
_('ui.fckeditor') |
|
41 |
_('ui.float-format') |
|
42 |
_('ui.language') |
|
43 |
_('ui.time-format') |
|
44 |
_('open all') |
|
45 |
_('ui.main-template') |
|
46 |
_('ui.site-title') |
|
47 |
_('ui.encoding') |
|
48 |
_('category') |
|
0 | 49 |
|
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
50 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
51 |
def make_togglable_link(nodeid, label, cookiename): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
52 |
"""builds a HTML link that switches the visibility & remembers it""" |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
53 |
action = u"javascript: toggle_and_remember_visibility('%s', '%s')" % \ |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
54 |
(nodeid, cookiename) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
55 |
return u'<a href="%s">%s</a>' % (action, label) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
56 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
57 |
def css_class(someclass): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
58 |
return someclass and 'class="%s"' % someclass or '' |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
59 |
|
1309 | 60 |
|
1658
3f3672f76399
delete-trailing-whitespaces, update import
sylvain.thenault@logilab.fr
parents:
1641
diff
changeset
|
61 |
class CWPropertyPrimaryView(primary.PrimaryView): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1365
diff
changeset
|
62 |
__select__ = implements('CWProperty') |
1309 | 63 |
skip_none = False |
64 |
||
65 |
||
1318
50e1a778c5ee
new FormViewMixIn class, cleanup FormMixIn (to remove once cubes doesn't use it anymore)
sylvain.thenault@logilab.fr
parents:
1314
diff
changeset
|
66 |
class SystemEPropertiesForm(FormViewMixIn, StartupView): |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
67 |
id = 'systemepropertiesform' |
1309 | 68 |
__select__ = none_rset() & match_user_groups('managers') |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
69 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
70 |
title = _('site configuration') |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
71 |
category = 'startupview' |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
72 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
73 |
def linkable(self): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
74 |
return True |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
75 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
76 |
def url(self): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
77 |
"""return the url associated with this view. We can omit rql here""" |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
78 |
return self.build_url('view', vid=self.id) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
79 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
80 |
def _cookie_name(self, somestr): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
81 |
return str('%s_property_%s' % (self.config.appid, somestr)) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
82 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
83 |
def _group_status(self, group, default=u'hidden'): |
1309 | 84 |
"""return css class name 'hidden' (collapsed), or '' (open)""" |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
85 |
cookies = self.req.get_cookie() |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
86 |
cookiename = self._cookie_name(group) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
87 |
cookie = cookies.get(cookiename) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
88 |
if cookie is None: |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
89 |
cookies[cookiename] = default |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
90 |
self.req.set_cookie(cookies, cookiename, maxage=None) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
91 |
status = default |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
92 |
else: |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
93 |
status = cookie.value |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
94 |
return status |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
95 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
96 |
def call(self, **kwargs): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
97 |
"""The default view representing the application's index""" |
1318
50e1a778c5ee
new FormViewMixIn class, cleanup FormMixIn (to remove once cubes doesn't use it anymore)
sylvain.thenault@logilab.fr
parents:
1314
diff
changeset
|
98 |
self.req.add_js('cubicweb.preferences.js') |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
99 |
self.req.add_css('cubicweb.preferences.css') |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
100 |
vreg = self.vreg |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
101 |
values = self.defined_keys |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
102 |
groupedopts = {} |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
103 |
mainopts = {} |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
104 |
# "self.id=='systemepropertiesform'" to skip site wide properties on |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
105 |
# user's preference but not site's configuration |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
106 |
for key in vreg.user_property_keys(self.id=='systemepropertiesform'): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
107 |
parts = key.split('.') |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
108 |
if parts[0] in vreg: |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
109 |
# appobject configuration |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
110 |
reg, oid, propid = parts |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
111 |
groupedopts.setdefault(reg, {}).setdefault(oid, []).append(key) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
112 |
else: |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
113 |
mainopts.setdefault(parts[0], []).append(key) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
114 |
# precompute form to consume error message |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
115 |
for group, keys in mainopts.items(): |
1309 | 116 |
mainopts[group] = self.form(keys, True) |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
117 |
for group, objects in groupedopts.items(): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
118 |
for oid, keys in objects.items(): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
119 |
groupedopts[group][oid] = self.form(keys, True) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
120 |
w = self.w |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
121 |
req = self.req |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
122 |
_ = req._ |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
123 |
w(u'<h1>%s</h1>\n' % _(self.title)) |
1365 | 124 |
# we don't want this in each sub-forms |
125 |
w(u'<div id="progress">%s</div>' % self.req._('validating...')) |
|
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
126 |
for label, group, form in sorted((_(g), g, f) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
127 |
for g, f in mainopts.iteritems()): |
1507 | 128 |
status = css_class(self._group_status(group)) |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
129 |
w(u'<h2 class="propertiesform">%s</h2>\n' % |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
130 |
(make_togglable_link('fieldset_' + group, label, |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
131 |
self._cookie_name(group)))) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
132 |
w(u'<div id="fieldset_%s" %s>' % (group, status)) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
133 |
w(form) |
1320 | 134 |
w(u'</div>') |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
135 |
for label, group, objects in sorted((_(g), g, o) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
136 |
for g, o in groupedopts.iteritems()): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
137 |
status = css_class(self._group_status(group)) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
138 |
w(u'<h2 class="propertiesform">%s</h2>\n' % |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
139 |
(make_togglable_link('fieldset_' + group, label, |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
140 |
self._cookie_name(group)))) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
141 |
w(u'<div id="fieldset_%s" %s>' % (group, status)) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
142 |
for label, oid, form in sorted((self.req.__('%s_%s' % (group, o)), o, f) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
143 |
for o, f in objects.iteritems()): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
144 |
w(u'<fieldset class="subentity">') |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
145 |
w(u'<legend class="componentTitle">%s</legend>\n' % label) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
146 |
docmsgid = '%s_%s_description' % (group, oid) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
147 |
doc = _(docmsgid) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
148 |
if doc != docmsgid: |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
149 |
w(u'<p class="description">%s</p>' % html_escape(doc)) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
150 |
w(form) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
151 |
w(u'</fieldset>') |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
152 |
w(u'</div>') |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
153 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
154 |
@property |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
155 |
@cached |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
156 |
def eprops_rset(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1365
diff
changeset
|
157 |
return self.req.execute('Any P,K,V WHERE P is CWProperty, P pkey K, ' |
1309 | 158 |
'P value V, NOT P for_user U') |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
159 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
160 |
@property |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
161 |
def defined_keys(self): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
162 |
values = {} |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
163 |
for i, entity in enumerate(self.eprops_rset.entities()): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
164 |
values[entity.pkey] = i |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
165 |
return values |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
166 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
167 |
def entity_for_key(self, key): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
168 |
values = self.defined_keys |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
169 |
if key in values: |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
170 |
entity = self.eprops_rset.get_entity(values[key], 0) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
171 |
else: |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1365
diff
changeset
|
172 |
entity = self.vreg.etype_class('CWProperty')(self.req, None, None) |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
173 |
entity.eid = self.req.varmaker.next() |
1309 | 174 |
entity['pkey'] = key |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
175 |
entity['value'] = self.vreg.property_value(key) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
176 |
return entity |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
177 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
178 |
def form(self, keys, splitlabel=False): |
1309 | 179 |
buttons = [SubmitButton(), |
180 |
Button(stdmsgs.BUTTON_CANCEL, cwaction='cancel')] |
|
181 |
form = CompositeForm(self.req, domid=None, action=self.build_url(), |
|
1507 | 182 |
form_buttons=buttons, |
1309 | 183 |
submitmsg=self.req._('changes applied')) |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
184 |
path = self.req.relative_path() |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
185 |
if '?' in path: |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
186 |
path, params = path.split('?', 1) |
1309 | 187 |
form.form_add_hidden('__redirectparams', params) |
188 |
form.form_add_hidden('__redirectpath', path) |
|
1507 | 189 |
for key in keys: |
1309 | 190 |
self.form_row(form, key, splitlabel) |
1365 | 191 |
return form.form_render(display_progress_div=False) |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
192 |
|
1309 | 193 |
def form_row(self, form, key, splitlabel): |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
194 |
entity = self.entity_for_key(key) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
195 |
if splitlabel: |
1309 | 196 |
label = key.split('.')[-1] |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
197 |
else: |
1309 | 198 |
label = key |
199 |
subform = EntityFieldsForm(self.req, entity=entity, set_error_url=False) |
|
200 |
subform.append_field(PropertyValueField(name='value', label=label, |
|
201 |
eidparam=True)) |
|
202 |
subform.vreg = self.vreg |
|
203 |
subform.form_add_hidden('pkey', key, eidparam=True) |
|
204 |
form.form_add_subform(subform) |
|
205 |
return subform |
|
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
206 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
207 |
|
879 | 208 |
def is_user_prefs(cls, req, rset, row=None, col=0, **kwargs): |
209 |
return req.user.eid == rset[row or 0][col] |
|
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
210 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
211 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
212 |
class EPropertiesForm(SystemEPropertiesForm): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
213 |
id = 'epropertiesform' |
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
691
diff
changeset
|
214 |
__select__ = ( |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
215 |
# we don't want guests to be able to come here |
792 | 216 |
match_user_groups('users', 'managers') & |
1309 | 217 |
(none_rset() | ((one_line_rset() & is_user_prefs) & |
218 |
(one_line_rset() & match_user_groups('managers')))) |
|
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
219 |
) |
1507 | 220 |
|
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
221 |
title = _('preferences') |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
222 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
223 |
@property |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
224 |
def user(self): |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
225 |
if self.rset is None: |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
226 |
return self.req.user |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
227 |
return self.rset.get_entity(self.row or 0, self.col or 0) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
228 |
|
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
229 |
@property |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
230 |
@cached |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
231 |
def eprops_rset(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1365
diff
changeset
|
232 |
return self.req.execute('Any P,K,V WHERE P is CWProperty, P pkey K, P value V,' |
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
233 |
'P for_user U, U eid %(x)s', {'x': self.user.eid}) |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
234 |
|
1309 | 235 |
def form_row(self, form, key, splitlabel): |
236 |
subform = super(EPropertiesForm, self).form_row(form, key, splitlabel) |
|
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
237 |
# if user is in the managers group and the property is being created, |
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
238 |
# we have to set for_user explicitly |
1309 | 239 |
if not subform.edited_entity.has_eid() and self.user.matching_groups('managers'): |
240 |
subform.form_add_hidden('for_user', self.user.eid, eidparam=True) |
|
241 |
||
242 |
||
1314
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
243 |
# eproperty form objects ###################################################### |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
244 |
|
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
245 |
class PlaceHolderWidget(object): |
1507 | 246 |
|
1314
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
247 |
def render(self, form, field): |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
248 |
domid = form.context[field]['id'] |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
249 |
# empty span as well else html validation fail (label is refering to |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
250 |
# this id) |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
251 |
return '<div id="div:%s"><span id="%s">%s</span></div>' % ( |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
252 |
domid, domid, form.req._('select a key first')) |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
253 |
|
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
254 |
|
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
255 |
class NotEditableWidget(object): |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
256 |
def __init__(self, value, msg=None): |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
257 |
self.value = value |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
258 |
self.msg = msg |
1507 | 259 |
|
1314
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
260 |
def render(self, form, field): |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
261 |
domid = form.context[field]['id'] |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
262 |
value = '<span class="value" id="%s">%s</span>' % (domid, self.value) |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
263 |
if self.msg: |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
264 |
value + '<div class="helper">%s</div>' % self.msg |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
265 |
return value |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
266 |
|
1309 | 267 |
|
268 |
class PropertyKeyField(StringField): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1365
diff
changeset
|
269 |
"""specific field for CWProperty.pkey to set the value widget according to |
1309 | 270 |
the selected key |
271 |
""" |
|
272 |
widget = Select |
|
1507 | 273 |
|
1309 | 274 |
def render(self, form, renderer): |
275 |
wdg = self.get_widget(form) |
|
276 |
wdg.attrs['tabindex'] = form.req.next_tabindex() |
|
277 |
wdg.attrs['onchange'] = "javascript:setPropValueWidget('%s', %s)" % ( |
|
278 |
form.edited_entity.eid, form.req.next_tabindex()) |
|
279 |
return wdg.render(form, self) |
|
1507 | 280 |
|
1309 | 281 |
def vocabulary(self, form): |
282 |
entity = form.edited_entity |
|
283 |
_ = form.req._ |
|
284 |
if entity.has_eid(): |
|
285 |
return [(_(entity.pkey), entity.pkey)] |
|
286 |
# key beginning with 'system.' should usually not be edited by hand |
|
287 |
choices = entity.vreg.user_property_keys() |
|
1314
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
288 |
return [(u'', u'')] + sorted(zip((_(v) for v in choices), choices)) |
1309 | 289 |
|
290 |
||
291 |
class PropertyValueField(StringField): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1365
diff
changeset
|
292 |
"""specific field for CWProperty.value which will be different according to |
1309 | 293 |
the selected key type and vocabulary information |
1314
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
294 |
""" |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
295 |
widget = PlaceHolderWidget |
1507 | 296 |
|
1309 | 297 |
def render(self, form, renderer=None, tabindex=None): |
298 |
wdg = self.get_widget(form) |
|
299 |
if tabindex is not None: |
|
300 |
wdg.attrs['tabindex'] = tabindex |
|
301 |
return wdg.render(form, self) |
|
691
35133d86970b
move EProperty management views into eproperties.py
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
302 |
|
1309 | 303 |
def form_init(self, form): |
304 |
entity = form.edited_entity |
|
1314
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
305 |
if not (entity.has_eid() or 'pkey' in entity): |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
306 |
# no key set yet, just include an empty div which will be filled |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
307 |
# on key selection |
dc5499bff1a9
fix primary edition of eproperty (weird js pb remaining though)
sylvain.thenault@logilab.fr
parents:
1309
diff
changeset
|
308 |
return |
1309 | 309 |
try: |
310 |
pdef = form.vreg.property_info(entity.pkey) |
|
311 |
except UnknownProperty, ex: |
|
312 |
self.warning('%s (you should probably delete that property ' |
|
313 |
'from the database)', ex) |
|
314 |
msg = form.req._('you should probably delete that property') |
|
315 |
self.widget = NotEditableWidget(entity.printable_value('value'), |
|
316 |
'%s (%s)' % (msg, ex)) |
|
317 |
if entity.pkey.startswith('system.'): |
|
318 |
msg = form.req._('value associated to this key is not editable ' |
|
319 |
'manually') |
|
320 |
self.widget = NotEditableWidget(entity.printable_value('value'), msg) |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1365
diff
changeset
|
321 |
# XXX race condition when used from CWPropertyForm, should not rely on |
1309 | 322 |
# instance attributes |
323 |
self.initial = pdef['default'] |
|
324 |
self.help = pdef['help'] |
|
325 |
vocab = pdef['vocabulary'] |
|
326 |
if vocab is not None: |
|
327 |
if callable(vocab): |
|
328 |
# list() just in case its a generator function |
|
329 |
self.choices = list(vocab(form.req)) |
|
330 |
else: |
|
331 |
self.choices = vocab |
|
332 |
wdg = Select() |
|
333 |
else: |
|
334 |
wdg = FIELDS[pdef['type']].widget() |
|
335 |
if pdef['type'] == 'Boolean': |
|
336 |
self.choices = [(form.req._('yes'), '1'), (form.req._('no'), '')] |
|
337 |
elif pdef['type'] in ('Float', 'Int'): |
|
338 |
wdg.attrs.setdefault('size', 3) |
|
339 |
self.widget = wdg |
|
340 |
||
1537
788b5ca792bd
fix rfields declaration order
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1533
diff
changeset
|
341 |
|
788b5ca792bd
fix rfields declaration order
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1533
diff
changeset
|
342 |
uicfg.rfields.tag_relation(PropertyKeyField, ('CWProperty', 'pkey', '*'), 'subject') |
788b5ca792bd
fix rfields declaration order
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1533
diff
changeset
|
343 |
uicfg.rfields.tag_relation(PropertyValueField, ('CWProperty', 'value', '*'), 'subject') |