Projet

Général

Profil

0001-backoffice-include-action-details-in-tracing-inspect.patch

Frédéric Péters, 29 avril 2022 15:37

Télécharger (6,01 ko)

Voir les différences:

Subject: [PATCH] backoffice: include action details in tracing inspect section
 (#60689)

 tests/backoffice_pages/test_form_inspect.py   | 15 ++++++++++++
 wcs/backoffice/management.py                  |  9 ++++++--
 wcs/qommon/static/css/dc2/admin.scss          |  3 +++
 .../wcs/backoffice/formdata-inspect.html      |  6 +++++
 wcs/wf/sendmail.py                            |  4 ++++
 wcs/workflows.py                              | 23 +++++++++++++++++++
 6 files changed, 58 insertions(+), 2 deletions(-)
tests/backoffice_pages/test_form_inspect.py
692 692
    )
693 693
    assert action_links[-1] == 'http://example.net/backoffice/workflows/2/global-actions/1/items/1/'
694 694

  
695
    # check details are available
696
    assert 'Email (to Recipient)' in [
697
        x.text_content().split(' ', 2)[-1] for x in resp.pyquery('#inspect-timeline li')
698
    ]
699
    # and there's no crash when part of the workflow changes
700
    workflow.global_actions = []
701
    workflow.store()
702
    get_app(pub).get(formdata.get_url(backoffice=True) + 'inspect')
703
    workflow.possible_status[0].items = []
704
    workflow.store()
705
    get_app(pub).get(formdata.get_url(backoffice=True) + 'inspect')
706
    workflow.possible_status = []
707
    workflow.store()
708
    get_app(pub).get(formdata.get_url(backoffice=True) + 'inspect')
709

  
695 710

  
696 711
def test_inspect_page_missing_carddef_error(pub):
697 712
    create_user(pub, is_admin=True)
wcs/backoffice/management.py
3719 3719
                        except KeyError:
3720 3720
                            url = '#missing-%s' % action_id
3721 3721
                        r += htmltext(
3722
                            '<li><span class="datetime">%s</span> '
3723
                            '<a class="tracing-link" href="%s">%s</a></li>'
3722
                            '<li><span class="datetime">%s</span> ' '<a class="tracing-link" href="%s">%s</a>'
3724 3723
                        ) % (
3725 3724
                            action_ts.strftime('%Y-%m-%d %H:%M:%S.%f')[:-3],
3726 3725
                            url,
3727 3726
                            action_label,
3728 3727
                        )
3728
                        real_action = part.get_real_action(self.filled.formdef.workflow, wf_status, action_id)
3729
                        if real_action:
3730
                            details = real_action.get_inspect_details()
3731
                            if details:
3732
                                r += htmltext(' <span>(%s)</span>') % details
3733
                        r += htmltext('</li>')
3729 3734
        return r.getvalue()
3730 3735

  
3731 3736
    def inspect_markers_stack(self):
wcs/qommon/static/css/dc2/admin.scss
1699 1699
		background: white;
1700 1700
		padding: 1em;
1701 1701
		min-height: 200px;
1702
		.pk-attention {
1703
			margin-top: 0;
1704
		}
1702 1705
	}
1703 1706
}
1704 1707

  
wcs/templates/wcs/backoffice/formdata-inspect.html
56 56

  
57 57
{% if has_tracing %}
58 58
<div id="inspect-timeline" role="tabpanel" tabindex="0" aria-labelledby="tab-timeline" hidden>
59
<div class="pk-attention">
60
<p>{% blocktrans %}
61
Beware actions, links and details do not represent the workflow as it was
62
at the time it was run but as it is now. There can be inconsistencies.
63
{% endblocktrans %}</p>
64
</div>
59 65
<ul class="form-inspector biglist">
60 66
{{ view.inspect_tracing|safe }}
61 67
</ul>
wcs/wf/sendmail.py
118 118
        else:
119 119
            return _('not completed')
120 120

  
121
    def get_inspect_details(self):
122
        if self.to:
123
            return _('to %s') % self.render_list_of_roles_or_emails(self.to)
124

  
121 125
    def get_parameters(self):
122 126
        parameters = (
123 127
            'to',
wcs/workflows.py
426 426
        status = workflow.get_status(status_id)
427 427
        return status.get_admin_url()
428 428

  
429
    def get_real_action(self, workflow, status_id, action_id):
430
        if self.is_global_event():
431
            global_action_id = self.event_args[0]
432
            try:
433
                global_action = [x for x in workflow.global_actions if x.id == global_action_id][0]
434
            except IndexError:
435
                return None
436
            items = global_action.items
437
        else:
438
            try:
439
                status = workflow.get_status(status_id)
440
            except KeyError:
441
                return None
442
            items = status.items
443
        try:
444
            real_action = [x for x in items if x.id == action_id][0]
445
        except IndexError:
446
            real_action = None
447
        return real_action
448

  
429 449

  
430 450
class DuplicateGlobalActionNameError(Exception):
431 451
    pass
......
2233 2253
    def get_admin_url(self):
2234 2254
        return self.parent.get_admin_url() + 'items/%s/' % self.id
2235 2255

  
2256
    def get_inspect_details(self):
2257
        return getattr(self, 'label', '')
2258

  
2236 2259
    def render_list_of_roles(self, roles):
2237 2260
        return self.parent.parent.render_list_of_roles(roles)
2238 2261

  
2239
-