Projet

Général

Profil

0001-admin-detail-target-status-on-choice-action-39207.patch

Nicolas Roche, 13 août 2020 15:35

Télécharger (5,05 ko)

Voir les différences:

Subject: [PATCH] admin: detail target status on choice action (#39207)

 tests/test_admin_pages.py | 57 +++++++++++++++++++++++++++++++++++++++
 wcs/workflows.py          | 24 ++++++++++-------
 2 files changed, 72 insertions(+), 9 deletions(-)
tests/test_admin_pages.py
997 997

  
998 998
    resp = app.get('/backoffice/workflows/1/')
999 999
    resp = resp.click('baz')
1000 1000
    resp = resp.click(href='items/1/', index=0)
1001 1001
    assert 'foobar' not in [x[2] for x in resp.form['by$element0'].options]
1002 1002
    assert '_receiver' in [x[0] for x in resp.form['by$element0'].options]
1003 1003

  
1004 1004

  
1005
def test_workflows_edit_choice_action_line_details(pub):
1006
    create_superuser(pub)
1007
    create_role()
1008

  
1009
    Workflow.wipe()
1010
    wf = Workflow(name='foo')
1011
    st1 = wf.add_status('New')
1012
    st2 = wf.add_status('Resubmit')
1013

  
1014
    jump = ChoiceWorkflowStatusItem()
1015
    jump.id = '1'
1016
    jump.parent = st1
1017
    st1.items.append(jump)
1018
    wf.store()
1019

  
1020
    app = login(get_app(pub))
1021
    resp = app.get('/backoffice/workflows/%s/status/%s/' % (wf.id, st1.id))
1022
    assert resp.html.find('a', {'href': 'items/1/'}).text == 'Manual Jump (not completed)'
1023

  
1024
    jump.label = 'Resubmit'
1025
    wf.store()
1026
    resp = app.get('/backoffice/workflows/%s/status/%s/' % (wf.id, st1.id))
1027
    assert resp.html.find('a', {'href': 'items/1/'}).text == \
1028
        'Manual Jump ("Resubmit", to New)'
1029

  
1030
    jump.status = st2.id
1031
    wf.store()
1032
    resp = app.get('/backoffice/workflows/%s/status/%s/' % (wf.id, st1.id))
1033
    assert resp.html.find('a', {'href': 'items/1/'}).text == \
1034
        'Manual Jump ("Resubmit", to Resubmit)'
1035

  
1036
    jump.label = 'Resubmit'
1037
    wf.store()
1038
    resp = app.get('/backoffice/workflows/%s/status/%s/' % (wf.id, st1.id))
1039
    assert resp.html.find('a', {'href': 'items/1/'}).text == \
1040
        'Manual Jump ("Resubmit", to Resubmit)'
1041

  
1042
    jump.set_marker_on_status = True
1043
    wf.store()
1044
    resp = app.get('/backoffice/workflows/%s/status/%s/' % (wf.id, st1.id))
1045
    assert resp.html.find('a', {'href': 'items/1/'}).text == \
1046
        'Manual Jump ("Resubmit", to Resubmit (and set marker))'
1047

  
1048
    jump.set_marker_on_status = False
1049
    jump.by = ['_submitter']
1050
    wf.store()
1051
    resp = app.get('/backoffice/workflows/%s/status/%s/' % (wf.id, st1.id))
1052
    assert resp.html.find('a', {'href': 'items/1/'}).text == \
1053
        'Manual Jump ("Resubmit", to Resubmit, by User)'
1054

  
1055
    jump.set_marker_on_status = True
1056
    wf.store()
1057
    resp = app.get('/backoffice/workflows/%s/status/%s/' % (wf.id, st1.id))
1058
    assert resp.html.find('a', {'href': 'items/1/'}).text == \
1059
        'Manual Jump ("Resubmit", to Resubmit, by User (and set marker))'
1060

  
1061

  
1005 1062
def test_workflows_action_subpath(pub):
1006 1063
    create_superuser(pub)
1007 1064
    role = create_role()
1008 1065
    Workflow.wipe()
1009 1066
    workflow = Workflow(name='foo')
1010 1067
    baz_status = workflow.add_status(name='baz')
1011 1068
    display_message = DisplayMessageWorkflowStatusItem()
1012 1069
    display_message.parent = baz_status
wcs/workflows.py
2408 2408
            return expression['value']
2409 2409
        return _('computed label')
2410 2410

  
2411 2411
    def get_line_details(self):
2412 2412
        if self.label:
2413 2413
            more = ''
2414 2414
            if self.set_marker_on_status:
2415 2415
                more += ' ' + _('(and set marker)')
2416
            if self.status:
2417
                to_status = self.parent.parent.get_status(self.status)
2418
            else:
2419
                to_status = self.parent
2416 2420
            if self.by:
2417
                return  _('"%(label)s" by %(by)s%(more)s') % {
2418
                        'label' : self.get_label(),
2419
                        'by' : self.render_list_of_roles(self.by),
2420
                        'more': more
2421
                    }
2421
                return  _('"%(label)s", to %(to)s, by %(by)s%(more)s') % {
2422
                    'label' : self.get_label(),
2423
                    'to' : to_status.name,
2424
                    'by' : self.render_list_of_roles(self.by),
2425
                    'more': more
2426
                }
2422 2427
            else:
2423
                return _('"%(label)s"%(more)s') % {
2424
                        'label': self.get_label(),
2425
                        'more': more
2426
                    }
2428
                return  _('"%(label)s", to %(to)s%(more)s') % {
2429
                    'label' : self.get_label(),
2430
                    'to' : to_status.name,
2431
                    'more': more
2432
                }
2427 2433
        else:
2428 2434
            return _('not completed')
2429 2435

  
2430 2436
    def fill_form(self, form, formdata, user, **kwargs):
2431 2437
        label = self.compute(self.label)
2432 2438
        if not label:
2433 2439
            return
2434 2440
        widget = form.add_submit('button%s' % self.id, label)
2435
-