diff --git a/tests/admin_pages/test_workflow.py b/tests/admin_pages/test_workflow.py index 031384bd0..0a0407658 100644 --- a/tests/admin_pages/test_workflow.py +++ b/tests/admin_pages/test_workflow.py @@ -1863,7 +1863,7 @@ def test_workflows_global_actions_external_workflow_action(pub): resp = resp.forms[0].submit('submit') resp.forms[0]['trigger_id'] = 'action:%s' % trigger.identifier resp = resp.forms[0].submit('submit').follow().follow() - assert 'External workflow (action "Global action" on external)' in resp.text + assert 'External workflow (action "Global action" on external)' in resp.text assert Workflow.get(workflow.id).possible_status[0].items[0].target_mode == 'all' assert Workflow.get(workflow.id).possible_status[0].items[0].target_id is None diff --git a/wcs/admin/workflows.py b/wcs/admin/workflows.py index 94cd0847a..74331b4cc 100644 --- a/wcs/admin/workflows.py +++ b/wcs/admin/workflows.py @@ -514,6 +514,7 @@ class WorkflowStatusPage(Directory): ('schema.svg', 'svg'), 'svg', ] + do_not_call_in_templates = True def __init__(self, workflow, status_id, html_top): self.html_top = html_top @@ -528,82 +529,36 @@ class WorkflowStatusPage(Directory): def _q_index(self): self.html_top('%s - %s' % (_('Workflow'), self.workflow.name)) - r = TemplateIO(html=True) get_response().add_javascript( - ['jquery.js', 'jquery-ui.js', 'biglist.js', 'svg-pan-zoom.js', 'qommon.wysiwyg.js'] + [ + 'jquery.js', + 'jquery-ui.js', + 'biglist.js', + 'svg-pan-zoom.js', + 'qommon.wysiwyg.js', + 'popup.js', + 'jquery.colourpicker.js', + ] + ) + return template.QommonTemplateResponse( + templates=['wcs/backoffice/workflow-status.html'], + context={'view': self, 'workflow': self.workflow, 'status': self.status, 'has_sidebar': True}, + is_django_native=True, ) - r += htmltext('

%s

') % self.status.name - r += get_session().display_message() - - if self.status.get_visibility_restricted_roles(): - r += htmltext('
') - r += _('This status is hidden from the user.') - if not self.workflow.is_readonly(): - r += ' ' - r += htmltext('(%s)') % _('change') - r += htmltext('
') - - if not self.status.items: - r += htmltext('
%s
') % _( - 'There are not yet any items in this status.' - ) - else: - r += htmltext('
') - if self.workflow.is_readonly(): - r += htmltext('
') # bo-block - - source_status = [] + def get_source_statuses(self): + statuses = [] for status in self.workflow.possible_status: if status is self.status: continue for item in status.items: if self.status in item.get_target_status(): - source_status.append(status) + statuses.append(status) break + return statuses - if source_status: - r += htmltext('
') - r += htmltext('

%s

') % _('Jumps') - r += htmltext('

%s ') % _('This status is reachable from the following status:') - r += htmltext(', ').join( - [htmltext('%s') % (x.id, x.name) for x in source_status] - ) - r += htmltext('.

') - r += htmltext('
') - - r += htmltext('

%s

') % _('Back to workflow main page') - - r += htmltext('
') - r += htmltext( - graphviz(self.workflow, url_prefix='../../', include=True, select='%s' % self.status.id) - ) - r += htmltext('') % _('Full Screen') - r += htmltext('
') - - get_response().filter['sidebar'] = self.get_sidebar() - - return r.getvalue() + def graphviz(self): + return graphviz(self.workflow, url_prefix='../../', include=True, select='%s' % self.status.id) def svg(self): response = get_response() @@ -614,34 +569,6 @@ class WorkflowStatusPage(Directory): self.workflow, url_prefix='../../', include=False, select='%s' % self.status.id ).replace('?>', '?>\n\n' % css) - def get_sidebar(self): - get_response().add_javascript(['popup.js', 'jquery.colourpicker.js']) - r = TemplateIO(html=True) - if self.workflow.is_default(): - r += htmltext('

') - r += _( - '''This is the default workflow, you cannot edit it but you can - duplicate it to base your own workflow on it.''' - ) - r += htmltext('

') - elif self.workflow.is_readonly(): - r += htmltext('

%s

') % _('This workflow is readonly.') - else: - r += htmltext('') - r += htmltext('
') - r += htmltext('

%s

') % _('New Action') - r += self.get_new_item_form().render() - r += htmltext('
') - return r.getvalue() - def is_item_available(self, item): return item.is_available(workflow=self.workflow) diff --git a/wcs/templates/wcs/backoffice/workflow-status.html b/wcs/templates/wcs/backoffice/workflow-status.html new file mode 100644 index 000000000..78de3b758 --- /dev/null +++ b/wcs/templates/wcs/backoffice/workflow-status.html @@ -0,0 +1,93 @@ +{% extends "wcs/backoffice.html" %} +{% load i18n %} + +{% block appbar-title %}{{ status.name }}{% endblock %} + +{% block content %} +{{ block.super }} + +{% if status.get_visibility_restricted_roles %} +
+{% trans "This status is hidden from the user." %} +{% if not workflow.is_readonly %} +({% trans "change" %}) +{% endif %} +
+{% endif %} + +{% if not status.items %} +
+{% trans "There are not yet any items in this status." %} +
+{% else %} +{% spaceless %} +
+ {% if workflow.is_readonly %} +
+{% endspaceless %} +{% endif %} + +{% with source_statuses=view.get_source_statuses %} + {% if source_statuses %} +
+

{% trans "Jumps" %}

+

{% trans "This status is reachable from the following status:" %} + {% for source in source_statuses %} + {{ source.name }}{% if not forloop.last %}, {% endif %} + {% endfor %} +

+
+ {% endif %} +{% endwith %} + +

{% trans "Back to workflow main page" %}

+ +
+{{ view.graphviz|safe }} + +
+ +{% endblock %} + +{% block sidebar-content %} +{% if workflow.is_default %} +

+{% blocktrans %} +This is the default workflow, you cannot edit it but you can +duplicate it to base your own workflow on it. +{% endblocktrans %} +

+{% elif workflow.is_readonly %} +

{% trans "This workflow is readonly." %}

+{% else %} + +
+

{% trans "New Action" %}

+{{ view.get_new_item_form.render|safe }} +
+{% endif %} + +{% endblock %}