backoffice: add assigned functions to inspect view (#17072)

This commit is contained in:
Frédéric Péters 2017-12-17 14:28:12 +01:00
parent 996fe47892
commit 730ff3d694
3 changed files with 46 additions and 1 deletions

View File

@ -3377,6 +3377,30 @@ def test_inspect_page(pub, local_user):
assert 'form_user_f3' not in resp.body
assert 'form_user_f_' not in resp.body
# check functions
assert re.findall('Recipient.*foobar', resp.body)
role = Role(name='plop')
role.store()
formdata.workflow_roles = {'_receiver': role.id}
formdata.store()
resp = login(get_app(pub)).get('%sinspect' % formdata.get_url(backoffice=True), status=200)
assert re.findall('Recipient.*plop', resp.body)
workflow = Workflow.get_default_workflow()
workflow.id = None
workflow.roles.update({'_plop': 'New Function'})
workflow.store()
formdef.workflow_id = workflow.id
formdef.store()
resp = login(get_app(pub)).get('%sinspect' % formdata.get_url(backoffice=True), status=200)
assert re.findall('New Function.*unset', resp.body)
formdata.workflow_roles = {'_receiver': role.id, '_plop': '123'}
formdata.store()
resp = login(get_app(pub)).get('%sinspect' % formdata.get_url(backoffice=True), status=200)
assert re.findall('New Function.*(deleted)', resp.body)
def test_workflow_jump_previous(pub):
user = create_user(pub)
create_environment(pub)

View File

@ -56,7 +56,8 @@ from wcs.admin.settings import UserFieldsFormDef
from wcs.categories import Category
from wcs.formdata import FormData
from wcs.formdef import FormDef
from wcs.roles import logged_users_role
from wcs.roles import logged_users_role, Role
from wcs.workflows import get_role_translation
from .submission import FormFillPage
@ -2176,6 +2177,25 @@ class FormBackOfficeStatusPage(FormStatusPage):
r += htmltext(' <span class="type">(%r)</span>') % type(v)
r += htmltext('</div></li>')
# assigned functions
if self.formdef.workflow.roles:
workflow = self.formdef.workflow
r += htmltext('<li><h3>%s</h3></li>\n') % _('Functions')
for key, label in (workflow.roles or {}).items():
r += htmltext('<li><span class="label">%s</span>') % label
acting_role_id = get_role_translation(self.filled, key)
if acting_role_id:
try:
acting_role = Role.get(acting_role_id)
r += htmltext('<div class="value"><span>%s</span></div>') % acting_role.name
except KeyError:
r += htmltext('<div class="value"><span>%s (%s)</span></div>') % (
acting_role_id, _('(deleted)'))
else:
r += htmltext('<div class="value"><span class="unset">%s</span></div>') % _('unset')
r += htmltext('</li>\n')
# markers stack
if '_markers_stack' in (self.filled.workflow_data or {}):
r += htmltext('<li><h3>%s</h3></li>') % _('Markers Stack')
for marker in reversed(self.filled.workflow_data['_markers_stack']):

View File

@ -1523,6 +1523,7 @@ form div.page > div {
padding-left: 1ex;
}
ul.form-inspector li span.label,
ul.form-inspector li code {
padding: 0 1ex;
float: left;