Projet

Général

Profil

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

Frédéric Péters, 14 février 2022 09:58

Télécharger (4,74 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                | 10 +++++++-
 wcs/workflows.py                            | 27 +++++++++++++++++++++
 3 files changed, 51 insertions(+), 1 deletion(-)
tests/backoffice_pages/test_form_inspect.py
623 623
    )
624 624
    assert action_links[-1] == 'http://example.net/backoffice/workflows/2/global-actions/1/items/1/'
625 625

  
626
    # check details are available
627
    assert 'Email (to Recipient)' in [
628
        x.text_content().split(' ', 2)[-1] for x in resp.pyquery('#inspect-timeline li')
629
    ]
630
    # and there's no crash when part of the workflow changes
631
    workflow.global_actions = []
632
    workflow.store()
633
    get_app(pub).get(formdata.get_url(backoffice=True) + 'inspect')
634
    workflow.possible_status[0].items = []
635
    workflow.store()
636
    get_app(pub).get(formdata.get_url(backoffice=True) + 'inspect')
637
    workflow.possible_status = []
638
    workflow.store()
639
    get_app(pub).get(formdata.get_url(backoffice=True) + 'inspect')
640

  
626 641

  
627 642
def test_inspect_page_missing_carddef_error(pub):
628 643
    create_user(pub, is_admin=True)
wcs/backoffice/management.py
3387 3387
                                url = '#missing-%s' % action_id
3388 3388
                            r += htmltext(
3389 3389
                                '<li><span class="datetime">%s</span> '
3390
                                '<a class="tracing-link" href="%s">%s</a></li>'
3390
                                '<a class="tracing-link" href="%s">%s</a>'
3391 3391
                            ) % (
3392 3392
                                action_ts.strftime('%Y-%m-%d %H:%M:%S.%f')[:-3],
3393 3393
                                url,
3394 3394
                                action_label,
3395 3395
                            )
3396
                            real_action = part.get_real_action(
3397
                                self.filled.formdef.workflow, wf_status, action_id
3398
                            )
3399
                            if real_action:
3400
                                details = real_action.get_inspect_details()
3401
                                if details:
3402
                                    r += htmltext(' <span>(%s)</span>') % details
3403
                            r += htmltext('</li>')
3396 3404

  
3397 3405
            r += htmltext('</ul>')
3398 3406
            r += htmltext('</div>')
wcs/workflows.py
414 414
        status = workflow.get_status(status_id)
415 415
        return status.get_admin_url()
416 416

  
417
    def get_real_action(self, workflow, status_id, action_id):
418
        if self.is_global_event():
419
            global_action_id = self.event_args[0]
420
            try:
421
                global_action = [x for x in workflow.global_actions if x.id == global_action_id][0]
422
            except IndexError:
423
                return None
424
            items = global_action.items
425
        else:
426
            try:
427
                status = workflow.get_status(status_id)
428
            except KeyError:
429
                return None
430
            items = status.items
431
        try:
432
            real_action = [x for x in items if x.id == action_id][0]
433
        except IndexError:
434
            real_action = None
435
        return real_action
436

  
417 437

  
418 438
class DuplicateGlobalActionNameError(Exception):
419 439
    pass
......
2176 2196
    def get_line_details(self):
2177 2197
        return ''
2178 2198

  
2199
    def get_inspect_details(self):
2200
        return getattr(self, 'label', '')
2201

  
2179 2202
    def render_list_of_roles(self, roles):
2180 2203
        return self.parent.parent.render_list_of_roles(roles)
2181 2204

  
......
3136 3159
        else:
3137 3160
            return _('not completed')
3138 3161

  
3162
    def get_inspect_details(self):
3163
        if self.to:
3164
            return _('to %s') % self.render_list_of_roles_or_emails(self.to)
3165

  
3139 3166
    def get_parameters(self):
3140 3167
        parameters = ('to', 'mail_template', 'subject', 'body', 'attachments', 'custom_from', 'condition')
3141 3168
        if (
3142
-