author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 28 Oct 2011 11:33:26 +0200 | |
changeset 8037 | a36bd56f33bb |
parent 7992 | 4ff9f25cb06e |
child 8050 | 0f3a54c37b05 |
permissions | -rw-r--r-- |
7411
238da9684f99
cleanup and update some copyright
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7403
diff
changeset
|
1 |
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4995
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:
4995
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:
4995
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:
4995
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:
4995
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:
4995
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:
4995
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:
4995
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:
4995
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:
4995
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:
4995
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:
4995
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:
4995
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:
4995
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:
4995
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
18 |
"""workflow views: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
19 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
20 |
* IWorkflowable views and forms |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
21 |
* workflow entities views (State, Transition, TrInfo) |
0 | 22 |
""" |
5737 | 23 |
|
0 | 24 |
__docformat__ = "restructuredtext en" |
1739 | 25 |
_ = unicode |
0 | 26 |
|
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
27 |
import os |
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6103
diff
changeset
|
28 |
from warnings import warn |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
29 |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2005
diff
changeset
|
30 |
from logilab.mtconverter import xml_escape |
6093
9001a74fcc82
more generic dot graph generator
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5877
diff
changeset
|
31 |
from logilab.common.graph import escape |
822 | 32 |
|
7403
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
33 |
from cubicweb import Unauthorized |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
34 |
from cubicweb.selectors import (has_related_entities, one_line_rset, |
3867
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
35 |
relation_possible, match_form_params, |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
36 |
score_entity, is_instance, adaptable) |
2438
576f4d51f826
[cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2381
diff
changeset
|
37 |
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
|
38 |
from cubicweb.schema import display_name |
3262
12ffb1e95771
uicfg tweaks for wf
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3228
diff
changeset
|
39 |
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
|
40 |
from cubicweb.web import formfields as ff, formwidgets as fwdgs |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
41 |
from cubicweb.web.views import TmpFileViewMixin |
7598
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
42 |
from cubicweb.web.views import forms, primary, ibreadcrumbs |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
43 |
from cubicweb.web.views.tabs import TabbedPrimaryView, PrimaryTab |
6093
9001a74fcc82
more generic dot graph generator
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5877
diff
changeset
|
44 |
from cubicweb.web.views.dotgraphview import DotGraphView, DotPropsHandler |
3306
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
45 |
|
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
|
46 |
_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
|
47 |
_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
|
48 |
_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
|
49 |
_pvs.tag_object_of(('*', 'transition_of', 'Workflow'), 'hidden') |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5224
diff
changeset
|
50 |
_pvs.tag_object_of(('*', 'wf_info_for', '*'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5224
diff
changeset
|
51 |
for rtype in ('in_state', 'by_transition', 'from_state', 'to_state'): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5224
diff
changeset
|
52 |
_pvs.tag_subject_of(('*', rtype, '*'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5224
diff
changeset
|
53 |
_pvs.tag_object_of(('*', rtype, '*'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5224
diff
changeset
|
54 |
_pvs.tag_object_of(('*', 'wf_info_for', '*'), 'hidden') |
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
|
55 |
|
3262
12ffb1e95771
uicfg tweaks for wf
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3228
diff
changeset
|
56 |
_abaa = uicfg.actionbox_appearsin_addmenu |
12ffb1e95771
uicfg tweaks for wf
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3228
diff
changeset
|
57 |
_abaa.tag_subject_of(('BaseTransition', 'condition', 'RQLExpression'), False) |
12ffb1e95771
uicfg tweaks for wf
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3228
diff
changeset
|
58 |
_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
|
59 |
_abaa.tag_object_of(('SubWorkflowExitPoint', 'destination_state', 'State'), |
12ffb1e95771
uicfg tweaks for wf
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3228
diff
changeset
|
60 |
False) |
4995
1817b87c7f67
[web] move workflow related uicfg stuff to the workflow module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4780
diff
changeset
|
61 |
_abaa.tag_subject_of(('*', 'wf_info_for', '*'), False) |
1817b87c7f67
[web] move workflow related uicfg stuff to the workflow module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4780
diff
changeset
|
62 |
_abaa.tag_object_of(('*', 'wf_info_for', '*'), False) |
1817b87c7f67
[web] move workflow related uicfg stuff to the workflow module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4780
diff
changeset
|
63 |
|
1817b87c7f67
[web] move workflow related uicfg stuff to the workflow module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4780
diff
changeset
|
64 |
_abaa.tag_object_of(('*', 'state_of', 'CWEType'), True) |
1817b87c7f67
[web] move workflow related uicfg stuff to the workflow module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4780
diff
changeset
|
65 |
_abaa.tag_object_of(('*', 'transition_of', 'CWEType'), True) |
1817b87c7f67
[web] move workflow related uicfg stuff to the workflow module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4780
diff
changeset
|
66 |
_abaa.tag_subject_of(('Transition', 'destination_state', '*'), True) |
1817b87c7f67
[web] move workflow related uicfg stuff to the workflow module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4780
diff
changeset
|
67 |
_abaa.tag_object_of(('*', 'allowed_transition', 'Transition'), True) |
1817b87c7f67
[web] move workflow related uicfg stuff to the workflow module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4780
diff
changeset
|
68 |
_abaa.tag_object_of(('*', 'destination_state', 'State'), True) |
1817b87c7f67
[web] move workflow related uicfg stuff to the workflow module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4780
diff
changeset
|
69 |
_abaa.tag_subject_of(('State', 'allowed_transition', '*'), True) |
3306
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
70 |
_abaa.tag_object_of(('State', 'state_of', 'Workflow'), True) |
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
71 |
_abaa.tag_object_of(('Transition', 'transition_of', 'Workflow'), True) |
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
72 |
_abaa.tag_object_of(('WorkflowTransition', 'transition_of', 'Workflow'), True) |
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
73 |
|
bf50dc056edd
[wf] uicfg tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3304
diff
changeset
|
74 |
_afs = uicfg.autoform_section |
7598
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
75 |
_affk = uicfg.autoform_field_kwargs |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
76 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
77 |
# IWorkflowable views ######################################################### |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
78 |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2726
diff
changeset
|
79 |
class ChangeStateForm(forms.CompositeEntityForm): |
6692
bbc3f7c9f8d9
[change state form] set domid to avoid data conflict with other (eg edition) form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6690
diff
changeset
|
80 |
# set dom id to ensure there is no conflict with edition form (see |
bbc3f7c9f8d9
[change state form] set domid to avoid data conflict with other (eg edition) form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6690
diff
changeset
|
81 |
# session_key() implementation) |
bbc3f7c9f8d9
[change state form] set domid to avoid data conflict with other (eg edition) form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6690
diff
changeset
|
82 |
__regid__ = domid = 'changestate' |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
83 |
|
1995
ec95eaa2b711
turn renderers into appobjects
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
84 |
form_renderer_id = 'base' # don't want EntityFormRenderer |
3805
ad0b38e1a4eb
[web ui] rename form buttons to ok/cancel where workflow change state
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3513
diff
changeset
|
85 |
form_buttons = [fwdgs.SubmitButton(), |
ad0b38e1a4eb
[web ui] rename form buttons to ok/cancel where workflow change state
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
3513
diff
changeset
|
86 |
fwdgs.Button(stdmsgs.BUTTON_CANCEL, cwaction='cancel')] |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
87 |
|
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
88 |
|
7403
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
89 |
class ChangeStateFormView(form.FormViewMixIn, EntityView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
90 |
__regid__ = 'statuschange' |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
91 |
title = _('status change') |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
92 |
__select__ = (one_line_rset() |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
93 |
& match_form_params('treid') |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
94 |
& adaptable('IWorkflowable')) |
0 | 95 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
96 |
def cell_call(self, row, col): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
97 |
entity = self.cw_rset.get_entity(row, col) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
98 |
transition = self._cw.entity_from_eid(self._cw.form['treid']) |
3920
366b30a6f9f6
refactor to ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3868
diff
changeset
|
99 |
form = self.get_form(entity, transition) |
3998
94cc7cad3d2d
backport stable into default
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
100 |
self.w(u'<h4>%s %s</h4>\n' % (self._cw._(transition.name), |
1305
395ef7f2b95b
cleanup, remove some unnecessary (sometime buggy) stuff
sylvain.thenault@logilab.fr
parents:
1304
diff
changeset
|
101 |
entity.view('oneline'))) |
4780
58432e8e7dde
fix a Depression Warning
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
4646
diff
changeset
|
102 |
msg = self._cw._('status will change from %(st1)s to %(st2)s') % { |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
103 |
'st1': entity.cw_adapt_to('IWorkflowable').printable_state, |
4646
322c3dd96dd5
[workflow] finish refactoring introduced by 021035b9a7ab for 'go back' transition:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4436
diff
changeset
|
104 |
'st2': self._cw._(transition.destination(entity).name)} |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
105 |
self.w(u'<p>%s</p>\n' % msg) |
6690
7d68948015ba
[forms] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6473
diff
changeset
|
106 |
form.render(w=self.w) |
3920
366b30a6f9f6
refactor to ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3868
diff
changeset
|
107 |
|
366b30a6f9f6
refactor to ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3868
diff
changeset
|
108 |
def redirectpath(self, entity): |
366b30a6f9f6
refactor to ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3868
diff
changeset
|
109 |
return entity.rest_path() |
366b30a6f9f6
refactor to ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3868
diff
changeset
|
110 |
|
366b30a6f9f6
refactor to ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3868
diff
changeset
|
111 |
def get_form(self, entity, transition, **kwargs): |
366b30a6f9f6
refactor to ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3868
diff
changeset
|
112 |
# XXX used to specify both rset/row/col and entity in case implements |
7411
238da9684f99
cleanup and update some copyright
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7403
diff
changeset
|
113 |
# selector (and not is_instance) is used on custom form |
3998
94cc7cad3d2d
backport stable into default
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
114 |
form = self._cw.vreg['forms'].select( |
94cc7cad3d2d
backport stable into default
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
115 |
'changestate', self._cw, entity=entity, transition=transition, |
3920
366b30a6f9f6
refactor to ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3868
diff
changeset
|
116 |
redirect_path=self.redirectpath(entity), **kwargs) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
117 |
trinfo = self._cw.vreg['etypes'].etype_class('TrInfo')(self._cw) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
118 |
trinfo.eid = self._cw.varmaker.next() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
119 |
subform = self._cw.vreg['forms'].select('edition', self._cw, entity=trinfo, |
4159
6b2b20c73d59
refactor form field value handling, to get a nicer api and an easier algorithm to get field's value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4090
diff
changeset
|
120 |
mainform=False) |
6b2b20c73d59
refactor form field value handling, to get a nicer api and an easier algorithm to get field's value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4090
diff
changeset
|
121 |
subform.field_by_name('wf_info_for', 'subject').value = entity.eid |
6b2b20c73d59
refactor form field value handling, to get a nicer api and an easier algorithm to get field's value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4090
diff
changeset
|
122 |
trfield = subform.field_by_name('by_transition', 'subject') |
6b2b20c73d59
refactor form field value handling, to get a nicer api and an easier algorithm to get field's value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4090
diff
changeset
|
123 |
trfield.widget = fwdgs.HiddenInput() |
6b2b20c73d59
refactor form field value handling, to get a nicer api and an easier algorithm to get field's value
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4090
diff
changeset
|
124 |
trfield.value = transition.eid |
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
|
125 |
form.add_subform(subform) |
3920
366b30a6f9f6
refactor to ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3868
diff
changeset
|
126 |
return form |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
127 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
128 |
|
2440
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
129 |
class WFHistoryView(EntityView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
130 |
__regid__ = 'wfhistory' |
3948
24a25b676671
make wfhistory non selectable for entities without record in its workflow history
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3920
diff
changeset
|
131 |
__select__ = relation_possible('wf_info_for', role='object') & \ |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
132 |
score_entity(lambda x: x.cw_adapt_to('IWorkflowable').workflow_history) |
3998
94cc7cad3d2d
backport stable into default
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
133 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
134 |
title = _('Workflow history') |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
135 |
|
6473
2b09a410ff8e
[wf history] avoid title duplication
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6456
diff
changeset
|
136 |
def cell_call(self, row, col, view=None, title=title): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
137 |
_ = self._cw._ |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
138 |
eid = self.cw_rset[row][col] |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
139 |
sel = 'Any FS,TS,WF,D' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
140 |
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
|
141 |
'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
|
142 |
'WF creation_date D' |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
143 |
if self._cw.vreg.schema.eschema('CWUser').has_perm(self._cw, 'read'): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
144 |
sel += ',U,C' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
145 |
rql += ', WF owned_by U?' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
146 |
headers = (_('from_state'), _('to_state'), _('comment'), _('date'), |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
147 |
_('CWUser')) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
148 |
else: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
149 |
sel += ',C' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
150 |
headers = (_('from_state'), _('to_state'), _('comment'), _('date')) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
151 |
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
|
152 |
try: |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4995
diff
changeset
|
153 |
rset = self._cw.execute(rql, {'x': eid}) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
154 |
except Unauthorized: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
155 |
return |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
156 |
if rset: |
6473
2b09a410ff8e
[wf history] avoid title duplication
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6456
diff
changeset
|
157 |
if title: |
7992
4ff9f25cb06e
[table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7988
diff
changeset
|
158 |
self.w(u'<h2>%s</h2>\n' % _(title)) |
4ff9f25cb06e
[table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7988
diff
changeset
|
159 |
self.wview('table', rset, headers=headers) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
160 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
161 |
|
6456
150246e77cda
[workflow] fix bw compat code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
162 |
class WFHistoryVComponent(component.EntityCtxComponent): |
2440
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
163 |
"""display the workflow history for entities supporting it""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
164 |
__regid__ = 'wfhistory' |
6456
150246e77cda
[workflow] fix bw compat code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
165 |
__select__ = component.EntityCtxComponent.__select__ & WFHistoryView.__select__ |
2440
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
166 |
context = 'navcontentbottom' |
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
167 |
title = _('Workflow history') |
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2438
diff
changeset
|
168 |
|
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6103
diff
changeset
|
169 |
def render_body(self, w): |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6103
diff
changeset
|
170 |
if hasattr(self, 'cell_call'): |
6456
150246e77cda
[workflow] fix bw compat code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
171 |
warn('[3.10] %s should now implement render_body instead of cell_call' |
150246e77cda
[workflow] fix bw compat code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
172 |
% self.__class__, DeprecationWarning) |
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6103
diff
changeset
|
173 |
self.w = w |
7879
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7598
diff
changeset
|
174 |
# pylint: disable=E1101 |
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6103
diff
changeset
|
175 |
self.cell_call(self.entity.cw_row, self.entity.cw_col) |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6103
diff
changeset
|
176 |
else: |
6473
2b09a410ff8e
[wf history] avoid title duplication
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6456
diff
changeset
|
177 |
self.entity.view('wfhistory', w=w, title=None) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
178 |
|
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
179 |
|
7403
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
180 |
class InContextWithStateView(EntityView): |
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
181 |
"""display incontext view for an entity as well as its current state""" |
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
182 |
__regid__ = 'incontext-state' |
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
183 |
__select__ = adaptable('IWorkflowable') |
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
184 |
def entity_call(self, entity): |
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
185 |
iwf = entity.cw_adapt_to('IWorkflowable') |
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
186 |
self.w(u'%s [%s]' % (entity.view('incontext'), iwf.printable_state)) |
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
187 |
|
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
188 |
|
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
189 |
# workflow actions ############################################################# |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
190 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
191 |
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
|
192 |
"""fill 'workflow' sub-menu of the actions box""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
193 |
__regid__ = 'workflow' |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
194 |
__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
|
195 |
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
|
196 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
197 |
submenu = _('workflow') |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
198 |
order = 10 |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
199 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
200 |
def fill_menu(self, box, menu): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
201 |
entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
202 |
menu.label = u'%s: %s' % (self._cw._('state'), |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
203 |
entity.cw_adapt_to('IWorkflowable').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
|
204 |
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
|
205 |
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
|
206 |
|
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
|
207 |
def actual_actions(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
208 |
entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
209 |
iworkflowable = entity.cw_adapt_to('IWorkflowable') |
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
|
210 |
hastr = False |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
211 |
for tr in iworkflowable.possible_transitions(): |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
212 |
url = entity.absolute_url(vid='statuschange', treid=tr.eid) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
213 |
yield self.build_action(self._cw._(tr.name), 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
|
214 |
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
|
215 |
# 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
|
216 |
if hastr: |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
217 |
wfurl = iworkflowable.current_workflow.absolute_url() |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
218 |
yield self.build_action(self._cw._('view workflow'), wfurl) |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
219 |
if iworkflowable.workflow_history: |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
220 |
wfurl = entity.absolute_url(vid='wfhistory') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
221 |
yield self.build_action(self._cw._('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
|
222 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
223 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3216
diff
changeset
|
224 |
# workflow entity types views ################################################## |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
225 |
|
3867
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
226 |
_pvs = uicfg.primaryview_section |
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
227 |
_pvs.tag_subject_of(('Workflow', 'initial_state', '*'), 'hidden') |
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
228 |
_pvs.tag_object_of(('*', 'state_of', 'Workflow'), 'hidden') |
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
229 |
_pvs.tag_object_of(('*', 'transition_of', 'Workflow'), 'hidden') |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
230 |
_pvs.tag_object_of(('*', 'default_workflow', 'Workflow'), 'hidden') |
3867
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
231 |
|
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
232 |
_abaa = uicfg.actionbox_appearsin_addmenu |
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
233 |
_abaa.tag_subject_of(('BaseTransition', 'condition', 'RQLExpression'), False) |
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
234 |
_abaa.tag_subject_of(('State', 'allowed_transition', 'BaseTransition'), False) |
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
235 |
_abaa.tag_object_of(('SubWorkflowExitPoint', 'destination_state', 'State'), |
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
236 |
False) |
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
237 |
_abaa.tag_object_of(('State', 'state_of', 'Workflow'), True) |
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
238 |
_abaa.tag_object_of(('BaseTransition', 'transition_of', 'Workflow'), False) |
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
239 |
_abaa.tag_object_of(('Transition', 'transition_of', 'Workflow'), True) |
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
240 |
_abaa.tag_object_of(('WorkflowTransition', 'transition_of', 'Workflow'), True) |
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
241 |
|
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
242 |
class WorkflowPrimaryView(TabbedPrimaryView): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
243 |
__select__ = is_instance('Workflow') |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
244 |
tabs = [ _('wf_tab_info'), _('wfgraph'),] |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
245 |
default_tab = 'wf_tab_info' |
3867
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
246 |
|
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
247 |
|
7403
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
248 |
class CellView(EntityView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
249 |
__regid__ = 'cell' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
250 |
__select__ = is_instance('TrInfo') |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
251 |
|
0 | 252 |
def cell_call(self, row, col, cellvid=None): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
253 |
self.w(self.cw_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
|
254 |
|
63f4f81e19f1
restore appropriate in State's incontext view, moved it into wfentities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
728
diff
changeset
|
255 |
|
7403
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
256 |
class StateInContextView(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
|
257 |
"""convenience trick, State's incontext view should not be clickable""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3369
diff
changeset
|
258 |
__regid__ = 'incontext' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
259 |
__select__ = is_instance('State') |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
260 |
|
795
63f4f81e19f1
restore appropriate in State's incontext view, moved it into wfentities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
728
diff
changeset
|
261 |
def cell_call(self, row, col): |
3460
e4843535db25
[api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
262 |
self.w(xml_escape(self._cw.view('textincontext', self.cw_rset, |
e4843535db25
[api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
263 |
row=row, col=col))) |
795
63f4f81e19f1
restore appropriate in State's incontext view, moved it into wfentities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
728
diff
changeset
|
264 |
|
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
265 |
class WorkflowTabTextView(PrimaryTab): |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
266 |
__regid__ = 'wf_tab_info' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
267 |
__select__ = PrimaryTab.__select__ & one_line_rset() & is_instance('Workflow') |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
268 |
|
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
269 |
def render_entity_attributes(self, entity): |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
270 |
_ = self._cw._ |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
271 |
self.w(u'<div>%s</div>' % (entity.printable_value('description'))) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
272 |
self.w(u'<span>%s%s</span>' % (_("workflow_of").capitalize(), _(" :"))) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
273 |
html = [] |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
274 |
for e in entity.workflow_of: |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
275 |
view = e.view('outofcontext') |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
276 |
if entity.eid == e.default_workflow[0].eid: |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
277 |
view += u' <span>[%s]</span>' % _('default_workflow') |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
278 |
html.append(view) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
279 |
self.w(', '.join(v for v in html)) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
280 |
self.w(u'<h2>%s</h2>' % _("Transition_plural")) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
281 |
rset = self._cw.execute( |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
282 |
'Any T,T,DS,T,TT ORDERBY TN WHERE T transition_of WF, WF eid %(x)s,' |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
283 |
'T type TT, T name TN, T destination_state DS?', {'x': entity.eid}) |
7992
4ff9f25cb06e
[table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7988
diff
changeset
|
284 |
self.wview('table', rset, 'null', |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
285 |
cellvids={ 1: 'trfromstates', 2: 'outofcontext', 3:'trsecurity',}, |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
286 |
headers = (_('Transition'), _('from_state'), |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
287 |
_('to_state'), _('permissions'), _('type') ), |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
288 |
) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
289 |
|
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
290 |
|
7403
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
291 |
class TransitionSecurityTextView(EntityView): |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
292 |
__regid__ = 'trsecurity' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
293 |
__select__ = is_instance('Transition') |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
294 |
|
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
295 |
def cell_call(self, row, col): |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
296 |
_ = self._cw._ |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
297 |
entity = self.cw_rset.get_entity(self.cw_row, self.cw_col) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
298 |
if entity.require_group: |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
299 |
self.w(u'<div>%s%s %s</div>' % |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
300 |
(_('groups'), _(" :"), |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
301 |
u', '.join((g.view('incontext') for g |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
302 |
in entity.require_group)))) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
303 |
if entity.condition: |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
304 |
self.w(u'<div>%s%s %s</div>' % |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
305 |
( _('conditions'), _(" :"), |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
306 |
u'<br/>'.join((e.dc_title() for e |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
307 |
in entity.condition)))) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
308 |
|
7403
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
309 |
class TransitionAllowedTextView(EntityView): |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
310 |
__regid__ = 'trfromstates' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
311 |
__select__ = is_instance('Transition') |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
312 |
|
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
313 |
def cell_call(self, row, col): |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
314 |
entity = self.cw_rset.get_entity(self.cw_row, self.cw_col) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
315 |
self.w(u', '.join((e.view('outofcontext') for e |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
316 |
in entity.reverse_allowed_transition))) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
317 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
318 |
|
3867
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
319 |
# workflow entity types edition ################################################ |
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
320 |
|
7598
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
321 |
def _wf_items_for_relation(req, wfeid, wfrelation, field): |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
322 |
wf = req.entity_from_eid(wfeid) |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
323 |
rschema = req.vreg.schema[field.name] |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
324 |
param = 'toeid' if field.role == 'subject' else 'fromeid' |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
325 |
return sorted((e.view('combobox'), e.eid) |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
326 |
for e in getattr(wf, 'reverse_%s' % wfrelation) |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
327 |
if rschema.has_perm(req, 'add', **{param: e.eid})) |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
328 |
|
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
329 |
# TrInfo |
4004
c52619c738a5
api renaming update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3998
diff
changeset
|
330 |
_afs.tag_subject_of(('TrInfo', 'to_state', '*'), 'main', 'hidden') |
c52619c738a5
api renaming update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3998
diff
changeset
|
331 |
_afs.tag_subject_of(('TrInfo', 'from_state', '*'), 'main', 'hidden') |
7598
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
332 |
_afs.tag_attribute(('TrInfo', 'tr_count'), 'main', 'hidden') |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
333 |
|
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
334 |
# BaseTransition |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
335 |
# XXX * allowed_transition BaseTransition |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
336 |
# XXX BaseTransition destination_state * |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
337 |
|
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
338 |
def transition_states_vocabulary(form, field): |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
339 |
entity = form.edited_entity |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
340 |
if not entity.has_eid(): |
7875
65e460690139
[form, entity]Â refactor '__linkto', now handled by the entity form, not the entity itself. Closes #1931543
Florent Cayré <florent.cayre@gmail.com>
parents:
7598
diff
changeset
|
341 |
eids = form.linked_to.get(('transition_of', 'subject')) |
7598
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
342 |
if not eids: |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
343 |
return [] |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
344 |
return _wf_items_for_relation(form._cw, eids[0], 'state_of', field) |
7988
d72a2881d53c
[forms] update code broken by linkto refactoring
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7894
diff
changeset
|
345 |
return field.relvoc_unrelated(form) |
3867
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
346 |
|
7598
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
347 |
_afs.tag_subject_of(('*', 'destination_state', '*'), 'main', 'attributes') |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
348 |
_affk.tag_subject_of(('*', 'destination_state', '*'), |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
349 |
{'choices': transition_states_vocabulary}) |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
350 |
_afs.tag_object_of(('*', 'allowed_transition', '*'), 'main', 'attributes') |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
351 |
_affk.tag_object_of(('*', 'allowed_transition', '*'), |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
352 |
{'choices': transition_states_vocabulary}) |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
353 |
|
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
354 |
# State |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
355 |
|
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
356 |
def state_transitions_vocabulary(form, field): |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
357 |
entity = form.edited_entity |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
358 |
if not entity.has_eid(): |
7875
65e460690139
[form, entity]Â refactor '__linkto', now handled by the entity form, not the entity itself. Closes #1931543
Florent Cayré <florent.cayre@gmail.com>
parents:
7598
diff
changeset
|
359 |
eids = form.linked_to.get(('state_of', 'subject')) |
7598
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
360 |
if eids: |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
361 |
return _wf_items_for_relation(form._cw, eids[0], 'transition_of', field) |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
362 |
return [] |
7988
d72a2881d53c
[forms] update code broken by linkto refactoring
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7894
diff
changeset
|
363 |
return field.relvoc_unrelated(form) |
7598
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
364 |
|
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
365 |
_afs.tag_subject_of(('State', 'allowed_transition', '*'), 'main', 'attributes') |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
366 |
_affk.tag_subject_of(('State', 'allowed_transition', '*'), |
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
367 |
{'choices': state_transitions_vocabulary}) |
3867
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
368 |
|
06ac8f00a99f
fix vocabulary for destination_state/allowed_transitions when creating state or transition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3805
diff
changeset
|
369 |
|
7598
781def950a85
[worklow forms] rewrite remaining pre 3.10 form code using uicfg
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7411
diff
changeset
|
370 |
# adaptaters ################################################################### |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
371 |
|
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
372 |
class WorkflowIBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
373 |
__select__ = is_instance('Workflow') |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
374 |
# XXX what if workflow of multiple types? |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
375 |
def parent_entity(self): |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
376 |
return self.entity.workflow_of and self.entity.workflow_of[0] or None |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
377 |
|
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
378 |
class WorkflowItemIBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
379 |
__select__ = is_instance('BaseTransition', 'State') |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
380 |
def parent_entity(self): |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
381 |
return self.entity.workflow |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
382 |
|
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
383 |
class TransitionItemIBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
384 |
__select__ = is_instance('SubWorkflowExitPoint') |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
385 |
def parent_entity(self): |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
386 |
return self.entity.reverse_subworkflow_exit[0] |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
387 |
|
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
388 |
class TrInfoIBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
389 |
__select__ = is_instance('TrInfo') |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
390 |
def parent_entity(self): |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
391 |
return self.entity.for_entity |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
392 |
|
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
393 |
|
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
|
394 |
# workflow images ############################################################## |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
395 |
|
6093
9001a74fcc82
more generic dot graph generator
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5877
diff
changeset
|
396 |
class WorkflowDotPropsHandler(DotPropsHandler): |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
397 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
398 |
def node_properties(self, stateortransition): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
399 |
"""return default DOT drawing options for a state or transition""" |
6093
9001a74fcc82
more generic dot graph generator
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5877
diff
changeset
|
400 |
props = super(WorkflowDotPropsHandler, self).node_properties(stateortransition) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
401 |
if hasattr(stateortransition, 'state_of'): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
402 |
props['shape'] = 'box' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
403 |
props['style'] = 'filled' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
404 |
if stateortransition.reverse_initial_state: |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
405 |
props['fillcolor'] = '#88CC88' |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
406 |
else: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
407 |
props['shape'] = 'ellipse' |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
408 |
descr = [] |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
409 |
tr = stateortransition |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
410 |
if descr: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
411 |
props['label'] += escape('\n'.join(descr)) |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
412 |
return props |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
413 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
414 |
|
6103 | 415 |
class WorkflowVisitor(object): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
416 |
def __init__(self, entity): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
417 |
self.entity = entity |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
418 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
419 |
def nodes(self): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
420 |
for state in self.entity.reverse_state_of: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
421 |
state.complete() |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
422 |
yield state.eid, state |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
423 |
for transition in self.entity.reverse_transition_of: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
424 |
transition.complete() |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
425 |
yield transition.eid, transition |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
426 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
427 |
def edges(self): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
428 |
for transition in self.entity.reverse_transition_of: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
429 |
for incomingstate in transition.reverse_allowed_transition: |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
430 |
yield incomingstate.eid, transition.eid, transition |
4646
322c3dd96dd5
[workflow] finish refactoring introduced by 021035b9a7ab for 'go back' transition:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4436
diff
changeset
|
431 |
for outgoingstate in transition.potential_destinations(): |
322c3dd96dd5
[workflow] finish refactoring introduced by 021035b9a7ab for 'go back' transition:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4436
diff
changeset
|
432 |
yield transition.eid, outgoingstate.eid, transition |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
433 |
|
6093
9001a74fcc82
more generic dot graph generator
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5877
diff
changeset
|
434 |
class WorkflowGraphView(DotGraphView): |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
435 |
__regid__ = 'wfgraph' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
436 |
__select__ = EntityView.__select__ & one_line_rset() & is_instance('Workflow') |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
437 |
|
6093
9001a74fcc82
more generic dot graph generator
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5877
diff
changeset
|
438 |
def build_visitor(self, entity): |
9001a74fcc82
more generic dot graph generator
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5877
diff
changeset
|
439 |
return WorkflowVisitor(entity) |
9001a74fcc82
more generic dot graph generator
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5877
diff
changeset
|
440 |
|
9001a74fcc82
more generic dot graph generator
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
5877
diff
changeset
|
441 |
def build_dotpropshandler(self): |
6103 | 442 |
return WorkflowDotPropsHandler(self._cw) |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
443 |
|
5682
5628247f51ce
[security] view was giving web access to every fs file accessible by the web server process. Fix this security hole by storing file in session data, not direct form parameters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
444 |
|
7403
344aa07dd0f2
[workflow] new 'incontext-state' view for IWorkflowable entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6763
diff
changeset
|
445 |
class TmpPngView(TmpFileViewMixin, EntityView): |
5682
5628247f51ce
[security] view was giving web access to every fs file accessible by the web server process. Fix this security hole by storing file in session data, not direct form parameters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
446 |
__regid__ = 'tmppng' |
5628247f51ce
[security] view was giving web access to every fs file accessible by the web server process. Fix this security hole by storing file in session data, not direct form parameters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
447 |
__select__ = match_form_params('tmpfile') |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
984
diff
changeset
|
448 |
content_type = 'image/png' |
5682
5628247f51ce
[security] view was giving web access to every fs file accessible by the web server process. Fix this security hole by storing file in session data, not direct form parameters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
449 |
binary = True |
1504
c6051f141807
register to catalog, delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
450 |
|
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
451 |
def cell_call(self, row=0, col=0): |
5682
5628247f51ce
[security] view was giving web access to every fs file accessible by the web server process. Fix this security hole by storing file in session data, not direct form parameters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
452 |
tmpfile = self._cw.session.data[self._cw.form['tmpfile']] |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5174
diff
changeset
|
453 |
self.w(open(tmpfile, 'rb').read()) |
5684
015755f67e46
[workflow image] remove debug code
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5682
diff
changeset
|
454 |
os.unlink(tmpfile) |