author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Thu, 07 Oct 2010 17:25:24 +0200 | |
branch | stable |
changeset 6406 | 39663630ca3c |
parent 6335 | d13d488a453e |
child 6366 | 1806148d6ce8 |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5896 | 18 |
"""The default primary view""" |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
19 |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
20 |
__docformat__ = "restructuredtext en" |
1739 | 21 |
_ = unicode |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
22 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
23 |
from warnings import warn |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
24 |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2237
diff
changeset
|
25 |
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
|
26 |
|
6235
d5f7bd102282
[primary view] properly handle case where view specified in pvdc['vid'] isn't selectable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6234
diff
changeset
|
27 |
from cubicweb import Unauthorized, NoSelectableObject |
3971
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
28 |
from cubicweb.selectors import match_kwargs |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
29 |
from cubicweb.view import EntityView |
5065
01d85f3a3d9e
[primary view] skip virtual rtypes anyway
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4742
diff
changeset
|
30 |
from cubicweb.schema import VIRTUAL_RTYPES, display_name |
1739 | 31 |
from cubicweb.web import uicfg |
1491
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 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
34 |
class PrimaryView(EntityView): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
35 |
"""the full view of an non final entity""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3072
diff
changeset
|
36 |
__regid__ = 'primary' |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
37 |
title = _('primary') |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
38 |
show_attr_label = True |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
39 |
show_rel_label = True |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
40 |
skip_none = True |
1739 | 41 |
rsection = uicfg.primaryview_section |
42 |
display_ctrl = uicfg.primaryview_display_ctrl |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
43 |
main_related_section = True |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
44 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
45 |
def html_headers(self): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
46 |
"""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
|
47 |
<head> and </head> of the returned page |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
48 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
49 |
by default primary views are indexed |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
50 |
""" |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
51 |
return [] |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
52 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
53 |
def cell_call(self, row, col): |
2889
5b42222d3b88
should affect cw_row/cw_col
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2813
diff
changeset
|
54 |
self.cw_row = row |
5b42222d3b88
should affect cw_row/cw_col
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2813
diff
changeset
|
55 |
self.cw_col = col |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
56 |
entity = self.cw_rset.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
|
57 |
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
|
58 |
|
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
|
59 |
def render_entity(self, entity): |
4566
c49dba55c0a6
[views] toolbox must be rendered before the title to appear at top right
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4467
diff
changeset
|
60 |
self.render_entity_toolbox(entity) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
61 |
self.render_entity_title(entity) |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
62 |
# entity's attributes and relations, excluding meta data |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
63 |
# if the entity isn't meta itself |
3974
1d36d9904c41
slightly adapt title and hide boxes when view is called as a non primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3972
diff
changeset
|
64 |
if self.is_primary(): |
1d36d9904c41
slightly adapt title and hide boxes when view is called as a non primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3972
diff
changeset
|
65 |
boxes = self._prepare_side_boxes(entity) |
1d36d9904c41
slightly adapt title and hide boxes when view is called as a non primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3972
diff
changeset
|
66 |
else: |
1d36d9904c41
slightly adapt title and hide boxes when view is called as a non primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3972
diff
changeset
|
67 |
boxes = None |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
68 |
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
|
69 |
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
|
70 |
self.render_entity_summary(entity) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
71 |
self.w(u'<div class="mainInfo">') |
2132
d7ae060cd746
move navcontenttop on the top
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
1977
diff
changeset
|
72 |
self.content_navigation_components('navcontenttop') |
2384
6220783caa4b
[primary] cleanup, render_entity -> cell_call
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2381
diff
changeset
|
73 |
self.render_entity_attributes(entity) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
74 |
if self.main_related_section: |
2384
6220783caa4b
[primary] cleanup, render_entity -> cell_call
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2381
diff
changeset
|
75 |
self.render_entity_relations(entity) |
4742
fac80328a6a3
[primary] navcontentbottom sections should be in the content table as navcontenttop
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4572
diff
changeset
|
76 |
self.content_navigation_components('navcontentbottom') |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
77 |
self.w(u'</div>') |
2237
7e546c3d6ea5
[primary] fix #344249
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2217
diff
changeset
|
78 |
# side boxes |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
79 |
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
|
80 |
self.w(u'</td><td>') |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
81 |
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
|
82 |
if hasattr(self, 'render_side_related'): |
5614
37b31a7b8e74
[primary] add missing version number to deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5560
diff
changeset
|
83 |
warn('[3.2] render_side_related is deprecated') |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
84 |
self.render_side_related(entity, []) |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
85 |
self.render_side_boxes(boxes) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
86 |
self.w(u'</div>') |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
87 |
self.w(u'</td></tr></table>') |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
88 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
89 |
def content_navigation_components(self, context): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
90 |
self.w(u'<div class="%s">' % context) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
91 |
for comp in self._cw.vreg['contentnavigation'].poss_visible_objects( |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
92 |
self._cw, rset=self.cw_rset, row=self.cw_row, view=self, context=context): |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
93 |
try: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
94 |
comp.render(w=self.w, row=self.cw_row, view=self) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
95 |
except NotImplementedError: |
5614
37b31a7b8e74
[primary] add missing version number to deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5560
diff
changeset
|
96 |
warn('[3.2] component %s doesnt implement cell_call, please update' |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
97 |
% comp.__class__, DeprecationWarning) |
1723 | 98 |
comp.render(w=self.w, view=self) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
99 |
self.w(u'</div>') |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
100 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
101 |
def render_entity_title(self, entity): |
1720 | 102 |
"""default implementation return dc_title""" |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2237
diff
changeset
|
103 |
title = xml_escape(entity.dc_title()) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
104 |
if title: |
3974
1d36d9904c41
slightly adapt title and hide boxes when view is called as a non primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3972
diff
changeset
|
105 |
if self.is_primary(): |
1d36d9904c41
slightly adapt title and hide boxes when view is called as a non primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3972
diff
changeset
|
106 |
self.w(u'<h1>%s</h1>' % title) |
1d36d9904c41
slightly adapt title and hide boxes when view is called as a non primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3972
diff
changeset
|
107 |
else: |
4104
7e478d7caf20
[mq]: small_api_changes_for_3.6
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
4074
diff
changeset
|
108 |
atitle = self._cw._('follow this link for more information on this %s') % entity.dc_type() |
3974
1d36d9904c41
slightly adapt title and hide boxes when view is called as a non primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3972
diff
changeset
|
109 |
self.w(u'<h4><a href="%s" title="%s">%s</a></h4>' |
1d36d9904c41
slightly adapt title and hide boxes when view is called as a non primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3972
diff
changeset
|
110 |
% (entity.absolute_url(), atitle, title)) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
111 |
|
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
|
112 |
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
|
113 |
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
|
114 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
115 |
def render_entity_metadata(self, entity): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
116 |
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
|
117 |
|
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
|
118 |
def render_entity_summary(self, entity): |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
119 |
summary = self.summary(entity) # deprecate summary? |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
120 |
if summary: |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
121 |
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
|
122 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
123 |
def summary(self, entity): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
124 |
"""default implementation return an empty string""" |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
125 |
return u'' |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
126 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
127 |
def render_entity_attributes(self, entity): |
5180
25c3269b2232
[xthml] fix #696079, potential empty table cause xhtml validation error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5065
diff
changeset
|
128 |
display_attributes = [] |
25c3269b2232
[xthml] fix #696079, potential empty table cause xhtml validation error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5065
diff
changeset
|
129 |
for rschema, _, role, dispctrl in self._section_def(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
|
130 |
vid = dispctrl.get('vid', 'reledit') |
6070
0ca78eb1a3c2
[primary] use a new rtypevid flag in primary view display controller, allowing to tell the view for a non final relation should be called as an attribute view (eg, not on the target rset)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5896
diff
changeset
|
131 |
if rschema.final or vid == 'reledit' or dispctrl.get('rtypevid'): |
6086
2b53a8669c98
[primary] handle final relation (eg attribute) in the relations section, and give dispctrl to view's extra kwargs as for non final relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6070
diff
changeset
|
132 |
value = entity.view(vid, rtype=rschema.type, role=role, |
2b53a8669c98
[primary] handle final relation (eg attribute) in the relations section, and give dispctrl to view's extra kwargs as for non final relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6070
diff
changeset
|
133 |
initargs={'dispctrl': dispctrl}) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
134 |
else: |
1739 | 135 |
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
|
136 |
if rset: |
4382
6fb02edd05da
3.6 api update, cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
137 |
value = self._cw.view(vid, rset) |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
138 |
else: |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
139 |
value = None |
5180
25c3269b2232
[xthml] fix #696079, potential empty table cause xhtml validation error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5065
diff
changeset
|
140 |
if not self.skip_none or (value is not None and value != ''): |
25c3269b2232
[xthml] fix #696079, potential empty table cause xhtml validation error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5065
diff
changeset
|
141 |
display_attributes.append( (rschema, role, dispctrl, value) ) |
25c3269b2232
[xthml] fix #696079, potential empty table cause xhtml validation error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5065
diff
changeset
|
142 |
if display_attributes: |
25c3269b2232
[xthml] fix #696079, potential empty table cause xhtml validation error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5065
diff
changeset
|
143 |
self.w(u'<table>') |
5182
3bc8250731fe
[primary] fix name error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5180
diff
changeset
|
144 |
for rschema, role, dispctrl, value in display_attributes: |
5180
25c3269b2232
[xthml] fix #696079, potential empty table cause xhtml validation error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5065
diff
changeset
|
145 |
try: |
25c3269b2232
[xthml] fix #696079, potential empty table cause xhtml validation error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5065
diff
changeset
|
146 |
self._render_attribute(dispctrl, rschema, value, |
25c3269b2232
[xthml] fix #696079, potential empty table cause xhtml validation error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5065
diff
changeset
|
147 |
role=role, table=True) |
6335
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
148 |
warn('[3.9] _render_attribute prototype has changed and ' |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
149 |
'renamed to render_attribute, please update %s' |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
150 |
% self.__class___, DeprecationWarning) |
5180
25c3269b2232
[xthml] fix #696079, potential empty table cause xhtml validation error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5065
diff
changeset
|
151 |
except TypeError: |
25c3269b2232
[xthml] fix #696079, potential empty table cause xhtml validation error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5065
diff
changeset
|
152 |
self._render_attribute(rschema, value, role=role, table=True) |
6335
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
153 |
warn('[3.6] _render_attribute prototype has changed and ' |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
154 |
'renamed to render_attribute, please update %s' |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
155 |
% self.__class___, DeprecationWarning) |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
156 |
except AttributeError: |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
157 |
label = self._rel_label(entity, rschema, role, dispctrl) |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
158 |
self.render_attribute(label, value, table=True) |
5180
25c3269b2232
[xthml] fix #696079, potential empty table cause xhtml validation error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5065
diff
changeset
|
159 |
self.w(u'</table>') |
1516
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
160 |
|
6335
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
161 |
def render_attribute(self, label, value, table=False): |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
162 |
self.field(label, value, tr=False, table=table) |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
163 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
164 |
def render_entity_relations(self, entity): |
1739 | 165 |
for rschema, tschemas, role, dispctrl in self._section_def(entity, 'relations'): |
6113
dbe17a3ebb9f
[primary view]Â consider rtypevid flag for relations in the 'relations' section as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6093
diff
changeset
|
166 |
if rschema.final or dispctrl.get('rtypevid'): |
6235
d5f7bd102282
[primary view] properly handle case where view specified in pvdc['vid'] isn't selectable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6234
diff
changeset
|
167 |
vid = dispctrl.get('vid', 'reledit') |
d5f7bd102282
[primary view] properly handle case where view specified in pvdc['vid'] isn't selectable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6234
diff
changeset
|
168 |
try: |
d5f7bd102282
[primary view] properly handle case where view specified in pvdc['vid'] isn't selectable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6234
diff
changeset
|
169 |
rview = self._cw.vreg['views'].select( |
d5f7bd102282
[primary view] properly handle case where view specified in pvdc['vid'] isn't selectable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6234
diff
changeset
|
170 |
vid, self._cw, rset=entity.cw_rset, row=entity.cw_row, |
6335
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
171 |
col=entity.cw_col, dispctrl=dispctrl, |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
172 |
rtype=rschema, role=role) |
6235
d5f7bd102282
[primary view] properly handle case where view specified in pvdc['vid'] isn't selectable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6234
diff
changeset
|
173 |
except NoSelectableObject: |
d5f7bd102282
[primary view] properly handle case where view specified in pvdc['vid'] isn't selectable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6234
diff
changeset
|
174 |
continue |
6335
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
175 |
value = rview.render(row=entity.cw_row, col=entity.cw_col, |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
176 |
rtype=rschema.type, role=role) |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
177 |
else: |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
178 |
rset = self._relation_rset(entity, rschema, role, dispctrl) |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
179 |
if not rset: |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
180 |
continue |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
181 |
if hasattr(self, '_render_relation'): |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
182 |
try: |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
183 |
self._render_relation(dispctrl, rset, 'autolimited') |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
184 |
warn('[3.9] _render_relation prototype has changed and has ' |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
185 |
'been renamed to render_relation, please update %s' |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
186 |
% self.__class__, DeprecationWarning) |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
187 |
except TypeError: |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
188 |
self._render_relation(rset, dispctrl, 'autolimited', |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
189 |
self.show_rel_label) |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
190 |
warn('[3.6] _render_relation prototype has changed and has ' |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
191 |
'been renamed to render_relation, please update %s' |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
192 |
% self.__class__, DeprecationWarning) |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
193 |
continue |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
194 |
vid = dispctrl.get('vid', 'autolimited') |
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
|
195 |
try: |
6335
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
196 |
rview = self._cw.vreg['views'].select( |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
197 |
vid, self._cw, rset=rset, dispctrl=dispctrl) |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
198 |
except NoSelectableObject: |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
199 |
continue |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
200 |
value = rview.render() |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
201 |
label = self._rel_label(entity, rschema, role, dispctrl) |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
202 |
self.render_relation(label, value) |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
203 |
|
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
204 |
def render_relation(self, label, value): |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
205 |
self.w(u'<div class="section">') |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
206 |
if label: |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
207 |
self.w(u'<h4>%s</h4>' % label) |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
208 |
self.w(value) |
d13d488a453e
[primary view] refactor label handling (hence render_[attribute|relation]) so we uniformly use _rel_label which provides properly contextified labels
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6291
diff
changeset
|
209 |
self.w(u'</div>') |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
210 |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
211 |
def render_side_boxes(self, boxes): |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
212 |
"""display side related relations: |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
213 |
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
|
214 |
""" |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
215 |
for box in boxes: |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
216 |
if isinstance(box, tuple): |
3975
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
217 |
try: |
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
218 |
label, rset, vid, dispctrl = box |
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
219 |
except ValueError: |
4572
9e0a86d3ba62
add version info to deprecation warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4566
diff
changeset
|
220 |
warn('[3.5] box views should now be defined as a 4-uple (label, rset, vid, dispctrl), ' |
3975
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
221 |
'please update %s' % self.__class__.__name__, |
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
222 |
DeprecationWarning) |
5560
b9a8e7109370
[primary view]Â fix name error on dispctrl w/ pre 3.5 box definition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5520
diff
changeset
|
223 |
label, rset, vid = box |
b9a8e7109370
[primary view]Â fix name error on dispctrl w/ pre 3.5 box definition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5520
diff
changeset
|
224 |
dispctrl = {} |
1885
c2011d238e98
replace sideRelated with sideBox
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1752
diff
changeset
|
225 |
self.w(u'<div class="sideBox">') |
5519
bdc6a7e724f3
[primary view] give dispctrl to side box views as for relations section
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
226 |
self.wview(vid, rset, title=label, initargs={'dispctrl': dispctrl}) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
227 |
self.w(u'</div>') |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
228 |
else: |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
229 |
try: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
230 |
box.render(w=self.w, row=self.cw_row) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
231 |
except NotImplementedError: |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
232 |
# 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
|
233 |
# .call() and not cell_call() |
1723 | 234 |
box.render(w=self.w) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
235 |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
236 |
def _prepare_side_boxes(self, entity): |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
237 |
sideboxes = [] |
1739 | 238 |
for rschema, tschemas, role, dispctrl in self._section_def(entity, 'sideboxes'): |
239 |
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
|
240 |
if not rset: |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
241 |
continue |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
242 |
label = display_name(self._cw, rschema.type, role) |
1739 | 243 |
vid = dispctrl.get('vid', 'sidebox') |
3975
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
244 |
sideboxes.append( (label, rset, vid, dispctrl) ) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
245 |
sideboxes += self._cw.vreg['boxes'].poss_visible_objects( |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
246 |
self._cw, rset=self.cw_rset, row=self.cw_row, view=self, |
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
|
247 |
context='incontext') |
3975
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
248 |
# XXX since we've two sorted list, it may be worth using bisect |
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
249 |
def get_order(x): |
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
250 |
if isinstance(x, tuple): |
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
251 |
# x is a view box (label, rset, vid, dispctrl) |
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
252 |
# default to 1000 so view boxes occurs after component boxes |
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
253 |
return x[-1].get('order', 1000) |
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
254 |
# x is a component box |
4073
03681ba6da0b
cw 3.6 api update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
4004
diff
changeset
|
255 |
return x.cw_propval('order') |
3975
569771016abb
add a fourth item to 'view box' defintion, dispctrl, so that
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3974
diff
changeset
|
256 |
return sorted(sideboxes, key=get_order) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
257 |
|
1739 | 258 |
def _section_def(self, entity, where): |
259 |
rdefs = [] |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
260 |
eschema = entity.e_schema |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
261 |
for rschema, tschemas, role in eschema.relation_definitions(True): |
5065
01d85f3a3d9e
[primary view] skip virtual rtypes anyway
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4742
diff
changeset
|
262 |
if rschema in VIRTUAL_RTYPES: |
01d85f3a3d9e
[primary view] skip virtual rtypes anyway
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4742
diff
changeset
|
263 |
continue |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
264 |
matchtschemas = [] |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
265 |
for tschema in tschemas: |
1739 | 266 |
section = self.rsection.etype_get(eschema, rschema, role, |
267 |
tschema) |
|
268 |
if section == where: |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
269 |
matchtschemas.append(tschema) |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
270 |
if matchtschemas: |
6234
ae97a8c818e5
[primary view] don't need to pick arbitrary target, this is properly handled by the rtag
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6113
diff
changeset
|
271 |
dispctrl = self.display_ctrl.etype_get(eschema, rschema, role, '*') |
1739 | 272 |
rdefs.append( (rschema, matchtschemas, role, dispctrl) ) |
273 |
return sorted(rdefs, key=lambda x: x[-1]['order']) |
|
274 |
||
275 |
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
|
276 |
try: |
6291
f6cba3be6ba2
[primary view]Â we should not limit related rset, else if something else than autolimited view is used, some content will be missed without a 'view all' link
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6290
diff
changeset
|
277 |
rset = entity.related(rschema.type, role) |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
278 |
except Unauthorized: |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
279 |
return |
1739 | 280 |
if 'filter' in dispctrl: |
281 |
rset = dispctrl['filter'](rset) |
|
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
282 |
return rset |
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1516
diff
changeset
|
283 |
|
6090
887c069d88df
[primary] backport _rel_label method from the default branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6086
diff
changeset
|
284 |
def _rel_label(self, entity, rschema, role, dispctrl): |
887c069d88df
[primary] backport _rel_label method from the default branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6086
diff
changeset
|
285 |
if rschema.final: |
887c069d88df
[primary] backport _rel_label method from the default branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6086
diff
changeset
|
286 |
showlabel = dispctrl.get('showlabel', self.show_attr_label) |
887c069d88df
[primary] backport _rel_label method from the default branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6086
diff
changeset
|
287 |
else: |
887c069d88df
[primary] backport _rel_label method from the default branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6086
diff
changeset
|
288 |
showlabel = dispctrl.get('showlabel', self.show_rel_label) |
887c069d88df
[primary] backport _rel_label method from the default branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6086
diff
changeset
|
289 |
if showlabel: |
887c069d88df
[primary] backport _rel_label method from the default branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6086
diff
changeset
|
290 |
if dispctrl.get('label'): |
887c069d88df
[primary] backport _rel_label method from the default branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6086
diff
changeset
|
291 |
label = self._cw._(dispctrl['label']) |
887c069d88df
[primary] backport _rel_label method from the default branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6086
diff
changeset
|
292 |
else: |
887c069d88df
[primary] backport _rel_label method from the default branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6086
diff
changeset
|
293 |
label = display_name(self._cw, rschema.type, role, |
887c069d88df
[primary] backport _rel_label method from the default branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6086
diff
changeset
|
294 |
context=entity.__regid__) |
887c069d88df
[primary] backport _rel_label method from the default branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6086
diff
changeset
|
295 |
return label |
887c069d88df
[primary] backport _rel_label method from the default branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6086
diff
changeset
|
296 |
return u'' |
1516
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
297 |
|
6093
9001a74fcc82
more generic dot graph generator
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
6090
diff
changeset
|
298 |
|
1516
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
299 |
class RelatedView(EntityView): |
6283
c827fa795a6b
[reledit] more api cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6255
diff
changeset
|
300 |
"""Display a rset, usually containing entities linked to another entity |
c827fa795a6b
[reledit] more api cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6255
diff
changeset
|
301 |
being displayed. |
c827fa795a6b
[reledit] more api cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6255
diff
changeset
|
302 |
|
c827fa795a6b
[reledit] more api cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6255
diff
changeset
|
303 |
It will try to display nicely according to the number of items in the result |
c827fa795a6b
[reledit] more api cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6255
diff
changeset
|
304 |
set. |
c827fa795a6b
[reledit] more api cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6255
diff
changeset
|
305 |
""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3072
diff
changeset
|
306 |
__regid__ = 'autolimited' |
3681
cdbe4aac1198
fix max-related of related entities handling in primary view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3071
diff
changeset
|
307 |
|
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
|
308 |
def call(self, **kwargs): |
4072
ead446e70c28
some api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4004
diff
changeset
|
309 |
if 'dispctrl' in self.cw_extra_kwargs: |
6291
f6cba3be6ba2
[primary view]Â we should not limit related rset, else if something else than autolimited view is used, some content will be missed without a 'view all' link
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6290
diff
changeset
|
310 |
if 'limit' in self.cw_extra_kwargs['dispctrl']: |
f6cba3be6ba2
[primary view]Â we should not limit related rset, else if something else than autolimited view is used, some content will be missed without a 'view all' link
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6290
diff
changeset
|
311 |
limit = self.cw_extra_kwargs['dispctrl']['limit'] |
f6cba3be6ba2
[primary view]Â we should not limit related rset, else if something else than autolimited view is used, some content will be missed without a 'view all' link
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6290
diff
changeset
|
312 |
else: |
f6cba3be6ba2
[primary view]Â we should not limit related rset, else if something else than autolimited view is used, some content will be missed without a 'view all' link
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6290
diff
changeset
|
313 |
limit = self._cw.property_value('navigation.related-limit') |
6288
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
314 |
list_limit = self.cw_extra_kwargs['dispctrl'].get('use_list_limit', 5) |
5520
2d7f135846ee
[primary view] allow new 'subvid' parameter in primaryview_display_ctrl
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5519
diff
changeset
|
315 |
subvid = self.cw_extra_kwargs['dispctrl'].get('subvid', 'incontext') |
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
|
316 |
else: |
6288
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
317 |
limit = list_limit = None |
5520
2d7f135846ee
[primary view] allow new 'subvid' parameter in primaryview_display_ctrl
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5519
diff
changeset
|
318 |
subvid = 'incontext' |
3720 | 319 |
if limit is None or self.cw_rset.rowcount <= limit: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
320 |
if self.cw_rset.rowcount == 1: |
5520
2d7f135846ee
[primary view] allow new 'subvid' parameter in primaryview_display_ctrl
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5519
diff
changeset
|
321 |
self.wview(subvid, self.cw_rset, row=0) |
6288
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
322 |
elif list_limit is None or 1 < self.cw_rset.rowcount <= list_limit: |
5520
2d7f135846ee
[primary view] allow new 'subvid' parameter in primaryview_display_ctrl
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5519
diff
changeset
|
323 |
self.wview('csv', self.cw_rset, subvid=subvid) |
1516
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
324 |
else: |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
325 |
self.w(u'<div>') |
5520
2d7f135846ee
[primary view] allow new 'subvid' parameter in primaryview_display_ctrl
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5519
diff
changeset
|
326 |
self.wview('simplelist', self.cw_rset, subvid=subvid) |
1516
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
327 |
self.w(u'</div>') |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
328 |
# else show links to display related entities |
288d55a7c5e2
refactor side boxes handling of primary view
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
329 |
else: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
330 |
rql = self.cw_rset.printable_rql() |
3890
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
331 |
self.cw_rset.limit(limit) # remove extra entity |
6288
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
332 |
if list_limit is None: |
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
333 |
self.wview('csv', self.cw_rset, subvid=subvid) |
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
334 |
self.w(u'[<a href="%s">%s</a>]' % ( |
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
335 |
xml_escape(self._cw.build_url(rql=rql, vid=subvid)), |
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
336 |
self._cw._('see them all'))) |
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
337 |
else: |
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
338 |
self.w(u'<div>') |
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
339 |
self.wview('simplelist', self.cw_rset, subvid=subvid) |
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
340 |
self.w(u'[<a href="%s">%s</a>]' % ( |
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
341 |
xml_escape(self._cw.build_url(rql=rql, vid=subvid)), |
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
342 |
self._cw._('see them all'))) |
17cd9ae3d2d5
[primary view] introducing use_list_limit in pvdc fix reledit regression on the way (introducted a few changesets ago)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6283
diff
changeset
|
343 |
self.w(u'</div>') |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2402
diff
changeset
|
344 |
|
3971
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
345 |
|
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
346 |
class URLAttributeView(EntityView): |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
347 |
"""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
|
348 |
to display as clickable link |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
349 |
""" |
4004
c52619c738a5
api renaming update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3998
diff
changeset
|
350 |
__regid__ = 'urlattr' |
3971
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
351 |
__select__ = EntityView.__select__ & match_kwargs('rtype') |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
352 |
|
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
353 |
def cell_call(self, row, col, rtype, **kwargs): |
4232
d9d031d68be2
more 3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4104
diff
changeset
|
354 |
entity = self.cw_rset.get_entity(row, col) |
3971
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
355 |
url = entity.printable_value(rtype) |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
356 |
if url: |
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
357 |
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
|
358 |
|
6246
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
359 |
class AttributeView(EntityView): |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
360 |
"""use this view on an entity as an alternative to more sophisticated |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
361 |
views such as reledit. |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
362 |
|
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
363 |
Ex. usage: |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
364 |
|
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
365 |
uicfg.primaryview_display_ctrl.tag_attribute(('Foo', 'bar'), {'vid': 'attribute'}) |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
366 |
""" |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
367 |
__regid__ = 'attribute' |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
368 |
__select__ = EntityView.__select__ & match_kwargs('rtype') |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
369 |
|
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
370 |
def cell_call(self, row, col, rtype, **kwargs): |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
371 |
entity = self.cw_rset.get_entity(row, col) |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
372 |
if self._cw.vreg.schema.rschema(rtype).final: |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
373 |
self.w(entity.printable_value(rtype)) |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
374 |
else: |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
375 |
dispctrl = uicfg.primaryview_display_ctrl.etype_get( |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
376 |
entity.e_schema, rtype, kwargs['role'], '*') |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
377 |
rset = entity.related(rtype, role) |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
378 |
if rset: |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
379 |
self.wview('autolimited', rset, initargs={'dispctrl': dispctrl}) |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6235
diff
changeset
|
380 |
|
3971
7cfbc35dce7e
new generic urlattr view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3970
diff
changeset
|
381 |
|
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2402
diff
changeset
|
382 |
## default primary ui configuration ########################################### |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2402
diff
changeset
|
383 |
|
3875
c2bd7922cdaf
use shorter notation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3849
diff
changeset
|
384 |
_pvs = uicfg.primaryview_section |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2402
diff
changeset
|
385 |
for rtype in ('eid', 'creation_date', 'modification_date', 'cwuri', |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
386 |
'is', 'is_instance_of', 'identity', 'owned_by', 'created_by', |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5222
diff
changeset
|
387 |
'require_permission', 'see_also'): |
3875
c2bd7922cdaf
use shorter notation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3849
diff
changeset
|
388 |
_pvs.tag_subject_of(('*', rtype, '*'), 'hidden') |
c2bd7922cdaf
use shorter notation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3849
diff
changeset
|
389 |
_pvs.tag_object_of(('*', rtype, '*'), 'hidden') |