snapshots: detail status action comments (#47367)

This commit is contained in:
Nicolas Roche 2020-10-16 19:37:12 +02:00
parent 7138f1456b
commit 94b74b29c3
2 changed files with 58 additions and 3 deletions

View File

@ -425,3 +425,46 @@ def test_form_snapshot_save(pub, formdef_with_history):
assert [x.attrib['class'] for x in resp.pyquery.find('ul.snapshots-list li')] == [
'new-day', 'collapsed', 'collapsed', 'collapsed', 'collapsed', 'has-label',
'collapsed', 'collapsed', 'collapsed', 'collapsed', 'collapsed', 'collapsed']
def test_snaphost_workflow_status_item_comments(pub):
create_superuser(pub)
create_role()
Workflow.wipe()
workflow = Workflow(name='test')
workflow.add_status(name='baz')
workflow.store()
app = login(get_app(pub))
resp = app.get('/backoffice/workflows/1/')
resp = resp.click('baz')
resp.forms[0]['action-interaction'] = 'Webservice'
resp = resp.forms[0].submit()
resp = resp.follow()
resp = resp.click('Edit', href='items/1/')
resp.form['url'] = 'http://example.org'
resp = resp.forms[0].submit('submit')
resp = resp.follow()
resp = resp.follow()
resp = resp.click('Edit', href='items/1/')
resp.form['label'] = 'foo'
resp = resp.forms[0].submit('submit')
resp = resp.follow()
resp = resp.follow()
resp = resp.click(href='items/1/delete')
resp = resp.form.submit('submit')
resp = app.get('/backoffice/workflows/%s/history/' % workflow.id)
comments = [x.text[18:x.text.find('\n')]
for x in resp.html.find('ul', {'class': 'snapshots-list'}).find_all('li')]
assert comments == [
'Deletion of action "Webservice (foo)" in status "baz"',
'Change in action "Webservice (foo)" in status "baz"',
'Change in action "Webservice" in status "baz"',
'New action "Webservice" in status "baz"',
'']

View File

@ -295,7 +295,11 @@ class WorkflowItemPage(Directory):
return r.getvalue()
else:
self.item.submit_admin_form(form)
self.workflow.store(comment=_('Change in action "%s"') % _(self.item.description))
self.workflow.store(
comment=_('Change in action "%(description)s" in status "%(status)s"') % {
'description': self.item.render_as_line(),
'status': self.parent.name,
})
return redirect('..')
def delete(self):
@ -314,7 +318,11 @@ class WorkflowItemPage(Directory):
return r.getvalue()
else:
del self.parent.items[self.parent.items.index(self.item)]
self.workflow.store(comment=_('Deletion of action "%s"') % _(self.item.description))
self.workflow.store(
comment=_('Deletion of action "%(description)s" in status "%(status)s"') % {
'description': self.item.render_as_line(),
'status': self.parent.name,
})
return redirect('../../')
def _q_lookup(self, component):
@ -571,7 +579,11 @@ class WorkflowStatusPage(Directory):
action_type = form.get_widget('action-%s' % category).parse()
if action_type:
self.status.append_item(action_type)
self.workflow.store(comment=_('New action'))
self.workflow.store(
comment=_('New action "%(description)s" in status "%(status)s"') % {
'description': self.status.items[-1].description,
'status': self.status.name,
})
return redirect('.')
get_session().message = ('error', _('Submitted form was not filled properly.'))