Projet

Général

Profil

0001-forms-display-messages-from-visible-status-55409.patch

Frédéric Péters, 05 juillet 2021 20:37

Télécharger (3,02 ko)

Voir les différences:

Subject: [PATCH] forms: display messages from visible status (#55409)

 tests/backoffice_pages/test_all.py |  2 +-
 tests/form_pages/test_all.py       | 12 ++++++++++++
 wcs/formdata.py                    |  4 ++--
 wcs/forms/common.py                |  2 +-
 4 files changed, 16 insertions(+), 4 deletions(-)
tests/backoffice_pages/test_all.py
5597 5597
    formdef.store()
5598 5598

  
5599 5599
    formdata = formdef.data_class().select()[0]
5600
    formdata.status = 'wf-st1'
5600
    formdata.jump_status('st1')
5601 5601
    formdata.store()
5602 5602

  
5603 5603
    app = login(get_app(pub))
tests/form_pages/test_all.py
4916 4916
    formdef.store()
4917 4917

  
4918 4918
    workflow = Workflow(name='test')
4919
    st0 = workflow.add_status('Status0', 'st0')
4920
    jump = JumpWorkflowStatusItem()
4921
    jump.status = 'st1'
4922
    st0.items.append(jump)
4923
    jump.parent = st0
4924

  
4919 4925
    st1 = workflow.add_status('Status1', 'st1')
4920 4926

  
4921 4927
    display1 = DisplayMessageWorkflowStatusItem()
......
5011 5017
    page = app.get(formdata.get_url())
5012 5018
    assert 'warningnotice' in page.text
5013 5019

  
5020
    # check message is not displayed if status is not visible to user
5021
    st1.visibility = ['_receiver']
5022
    workflow.store()
5023
    page = app.get(formdata.get_url())
5024
    assert 'warningnotice' not in page.text
5025

  
5014 5026

  
5015 5027
def test_workflow_condition_on_message(pub):
5016 5028
    create_user(pub)
wcs/formdata.py
535 535
            perform_items(action.items, self)
536 536
            break
537 537

  
538
    def get_workflow_messages(self, position='top'):
539
        wf_status = self.get_status()
538
    def get_workflow_messages(self, position='top', user=None):
539
        wf_status = self.get_visible_status(user=user)
540 540
        if not wf_status:
541 541
            return []
542 542
        messages = []
wcs/forms/common.py
183 183

  
184 184
    def workflow_messages(self, position='top'):
185 185
        if self.formdef.workflow:
186
            workflow_messages = self.filled.get_workflow_messages(position=position)
186
            workflow_messages = self.filled.get_workflow_messages(position=position, user=get_request().user)
187 187
            if workflow_messages:
188 188
                r = TemplateIO(html=True)
189 189
                if position == 'top':
190
-