0001-workflows-add-button-link-to-go-to-workflow-form-fie.patch
tests/admin_pages/test_workflow.py | ||
---|---|---|
3243 | 3243 |
resp.form['varname'] = 'myform' |
3244 | 3244 |
resp.form['condition$type'] = 'django' |
3245 | 3245 |
resp.form['condition$value_django'] = '42' |
3246 |
assert 'Edit Fields' not in resp.text |
|
3247 |
assert resp.form.fields['submit'][0]._value == 'Submit and go to fields edition' |
|
3246 | 3248 |
resp = resp.form.submit('submit') |
3247 | 3249 |
assert resp.location == 'http://example.net/backoffice/workflows/%s/status/%s/items/1/fields/' % ( |
3248 | 3250 |
wf.id, |
3249 | 3251 |
st.id, |
3250 | 3252 |
) |
3253 |
resp = resp.follow() |
|
3254 |
resp.form['label'] = 'Text field' |
|
3255 |
resp = resp.form.submit('submit') |
|
3251 | 3256 | |
3252 | 3257 |
wf = Workflow.get(wf.id) |
3253 | 3258 |
form = wf.possible_status[0].items[0] |
3254 | 3259 |
assert form.by == ['_submitter'] |
3255 | 3260 |
assert form.varname == 'myform' |
3256 | 3261 |
assert form.condition == {'type': 'django', 'value': '42'} |
3262 |
assert form.formdef.fields[0].label == 'Text field' |
|
3263 | ||
3264 |
resp = app.get('/backoffice/workflows/%s/status/%s/items/1/' % (wf.id, st.id)) |
|
3265 |
assert 'Edit Fields' in resp.text |
|
3266 |
resp = resp.click('Edit Fields') |
|
3267 | ||
3268 |
resp = app.get('/backoffice/workflows/%s/status/%s/items/1/' % (wf.id, st.id)) |
|
3269 |
assert resp.form.fields['submit'][0]._value == 'Submit' |
|
3270 |
resp = resp.form.submit('submit') |
|
3271 |
assert resp.location == 'http://example.net/backoffice/workflows/%s/status/%s/items/' % ( |
|
3272 |
wf.id, |
|
3273 |
st.id, |
|
3274 |
) |
|
3257 | 3275 | |
3258 | 3276 | |
3259 | 3277 |
def test_workflows_inspect_view(pub): |
wcs/admin/workflows.py | ||
---|---|---|
421 | 421 |
'name': self.parent.name, |
422 | 422 |
} |
423 | 423 |
) |
424 |
if hasattr(self.item, 'redirect_after_submit_url'):
|
|
424 |
if getattr(self.item, 'redirect_after_submit_url', None):
|
|
425 | 425 |
return redirect(self.item.redirect_after_submit_url) |
426 | 426 |
return redirect('..') |
427 | 427 |
wcs/wf/form.py | ||
---|---|---|
29 | 29 |
from wcs.workflows import EvolutionPart, RedisplayFormException, WorkflowStatusItem, register_item_class |
30 | 30 | |
31 | 31 |
from ..qommon import _ |
32 |
from ..qommon.form import SingleSelectWidget, VarnameWidget, WidgetList |
|
32 |
from ..qommon.form import HtmlWidget, SingleSelectWidget, VarnameWidget, WidgetList
|
|
33 | 33 | |
34 | 34 | |
35 | 35 |
class WorkflowFormEvolutionPart(EvolutionPart): |
... | ... | |
115 | 115 |
ok_in_global_action = False |
116 | 116 |
endpoint = False |
117 | 117 |
waitpoint = True |
118 |
redirect_after_submit_url = 'fields/' |
|
119 |
submit_button_label = _('Submit and go to fields edition') |
|
120 | 118 | |
121 | 119 |
by = [] |
122 | 120 |
formdef = None |
123 | 121 |
varname = None |
124 | 122 | |
123 |
@property |
|
124 |
def submit_button_label(self): |
|
125 |
# make submit button go to fields page when there are not yet any field. |
|
126 |
if self.formdef and self.formdef.fields: |
|
127 |
return _('Submit') |
|
128 |
return _('Submit and go to fields edition') |
|
129 | ||
130 |
@property |
|
131 |
def redirect_after_submit_url(self): |
|
132 |
if self.formdef and self.formdef.fields: |
|
133 |
return None |
|
134 |
return 'fields/' |
|
135 | ||
125 | 136 |
@classmethod |
126 | 137 |
def init(cls): |
127 | 138 |
if 'lookup_wf_form_file' not in FileDirectory._lookup_methods: |
... | ... | |
152 | 163 |
value=self.varname, |
153 | 164 |
hint=_('This is used as prefix for form fields variable names.'), |
154 | 165 |
) |
166 |
if not formdef and self.formdef and self.formdef.fields: |
|
167 |
# add link to go edit or view fields |
|
168 |
widget = HtmlWidget( |
|
169 |
'<p><a class="pk-button" href="fields/">%s</a></p>' |
|
170 |
% (_('View fields') if self.parent.parent.is_readonly() else _('Edit Fields')) |
|
171 |
) |
|
172 |
widget.tab = ('general', _('General')) |
|
173 |
form.widgets.append(widget) |
|
155 | 174 | |
156 | 175 |
def get_parameters(self): |
157 | 176 |
return ('by', 'varname', 'condition') |
158 |
- |