0001-snapshots-detail-status-action-comments-47367.patch
tests/test_snapshots.py | ||
---|---|---|
385 | 385 |
for i in range(10, 15): |
386 | 386 |
formdef.description = 'this is a description (%s)' % i |
387 | 387 |
formdef.store() |
388 | 388 | |
389 | 389 |
resp = app.get('/backoffice/forms/%s/history/' % formdef_with_history.id) |
390 | 390 |
assert [x.attrib['class'] for x in resp.pyquery.find('ul.snapshots-list li')] == [ |
391 | 391 |
'new-day', 'collapsed', 'collapsed', 'collapsed', 'collapsed', 'has-label', |
392 | 392 |
'collapsed', 'collapsed', 'collapsed', 'collapsed', 'collapsed', 'collapsed'] |
393 | ||
394 | ||
395 |
def test_snaphost_workflow_status_item_comments(pub): |
|
396 |
create_superuser(pub) |
|
397 |
create_role() |
|
398 | ||
399 |
Workflow.wipe() |
|
400 |
workflow = Workflow(name='test') |
|
401 |
workflow.add_status(name='baz') |
|
402 |
workflow.store() |
|
403 | ||
404 |
app = login(get_app(pub)) |
|
405 |
resp = app.get('/backoffice/workflows/1/') |
|
406 |
resp = resp.click('baz') |
|
407 | ||
408 |
resp.forms[0]['action-interaction'] = 'Webservice' |
|
409 |
resp = resp.forms[0].submit() |
|
410 |
resp = resp.follow() |
|
411 | ||
412 |
resp = resp.click('Edit', href='items/1/') |
|
413 |
resp.form['url'] = 'http://example.org' |
|
414 |
resp = resp.forms[0].submit('submit') |
|
415 |
resp = resp.follow() |
|
416 |
resp = resp.follow() |
|
417 | ||
418 |
resp = resp.click('Edit', href='items/1/') |
|
419 |
resp.form['label'] = 'foo' |
|
420 |
resp = resp.forms[0].submit('submit') |
|
421 |
resp = resp.follow() |
|
422 |
resp = resp.follow() |
|
423 | ||
424 |
resp = resp.click(href='items/1/delete') |
|
425 |
resp = resp.form.submit('submit') |
|
426 | ||
427 |
resp = app.get('/backoffice/workflows/%s/history/' % workflow.id) |
|
428 |
comments = [x.text[18:x.text.find('\n')] |
|
429 |
for x in resp.html.find('ul', {'class': 'snapshots-list'}).find_all('li')] |
|
430 |
assert comments == [ |
|
431 |
'Deletion of action "Webservice (foo)" in status "baz"', |
|
432 |
'Change in action "Webservice (foo)" in status "baz"', |
|
433 |
'Change in action "Webservice" in status "baz"', |
|
434 |
'New action "Webservice" in status "baz"', |
|
435 |
''] |
wcs/admin/workflows.py | ||
---|---|---|
290 | 290 |
r = TemplateIO(html=True) |
291 | 291 |
r += htmltext('<h2>%s</h2>') % _(self.item.description) |
292 | 292 |
r += form.render() |
293 | 293 |
if self.item.support_substitution_variables: |
294 | 294 |
r += get_publisher().substitutions.get_substitution_html_table() |
295 | 295 |
return r.getvalue() |
296 | 296 |
else: |
297 | 297 |
self.item.submit_admin_form(form) |
298 |
self.workflow.store(comment=_('Change in action "%s"') % _(self.item.description)) |
|
298 |
self.workflow.store( |
|
299 |
comment=_('Change in action "%(description)s" in status "%(status)s"') % { |
|
300 |
'description': self.item.render_as_line(), |
|
301 |
'status': self.parent.name, |
|
302 |
}) |
|
299 | 303 |
return redirect('..') |
300 | 304 | |
301 | 305 |
def delete(self): |
302 | 306 |
form = Form(enctype='multipart/form-data') |
303 | 307 |
form.widgets.append(HtmlWidget('<p>%s</p>' % _('You are about to remove an item.'))) |
304 | 308 |
form.add_submit('delete', _('Delete')) |
305 | 309 |
form.add_submit('cancel', _('Cancel')) |
306 | 310 |
if form.get_widget('cancel').parse(): |
... | ... | |
309 | 313 |
get_response().breadcrumb.append(('delete', _('Delete'))) |
310 | 314 |
self.html_top(title = _('Delete Item')) |
311 | 315 |
r = TemplateIO(html=True) |
312 | 316 |
r += htmltext('<h2>%s</h2>') % _('Deleting Item') |
313 | 317 |
r += form.render() |
314 | 318 |
return r.getvalue() |
315 | 319 |
else: |
316 | 320 |
del self.parent.items[self.parent.items.index(self.item)] |
317 |
self.workflow.store(comment=_('Deletion of action "%s"') % _(self.item.description)) |
|
321 |
self.workflow.store( |
|
322 |
comment=_('Deletion of action "%(description)s" in status "%(status)s"') % { |
|
323 |
'description': self.item.render_as_line(), |
|
324 |
'status': self.parent.name, |
|
325 |
}) |
|
318 | 326 |
return redirect('../../') |
319 | 327 | |
320 | 328 |
def _q_lookup(self, component): |
321 | 329 |
t = self.item.q_admin_lookup(self.workflow, self.parent, component, |
322 | 330 |
self.html_top) |
323 | 331 |
if t: |
324 | 332 |
return t |
325 | 333 |
return Directory._q_lookup(self, component) |
... | ... | |
566 | 574 |
if not form.is_submitted() or form.has_errors(): |
567 | 575 |
get_session().message = ('error', _('Submitted form was not filled properly.')) |
568 | 576 |
return redirect('.') |
569 | 577 | |
570 | 578 |
for category in ('status-change', 'interaction', 'formdata-action', 'user-action'): |
571 | 579 |
action_type = form.get_widget('action-%s' % category).parse() |
572 | 580 |
if action_type: |
573 | 581 |
self.status.append_item(action_type) |
574 |
self.workflow.store(comment=_('New action')) |
|
582 |
self.workflow.store( |
|
583 |
comment=_('New action "%(description)s" in status "%(status)s"') % { |
|
584 |
'description': self.status.items[-1].description, |
|
585 |
'status': self.status.name, |
|
586 |
}) |
|
575 | 587 |
return redirect('.') |
576 | 588 | |
577 | 589 |
get_session().message = ('error', _('Submitted form was not filled properly.')) |
578 | 590 |
return redirect('.') |
579 | 591 | |
580 | 592 | |
581 | 593 |
def delete(self): |
582 | 594 |
form = Form(enctype="multipart/form-data") |
583 |
- |