author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Tue, 20 Oct 2009 14:24:19 +0200 | |
branch | stable |
changeset 3748 | 7143198dd8a4 |
parent 3513 | c002f6488631 |
child 3524 | a3431f4e2f40 |
child 3805 | ad0b38e1a4eb |
permissions | -rw-r--r-- |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
1 |
"""workflow views: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
2 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
3 |
* IWorkflowable views and forms |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
4 |
* workflow entities views (State, Transition, TrInfo) |
0 | 5 |
|
6 |
:organization: Logilab |
|
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1739
diff
changeset
|
7 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 8 |
: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:
1739
diff
changeset
|
9 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 10 |
""" |
11 |
__docformat__ = "restructuredtext en" |
|
1739 | 12 |
_ = unicode |
0 | 13 |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2005
diff
changeset
|
14 |
from logilab.mtconverter import xml_escape |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
15 |
from logilab.common.graph import escape, GraphGenerator, DotBackend |
822 | 16 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
17 |
from cubicweb import Unauthorized, view |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
18 |
from cubicweb.selectors import (implements, has_related_entities, one_line_rset, |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
19 |
relation_possible, match_form_params) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
20 |
from cubicweb.interfaces import IWorkflowable |
2438
576f4d51f826
[cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2381
diff
changeset
|
21 |
from cubicweb.view import EntityView |
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
22 |
from cubicweb.schema import display_name |
3262
12ffb1e95771
uicfg tweaks for wf
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3228
diff
changeset
|
23 |
from cubicweb.web import uicfg, stdmsgs, action, component, form, action |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
24 |
from cubicweb.web import formfields as ff, formwidgets as fwdgs |
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
25 |
from cubicweb.web.views import TmpFileViewMixin, forms, primary |
1151
b20677336ee6
turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
26 |
|
3487
2e705d9fdaf1
[views] workflow primary view: do not show states and transitions in side boxes
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3350
diff
changeset
|
27 |
_pvs = uicfg.primaryview_section |
2e705d9fdaf1
[views] workflow primary view: do not show states and transitions in side boxes
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3350
diff
changeset
|
28 |
_pvs.tag_subject_of(('Workflow', 'initial_state', '*'), 'hidden') |
2e705d9fdaf1
[views] workflow primary view: do not show states and transitions in side boxes
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3350
diff
changeset
|
29 |
_pvs.tag_object_of(('*', 'state_of', 'Workflow'), 'hidden') |
2e705d9fdaf1
[views] workflow primary view: do not show states and transitions in side boxes
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3350
diff
changeset
|
30 |
_pvs.tag_object_of(('*', 'transition_of', 'Workflow'), 'hidden') |
2e705d9fdaf1
[views] workflow primary view: do not show states and transitions in side boxes
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3350
diff
changeset
|
31 |
|
3262
12ffb1e95771
uicfg tweaks for wf
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3228
diff
changeset
|
32 |
_abaa = uicfg.actionbox_appearsin_addmenu |
12ffb1e95771
uicfg tweaks for wf
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3228
diff
changeset
|
33 |
_abaa.tag_subject_of(('BaseTransition', 'condition', 'RQLExpression'), False) |
12ffb1e95771
uicfg tweaks for wf
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3228
diff
changeset
|
34 |
_abaa.tag_subject_of(('State', 'allowed_transition', 'BaseTransition'), False) |
12ffb1e95771
uicfg tweaks for wf
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3228
diff
changeset
|
35 |
_abaa.tag_object_of(('SubWorkflowExitPoint', 'destination_state', 'State'), |
12ffb1e95771
uicfg tweaks for wf
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3228
diff
changeset
|
36 |
False) |
3306
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
37 |
_abaa.tag_object_of(('State', 'state_of', 'Workflow'), True) |
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
38 |
_abaa.tag_object_of(('Transition', 'transition_of', 'Workflow'), True) |
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
39 |
_abaa.tag_object_of(('WorkflowTransition', 'transition_of', 'Workflow'), True) |
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
40 |
|
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
41 |
_afs = uicfg.autoform_section |
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
42 |
_afs.tag_subject_of(('TrInfo', 'to_state', '*'), 'generated') |
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
43 |
_afs.tag_subject_of(('TrInfo', 'from_state', '*'), 'generated') |
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
44 |
_afs.tag_object_of(('State', 'allowed_transition', '*'), 'primary') |
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
45 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
46 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
47 |
# IWorkflowable views ######################################################### |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
48 |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
49 |
class ChangeStateForm(forms.CompositeEntityForm): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
50 |
id = 'changestate' |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
51 |
|
1995
ec95eaa2b711
turn renderers into appobjects
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
52 |
form_renderer_id = 'base' # don't want EntityFormRenderer |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
53 |
form_buttons = [fwdgs.SubmitButton(stdmsgs.YES), |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
54 |
fwdgs.Button(stdmsgs.NO, cwaction='cancel')] |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
55 |
|
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
56 |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
57 |
class ChangeStateFormView(form.FormViewMixIn, view.EntityView): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
58 |
id = 'statuschange' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
59 |
title = _('status change') |
3335
3c035436ca65
statuschange form view only works w/ one entity, fix selector accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3307
diff
changeset
|
60 |
__select__ = (one_line_rset() & implements(IWorkflowable) |
3c035436ca65
statuschange form view only works w/ one entity, fix selector accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3307
diff
changeset
|
61 |
& match_form_params('treid')) |
0 | 62 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
63 |
def cell_call(self, row, col): |
3220
11b6016e3970
cleanup, futur warning fixes :)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3219
diff
changeset
|
64 |
entity = self.rset.get_entity(row, col) |
2680
66472d85d548
[R] use req.entity_from_eid
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2506
diff
changeset
|
65 |
transition = self.req.entity_from_eid(self.req.form['treid']) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
66 |
dest = transition.destination() |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
67 |
_ = self.req._ |
3339
d1d643ef37f7
fix argument given to changestate form selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3335
diff
changeset
|
68 |
# specify both rset/row/col and entity in case implements selector (and |
d1d643ef37f7
fix argument given to changestate form selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3335
diff
changeset
|
69 |
# not entity_implements) is used on custom form |
d1d643ef37f7
fix argument given to changestate form selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3335
diff
changeset
|
70 |
form = self.vreg['forms'].select( |
d1d643ef37f7
fix argument given to changestate form selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3335
diff
changeset
|
71 |
'changestate', self.req, rset=self.rset, row=row, col=col, |
3350
fa77640a9155
since we have the transition entity, give it directly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3339
diff
changeset
|
72 |
entity=entity, transition=transition, |
3339
d1d643ef37f7
fix argument given to changestate form selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3335
diff
changeset
|
73 |
redirect_path=self.redirectpath(entity)) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
74 |
self.w(form.error_message()) |
1305
395ef7f2b95b
cleanup, remove some unnecessary (sometime buggy) stuff
sylvain.thenault@logilab.fr
parents:
1304
diff
changeset
|
75 |
self.w(u'<h4>%s %s</h4>\n' % (_(transition.name), |
395ef7f2b95b
cleanup, remove some unnecessary (sometime buggy) stuff
sylvain.thenault@logilab.fr
parents:
1304
diff
changeset
|
76 |
entity.view('oneline'))) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
77 |
msg = _('status will change from %(st1)s to %(st2)s') % { |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
78 |
'st1': _(entity.current_state.name), |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
79 |
'st2': _(dest.name)} |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
80 |
self.w(u'<p>%s</p>\n' % msg) |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
81 |
trinfo = self.vreg['etypes'].etype_class('TrInfo')(self.req) |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
82 |
self.initialize_varmaker() |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
83 |
trinfo.eid = self.varmaker.next() |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
84 |
subform = self.vreg['forms'].select('edition', self.req, entity=trinfo, |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
85 |
mainform=False) |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
86 |
subform.field_by_name('by_transition').widget = fwdgs.HiddenInput() |
3513
c002f6488631
[form] replace is_subform by parent_form, carrying more information at the same cost
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3487
diff
changeset
|
87 |
form.add_subform(subform) |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
88 |
self.w(form.form_render(wf_info_for=entity.eid, |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
89 |
by_transition=transition.eid)) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
90 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
91 |
def redirectpath(self, entity): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
92 |
return entity.rest_path() |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
93 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
94 |
|
2440
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
95 |
class WFHistoryView(EntityView): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
96 |
id = 'wfhistory' |
2440
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
97 |
__select__ = relation_possible('wf_info_for', role='object') |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
98 |
title = _('Workflow history') |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
99 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
100 |
def cell_call(self, row, col, view=None): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
101 |
_ = self.req._ |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
102 |
eid = self.rset[row][col] |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
103 |
sel = 'Any FS,TS,WF,D' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
104 |
rql = ' ORDERBY D DESC WHERE WF wf_info_for X,'\ |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
105 |
'WF from_state FS, WF to_state TS, WF comment C,'\ |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
106 |
'WF creation_date D' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1318
diff
changeset
|
107 |
if self.vreg.schema.eschema('CWUser').has_perm(self.req, 'read'): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
108 |
sel += ',U,C' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
109 |
rql += ', WF owned_by U?' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
110 |
displaycols = range(5) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
111 |
headers = (_('from_state'), _('to_state'), _('comment'), _('date'), |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
112 |
_('CWUser')) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
113 |
else: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
114 |
sel += ',C' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
115 |
displaycols = range(4) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
116 |
headers = (_('from_state'), _('to_state'), _('comment'), _('date')) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
117 |
rql = '%s %s, X eid %%(x)s' % (sel, rql) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
118 |
try: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
119 |
rset = self.req.execute(rql, {'x': eid}, 'x') |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
120 |
except Unauthorized: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
121 |
return |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
122 |
if rset: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
123 |
self.wview('table', rset, title=_(self.title), displayactions=False, |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
124 |
displaycols=displaycols, headers=headers) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
125 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
126 |
|
2440
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
127 |
class WFHistoryVComponent(component.EntityVComponent): |
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
128 |
"""display the workflow history for entities supporting it""" |
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
129 |
id = 'wfhistory' |
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
130 |
__select__ = WFHistoryView.__select__ & component.EntityVComponent.__select__ |
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
131 |
context = 'navcontentbottom' |
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
132 |
title = _('Workflow history') |
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
133 |
|
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
134 |
def cell_call(self, row, col, view=None): |
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
135 |
self.wview('wfhistory', self.rset, row=row, col=col, view=view) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
136 |
|
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
137 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
138 |
# workflow actions ############################################################# |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
139 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
140 |
class WorkflowActions(action.Action): |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
141 |
"""fill 'workflow' sub-menu of the actions box""" |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
142 |
id = 'workflow' |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
143 |
__select__ = (action.Action.__select__ & one_line_rset() & |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
144 |
relation_possible('in_state')) |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
145 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
146 |
submenu = _('workflow') |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
147 |
order = 10 |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
148 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
149 |
def fill_menu(self, box, menu): |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
150 |
entity = self.rset.get_entity(self.row or 0, self.col or 0) |
3228
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3220
diff
changeset
|
151 |
menu.label = u'%s: %s' % (self.req._('state'), entity.printable_state) |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
152 |
menu.append_anyway = True |
3228
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3220
diff
changeset
|
153 |
super(WorkflowActions, self).fill_menu(box, menu) |
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3220
diff
changeset
|
154 |
|
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3220
diff
changeset
|
155 |
def actual_actions(self): |
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3220
diff
changeset
|
156 |
entity = self.rset.get_entity(self.row or 0, self.col or 0) |
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3220
diff
changeset
|
157 |
hastr = False |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
158 |
for tr in entity.possible_transitions(): |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
159 |
url = entity.absolute_url(vid='statuschange', treid=tr.eid) |
3228
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3220
diff
changeset
|
160 |
yield self.build_action(self.req._(tr.name), url) |
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3220
diff
changeset
|
161 |
hastr = True |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
162 |
# don't propose to see wf if user can't pass any transition |
3228
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3220
diff
changeset
|
163 |
if hastr: |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
164 |
wfurl = entity.current_workflow.absolute_url() |
3228
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3220
diff
changeset
|
165 |
yield self.build_action(self.req._('view workflow'), wfurl) |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
166 |
if entity.workflow_history: |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
167 |
wfurl = entity.absolute_url(vid='wfhistory') |
3228
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3220
diff
changeset
|
168 |
yield self.build_action(self.req._('view history'), wfurl) |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
169 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
170 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
171 |
# workflow entity types views ################################################## |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
172 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
173 |
class CellView(view.EntityView): |
0 | 174 |
id = 'cell' |
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
175 |
__select__ = implements('TrInfo') |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
176 |
|
0 | 177 |
def cell_call(self, row, col, cellvid=None): |
3220
11b6016e3970
cleanup, futur warning fixes :)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3219
diff
changeset
|
178 |
self.w(self.rset.get_entity(row, col).view('reledit', rtype='comment')) |
795
63f4f81e19f1
restore appropriate in State's incontext view, moved it into wfentities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
728
diff
changeset
|
179 |
|
63f4f81e19f1
restore appropriate in State's incontext view, moved it into wfentities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
728
diff
changeset
|
180 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
181 |
class StateInContextView(view.EntityView): |
795
63f4f81e19f1
restore appropriate in State's incontext view, moved it into wfentities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
728
diff
changeset
|
182 |
"""convenience trick, State's incontext view should not be clickable""" |
63f4f81e19f1
restore appropriate in State's incontext view, moved it into wfentities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
728
diff
changeset
|
183 |
id = 'incontext' |
63f4f81e19f1
restore appropriate in State's incontext view, moved it into wfentities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
728
diff
changeset
|
184 |
__select__ = implements('State') |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
185 |
|
795
63f4f81e19f1
restore appropriate in State's incontext view, moved it into wfentities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
728
diff
changeset
|
186 |
def cell_call(self, row, col): |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2005
diff
changeset
|
187 |
self.w(xml_escape(self.view('textincontext', self.rset, |
795
63f4f81e19f1
restore appropriate in State's incontext view, moved it into wfentities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
728
diff
changeset
|
188 |
row=row, col=col))) |
63f4f81e19f1
restore appropriate in State's incontext view, moved it into wfentities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
728
diff
changeset
|
189 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
190 |
|
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
191 |
class WorkflowPrimaryView(primary.PrimaryView): |
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
192 |
__select__ = implements('Workflow') |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
193 |
|
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
194 |
def render_entity_attributes(self, entity): |
3220
11b6016e3970
cleanup, futur warning fixes :)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3219
diff
changeset
|
195 |
self.w(entity.view('reledit', rtype='description')) |
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
196 |
self.w(u'<img src="%s" alt="%s"/>' % ( |
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
197 |
xml_escape(entity.absolute_url(vid='wfgraph')), |
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
198 |
xml_escape(self.req._('graphical workflow for %s') % entity.name))) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
199 |
|
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
200 |
|
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
201 |
# workflow images ############################################################## |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
202 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
203 |
class WorkflowDotPropsHandler(object): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
204 |
def __init__(self, req): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
205 |
self._ = req._ |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
206 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
207 |
def node_properties(self, stateortransition): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
208 |
"""return default DOT drawing options for a state or transition""" |
3304
2b18276b21ab
[ui] translate state/tr names in wf image
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3262
diff
changeset
|
209 |
props = {'label': stateortransition.printable_value('name'), |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
210 |
'fontname': 'Courier'} |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
211 |
if hasattr(stateortransition, 'state_of'): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
212 |
props['shape'] = 'box' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
213 |
props['style'] = 'filled' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
214 |
if stateortransition.reverse_initial_state: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
215 |
props['color'] = '#88CC88' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
216 |
else: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
217 |
props['shape'] = 'ellipse' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
218 |
descr = [] |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
219 |
tr = stateortransition |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
220 |
if tr.require_group: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
221 |
descr.append('%s %s'% ( |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
222 |
self._('groups:'), |
3307
d1230b89d887
[wf graph] translate group names as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3306
diff
changeset
|
223 |
','.join(g.printable_value('name') for g in tr.require_group))) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
224 |
if tr.condition: |
3216
4a006fce6023
[wf graph] fix display of condition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3215
diff
changeset
|
225 |
descr.append('%s %s'% ( |
4a006fce6023
[wf graph] fix display of condition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3215
diff
changeset
|
226 |
self._('condition:'), |
4a006fce6023
[wf graph] fix display of condition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3215
diff
changeset
|
227 |
' | '.join(e.expression for e in tr.condition))) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
228 |
if descr: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
229 |
props['label'] += escape('\n'.join(descr)) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
230 |
return props |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
231 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
232 |
def edge_properties(self, transition, fromstate, tostate): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
233 |
return {'label': '', 'dir': 'forward', |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
234 |
'color': 'black', 'style': 'filled'} |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
235 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
236 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
237 |
class WorkflowVisitor: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
238 |
def __init__(self, entity): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
239 |
self.entity = entity |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
240 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
241 |
def nodes(self): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
242 |
for state in self.entity.reverse_state_of: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
243 |
state.complete() |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
244 |
yield state.eid, state |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
245 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
246 |
for transition in self.entity.reverse_transition_of: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
247 |
transition.complete() |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
248 |
yield transition.eid, transition |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
249 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
250 |
def edges(self): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
251 |
for transition in self.entity.reverse_transition_of: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
252 |
for incomingstate in transition.reverse_allowed_transition: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
253 |
yield incomingstate.eid, transition.eid, transition |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
254 |
yield transition.eid, transition.destination().eid, transition |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
255 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
256 |
|
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
257 |
class WorkflowImageView(TmpFileViewMixin, view.EntityView): |
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
258 |
id = 'wfgraph' |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
259 |
content_type = 'image/png' |
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
260 |
__select__ = implements('Workflow') |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
261 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
262 |
def _generate(self, tmpfile): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
263 |
"""display schema information for an entity""" |
3220
11b6016e3970
cleanup, futur warning fixes :)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3219
diff
changeset
|
264 |
entity = self.rset.get_entity(self.row, self.col) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
265 |
visitor = WorkflowVisitor(entity) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
266 |
prophdlr = WorkflowDotPropsHandler(self.req) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
267 |
generator = GraphGenerator(DotBackend('workflow', 'LR', |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
268 |
ratio='compress', size='30,12')) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
269 |
return generator.generate(visitor, prophdlr, tmpfile) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
270 |