author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Wed, 02 Dec 2009 15:08:11 +0100 | |
branch | stable |
changeset 3972 | ec3d294034bf |
parent 3971 | 7cfbc35dce7e |
child 3974 | 1d36d9904c41 |
permissions | -rw-r--r-- |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
1 |
"""The default primary view |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
2 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
3 |
:organization: Logilab |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1885
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1885
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
7 |
""" |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
8 |
__docformat__ = "restructuredtext en" |
1739 | 9 |
_ = unicode |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
10 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
11 |
from warnings import warn |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
12 |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2237
diff
changeset
|
13 |
from logilab.mtconverter import xml_escape |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
14 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
15 |
from cubicweb import Unauthorized |
3971
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
16 |
from cubicweb.selectors import match_kwargs |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
17 |
from cubicweb.view import EntityView |
2217
3a8cee8f8778
explicit display_name import
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2190
diff
changeset
|
18 |
from cubicweb.schema import display_name |
1739 | 19 |
from cubicweb.web import uicfg |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
20 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
21 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
22 |
class PrimaryView(EntityView): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
23 |
"""the full view of an non final entity""" |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
24 |
id = 'primary' |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
25 |
title = _('primary') |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
26 |
show_attr_label = True |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
27 |
show_rel_label = True |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
28 |
skip_none = True |
1739 | 29 |
rsection = uicfg.primaryview_section |
30 |
display_ctrl = uicfg.primaryview_display_ctrl |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
31 |
main_related_section = True |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
32 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
33 |
def html_headers(self): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
34 |
"""return a list of html headers (eg something to be inserted between |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
35 |
<head> and </head> of the returned page |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
36 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
37 |
by default primary views are indexed |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
38 |
""" |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
39 |
return [] |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
40 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
41 |
def cell_call(self, row, col): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
42 |
self.row = row |
2402
321a87654988
strange, how does it work by computing maxrelated once everything is done ?
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2400
diff
changeset
|
43 |
self.maxrelated = self.req.property_value('navigation.related-limit') |
2384
6220783caa4b
[primary] cleanup, render_entity -> cell_call
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2381
diff
changeset
|
44 |
entity = self.complete_entity(row, col) |
2400
17b1f0b80fe8
[primary] restore render_entity, as it is a bit too much work to update everything accordingly
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2384
diff
changeset
|
45 |
self.render_entity(entity) |
17b1f0b80fe8
[primary] restore render_entity, as it is a bit too much work to update everything accordingly
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2384
diff
changeset
|
46 |
|
17b1f0b80fe8
[primary] restore render_entity, as it is a bit too much work to update everything accordingly
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2384
diff
changeset
|
47 |
def render_entity(self, entity): |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
48 |
self.render_entity_title(entity) |
3849
afba6d304e71
deactivate toolbox until 3.6
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3845
diff
changeset
|
49 |
# XXX uncomment this in 3.6 |
afba6d304e71
deactivate toolbox until 3.6
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3845
diff
changeset
|
50 |
#self.render_entity_toolbox(entity) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
51 |
# entity's attributes and relations, excluding meta data |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
52 |
# if the entity isn't meta itself |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
53 |
boxes = self._prepare_side_boxes(entity) |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
54 |
if boxes or hasattr(self, 'render_side_related'): |
1558
f63d090eb34a
some primary view fixes, need more (eg reledit doesn't work for non final relation
sylvain.thenault@logilab.fr
parents:
1554
diff
changeset
|
55 |
self.w(u'<table width="100%"><tr><td style="width: 75%">') |
3064
3fbcdf220ce9
fix so that entity's summary appears in main content cell to avoid layout pb
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2655
diff
changeset
|
56 |
self.render_entity_summary(entity) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
57 |
self.w(u'<div class="mainInfo">') |
2132
d7ae060cd746
move navcontenttop on the top
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
1977
diff
changeset
|
58 |
self.content_navigation_components('navcontenttop') |
2384
6220783caa4b
[primary] cleanup, render_entity -> cell_call
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2381
diff
changeset
|
59 |
self.render_entity_attributes(entity) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
60 |
if self.main_related_section: |
2384
6220783caa4b
[primary] cleanup, render_entity -> cell_call
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2381
diff
changeset
|
61 |
self.render_entity_relations(entity) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
62 |
self.w(u'</div>') |
2237
7e546c3d6ea5
[primary] fix #344249
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2217
diff
changeset
|
63 |
# side boxes |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
64 |
if boxes or hasattr(self, 'render_side_related'): |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
65 |
self.w(u'</td><td>') |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
66 |
self.w(u'<div class="primaryRight">') |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
67 |
if hasattr(self, 'render_side_related'): |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
68 |
warn('render_side_related is deprecated') |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
69 |
self.render_side_related(entity, []) |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
70 |
self.render_side_boxes(boxes) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
71 |
self.w(u'</div>') |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
72 |
self.w(u'</td></tr></table>') |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
73 |
self.content_navigation_components('navcontentbottom') |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
74 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
75 |
def content_navigation_components(self, context): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
76 |
self.w(u'<div class="%s">' % context) |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2402
diff
changeset
|
77 |
for comp in self.vreg['contentnavigation'].possible_vobjects( |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2402
diff
changeset
|
78 |
self.req, rset=self.rset, row=self.row, view=self, context=context): |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
79 |
try: |
1723 | 80 |
comp.render(w=self.w, row=self.row, view=self) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
81 |
except NotImplementedError: |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
82 |
warn('component %s doesnt implement cell_call, please update' |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
83 |
% comp.__class__, DeprecationWarning) |
1723 | 84 |
comp.render(w=self.w, view=self) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
85 |
self.w(u'</div>') |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
86 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
87 |
def render_entity_title(self, entity): |
1720 | 88 |
"""default implementation return dc_title""" |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2237
diff
changeset
|
89 |
title = xml_escape(entity.dc_title()) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
90 |
if title: |
3843
200719b9221f
display entity type in metadata section instead of default title of primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3809
diff
changeset
|
91 |
self.w(u'<h1>%s</h1>' % title) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
92 |
|
3845
596044fb7bc5
introduce render_entity_toolbox on default primary view to display components in the ctxtoolbar context, such as pdf icon, notification registration (nosylist)...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3844
diff
changeset
|
93 |
def render_entity_toolbox(self, entity): |
596044fb7bc5
introduce render_entity_toolbox on default primary view to display components in the ctxtoolbar context, such as pdf icon, notification registration (nosylist)...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3844
diff
changeset
|
94 |
self.content_navigation_components('ctxtoolbar') |
596044fb7bc5
introduce render_entity_toolbox on default primary view to display components in the ctxtoolbar context, such as pdf icon, notification registration (nosylist)...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3844
diff
changeset
|
95 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
96 |
def render_entity_metadata(self, entity): |
3844
c2625c512085
stop calling render_entity_metadata in primary view, provides a
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3843
diff
changeset
|
97 |
# XXX deprecated |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
98 |
entity.view('metadata', w=self.w) |
3064
3fbcdf220ce9
fix so that entity's summary appears in main content cell to avoid layout pb
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2655
diff
changeset
|
99 |
|
3fbcdf220ce9
fix so that entity's summary appears in main content cell to avoid layout pb
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2655
diff
changeset
|
100 |
def render_entity_summary(self, entity): |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
101 |
summary = self.summary(entity) # deprecate summary? |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
102 |
if summary: |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
103 |
self.w(u'<div class="summary">%s</div>' % summary) |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
104 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
105 |
def summary(self, entity): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
106 |
"""default implementation return an empty string""" |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
107 |
return u'' |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
108 |
|
1516
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
109 |
def render_entity_attributes(self, entity, siderelations=None): |
3809
1b9b51ee543e
[web ui] PrimaryView.render_attributes now uses a table
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3778
diff
changeset
|
110 |
entity_attributes = self._section_def(entity, 'attributes') |
1b9b51ee543e
[web ui] PrimaryView.render_attributes now uses a table
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3778
diff
changeset
|
111 |
if not entity_attributes: |
1b9b51ee543e
[web ui] PrimaryView.render_attributes now uses a table
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3778
diff
changeset
|
112 |
return |
1b9b51ee543e
[web ui] PrimaryView.render_attributes now uses a table
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3778
diff
changeset
|
113 |
self.w(u'<table>') |
1b9b51ee543e
[web ui] PrimaryView.render_attributes now uses a table
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3778
diff
changeset
|
114 |
for rschema, tschemas, role, dispctrl in entity_attributes: |
2361
8f00836580f1
[reledit] do NOT propose to edit composite-related entities (unlinking would destroy the other side)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2312
diff
changeset
|
115 |
vid = dispctrl.get('vid', 'reledit') |
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3681
diff
changeset
|
116 |
if rschema.final or vid == 'reledit': |
1558
f63d090eb34a
some primary view fixes, need more (eg reledit doesn't work for non final relation
sylvain.thenault@logilab.fr
parents:
1554
diff
changeset
|
117 |
value = entity.view(vid, rtype=rschema.type, role=role) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
118 |
else: |
1739 | 119 |
rset = self._relation_rset(entity, rschema, role, dispctrl) |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
120 |
if rset: |
1558
f63d090eb34a
some primary view fixes, need more (eg reledit doesn't work for non final relation
sylvain.thenault@logilab.fr
parents:
1554
diff
changeset
|
121 |
value = self.view(vid, rset) |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
122 |
else: |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
123 |
value = None |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
124 |
if self.skip_none and (value is None or value == ''): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
125 |
continue |
3970
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
126 |
try: |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
127 |
self._render_attribute(dispctrl, rschema, value, |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
128 |
role=role, table=True) |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
129 |
except TypeError: |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
130 |
warn('[3.6] _render_attribute prototype has changed, ' |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
131 |
'please update %s' % self.__class___, DeprecationWarning) |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
132 |
self._render_attribute(rschema, value, role=role, table=True) |
3809
1b9b51ee543e
[web ui] PrimaryView.render_attributes now uses a table
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3778
diff
changeset
|
133 |
self.w(u'</table>') |
1516
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
134 |
|
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
135 |
def render_entity_relations(self, entity, siderelations=None): |
1739 | 136 |
for rschema, tschemas, role, dispctrl in self._section_def(entity, 'relations'): |
137 |
rset = self._relation_rset(entity, rschema, role, dispctrl) |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
138 |
if rset: |
3970
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
139 |
try: |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
140 |
self._render_relation(dispctrl, rset, 'autolimited') |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
141 |
except TypeError: |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
142 |
warn('[3.6] _render_relation prototype has changed, ' |
3972 | 143 |
'please update %s' % self.__class__, DeprecationWarning) |
3970
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
144 |
self._render_relation(rset, dispctrl, 'autolimited', |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
145 |
self.show_rel_label) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
146 |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
147 |
def render_side_boxes(self, boxes): |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
148 |
"""display side related relations: |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
149 |
non-meta in a first step, meta in a second step |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
150 |
""" |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
151 |
for box in boxes: |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
152 |
if isinstance(box, tuple): |
1739 | 153 |
label, rset, vid = box |
1885
c2011d238e98
replace sideRelated with sideBox
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1752
diff
changeset
|
154 |
self.w(u'<div class="sideBox">') |
1516
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
155 |
self.wview(vid, rset, title=label) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
156 |
self.w(u'</div>') |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
157 |
else: |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
158 |
try: |
1723 | 159 |
box.render(w=self.w, row=self.row) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
160 |
except NotImplementedError: |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
161 |
# much probably a context insensitive box, which only implements |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
162 |
# .call() and not cell_call() |
1723 | 163 |
box.render(w=self.w) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
164 |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
165 |
def _prepare_side_boxes(self, entity): |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
166 |
sideboxes = [] |
1739 | 167 |
for rschema, tschemas, role, dispctrl in self._section_def(entity, 'sideboxes'): |
168 |
rset = self._relation_rset(entity, rschema, role, dispctrl) |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
169 |
if not rset: |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
170 |
continue |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
171 |
label = display_name(self.req, rschema.type, role) |
1739 | 172 |
vid = dispctrl.get('vid', 'sidebox') |
173 |
sideboxes.append( (label, rset, vid) ) |
|
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2402
diff
changeset
|
174 |
sideboxes += self.vreg['boxes'].possible_vobjects( |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2402
diff
changeset
|
175 |
self.req, rset=self.rset, row=self.row, view=self, |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2402
diff
changeset
|
176 |
context='incontext') |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
177 |
return sideboxes |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
178 |
|
1739 | 179 |
def _section_def(self, entity, where): |
180 |
rdefs = [] |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
181 |
eschema = entity.e_schema |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
182 |
for rschema, tschemas, role in eschema.relation_definitions(True): |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
183 |
matchtschemas = [] |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
184 |
for tschema in tschemas: |
1739 | 185 |
section = self.rsection.etype_get(eschema, rschema, role, |
186 |
tschema) |
|
187 |
if section == where: |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
188 |
matchtschemas.append(tschema) |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
189 |
if matchtschemas: |
1739 | 190 |
# XXX pick the latest dispctrl |
191 |
dispctrl = self.display_ctrl.etype_get(eschema, rschema, role, |
|
192 |
matchtschemas[-1]) |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
193 |
|
1739 | 194 |
rdefs.append( (rschema, matchtschemas, role, dispctrl) ) |
195 |
return sorted(rdefs, key=lambda x: x[-1]['order']) |
|
196 |
||
197 |
def _relation_rset(self, entity, rschema, role, dispctrl): |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
198 |
try: |
3681
cdbe4aac1198
fix max-related of related entities handling in primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3071
diff
changeset
|
199 |
dispctrl.setdefault('limit', self.maxrelated) |
cdbe4aac1198
fix max-related of related entities handling in primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3071
diff
changeset
|
200 |
rset = entity.related(rschema.type, role, limit=dispctrl['limit']+1) |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
201 |
except Unauthorized: |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
202 |
return |
1739 | 203 |
if 'filter' in dispctrl: |
204 |
rset = dispctrl['filter'](rset) |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
205 |
return rset |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
206 |
|
3970
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
207 |
def _render_relation(self, dispctrl, rset, defaultvid, showlabel): |
1583 | 208 |
self.w(u'<div class="section">') |
3970
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
209 |
if dispctrl.get('showlabel', self.show_rel_label): |
1739 | 210 |
self.w(u'<h4>%s</h4>' % self.req._(dispctrl['label'])) |
3705
5cd35123866b
get dispctrl through extra_kwargs to avoid error when a custom view is specified (potentially not taking any argument)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
211 |
self.wview(dispctrl.get('vid', defaultvid), rset, |
5cd35123866b
get dispctrl through extra_kwargs to avoid error when a custom view is specified (potentially not taking any argument)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
212 |
initargs={'dispctrl': dispctrl}) |
1583 | 213 |
self.w(u'</div>') |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
214 |
|
3970
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
215 |
def _render_attribute(self, dispctrl, rschema, value, |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
216 |
role='subject', table=False): |
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3681
diff
changeset
|
217 |
if rschema.final: |
3970
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
218 |
showlabel = dispctrl.get('showlabel', self.show_attr_label) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
219 |
else: |
3970
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
220 |
showlabel = dispctrl.get('showlabel', self.show_rel_label) |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
221 |
if dispctrl.get('label'): |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
222 |
label = self.req._(dispctrl.get('label')) |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
223 |
else: |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
224 |
label = display_name(self.req, rschema.type, role) |
e4ad7663610b
update _render_attribute / _render_relation prototype to gain more control on label through uicfg (for attributes and relations). Keep bw compat for crm/iliane
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3875
diff
changeset
|
225 |
self.field(label, value, show_label=showlabel, tr=False, table=table) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
226 |
|
1516
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
227 |
|
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
228 |
class RelatedView(EntityView): |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
229 |
id = 'autolimited' |
3681
cdbe4aac1198
fix max-related of related entities handling in primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3071
diff
changeset
|
230 |
|
3705
5cd35123866b
get dispctrl through extra_kwargs to avoid error when a custom view is specified (potentially not taking any argument)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
231 |
def call(self, **kwargs): |
3681
cdbe4aac1198
fix max-related of related entities handling in primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3071
diff
changeset
|
232 |
# nb: rset retreived using entity.related with limit + 1 if any |
cdbe4aac1198
fix max-related of related entities handling in primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3071
diff
changeset
|
233 |
# because of that, we known that rset.printable_rql() will return |
cdbe4aac1198
fix max-related of related entities handling in primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3071
diff
changeset
|
234 |
# rql with no limit set anyway (since it's handled manually) |
3705
5cd35123866b
get dispctrl through extra_kwargs to avoid error when a custom view is specified (potentially not taking any argument)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
235 |
if 'dispctrl' in self.extra_kwargs: |
5cd35123866b
get dispctrl through extra_kwargs to avoid error when a custom view is specified (potentially not taking any argument)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
236 |
limit = self.extra_kwargs['dispctrl'].get('limit') |
5cd35123866b
get dispctrl through extra_kwargs to avoid error when a custom view is specified (potentially not taking any argument)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
237 |
else: |
5cd35123866b
get dispctrl through extra_kwargs to avoid error when a custom view is specified (potentially not taking any argument)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
238 |
limit = None |
1516
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
239 |
# if not too many entities, show them all in a list |
3681
cdbe4aac1198
fix max-related of related entities handling in primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3071
diff
changeset
|
240 |
if limit is None or self.rset.rowcount <= limit: |
1516
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
241 |
if self.rset.rowcount == 1: |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
242 |
self.wview('incontext', self.rset, row=0) |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
243 |
elif 1 < self.rset.rowcount <= 5: |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
244 |
self.wview('csv', self.rset) |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
245 |
else: |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
246 |
self.w(u'<div>') |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
247 |
self.wview('simplelist', self.rset) |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
248 |
self.w(u'</div>') |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
249 |
# else show links to display related entities |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
250 |
else: |
3778
fd5449479584
so bad tests hasn't find that one...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3705
diff
changeset
|
251 |
rql = self.rset.printable_rql() |
3681
cdbe4aac1198
fix max-related of related entities handling in primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3071
diff
changeset
|
252 |
self.rset.limit(limit) # remove extra entity |
1516
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
253 |
self.w(u'<div>') |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
254 |
self.wview('simplelist', self.rset) |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
255 |
self.w(u'[<a href="%s">%s</a>]' % (self.build_url(rql=rql), |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
256 |
self.req._('see them all'))) |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
257 |
self.w(u'</div>') |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2402
diff
changeset
|
258 |
|
3971
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
259 |
|
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
260 |
class URLAttributeView(EntityView): |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
261 |
"""use this view for attributes whose value is an url and that you want |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
262 |
to display as clickable link |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
263 |
""" |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
264 |
id = 'urlattr' |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
265 |
__select__ = EntityView.__select__ & match_kwargs('rtype') |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
266 |
|
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
267 |
def cell_call(self, row, col, rtype, **kwargs): |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
268 |
entity = self.rset.get_entity(row, col) |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
269 |
url = entity.printable_value(rtype) |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
270 |
if url: |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
271 |
self.w(u'<a href="%s">%s</a>' % (url, url)) |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
272 |
|
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
273 |
|
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2402
diff
changeset
|
274 |
## default primary ui configuration ########################################### |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2402
diff
changeset
|
275 |
|
3875
c2bd7922cdaf
use shorter notation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3849
diff
changeset
|
276 |
_pvs = uicfg.primaryview_section |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2402
diff
changeset
|
277 |
for rtype in ('eid', 'creation_date', 'modification_date', 'cwuri', |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2402
diff
changeset
|
278 |
'is', 'is_instance_of', 'identity', |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2655
diff
changeset
|
279 |
'owned_by', 'created_by', 'in_state', |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2655
diff
changeset
|
280 |
'wf_info_for', 'by_transition', 'from_state', 'to_state', |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2655
diff
changeset
|
281 |
'require_permission', 'from_entity', 'to_entity', |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2402
diff
changeset
|
282 |
'see_also'): |
3875
c2bd7922cdaf
use shorter notation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3849
diff
changeset
|
283 |
_pvs.tag_subject_of(('*', rtype, '*'), 'hidden') |
c2bd7922cdaf
use shorter notation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3849
diff
changeset
|
284 |
_pvs.tag_object_of(('*', rtype, '*'), 'hidden') |
c2bd7922cdaf
use shorter notation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3849
diff
changeset
|
285 |
|
c2bd7922cdaf
use shorter notation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3849
diff
changeset
|
286 |
_pvs.tag_subject_of(('*', 'use_email', '*'), 'attributes') |
c2bd7922cdaf
use shorter notation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3849
diff
changeset
|
287 |
_pvs.tag_subject_of(('*', 'primary_email', '*'), 'hidden') |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2402
diff
changeset
|
288 |
|
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2402
diff
changeset
|
289 |
for attr in ('name', 'final'): |
3875
c2bd7922cdaf
use shorter notation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3849
diff
changeset
|
290 |
_pvs.tag_attribute(('CWEType', attr), 'hidden') |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2402
diff
changeset
|
291 |
for attr in ('name', 'final', 'symetric', 'inlined'): |
3875
c2bd7922cdaf
use shorter notation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3849
diff
changeset
|
292 |
_pvs.tag_attribute(('CWRType', attr), 'hidden') |