Projet

Général

Profil

0001-misc-always-hide-status-in-front-37517.patch

Frédéric Péters, 07 novembre 2019 14:45

Télécharger (3,21 ko)

Voir les différences:

Subject: [PATCH] misc: always hide status in front (#37517)

 tests/test_form_pages.py   | 20 ++++++++++----------
 wcs/qommon/http_request.py |  3 +++
 wcs/workflows.py           |  3 +++
 3 files changed, 16 insertions(+), 10 deletions(-)
tests/test_form_pages.py
3727 3727
    wf = Workflow(name='status')
3728 3728
    st0 = wf.add_status('Status0', 'st0')
3729 3729
    st1 = wf.add_status('Status1', 'st1')
3730
    st1.visibility = ['_receiver']
3731 3730
    export_to = ExportToModel()
3732 3731
    export_to.label = 'create doc'
3733 3732
    upload = QuixoteUpload('/foo/test.rtf', content_type='application/rtf')
......
3783 3782
    resp = resp.form.submit('button_export_to')
3784 3783
    resp = resp.follow()
3785 3784
    assert 'Form exported in a model' in resp.body
3786
    assert 'visibility-off' in resp.body
3787 3785

  
3788 3786
    resp = resp.form.submit('button_jump2')
3789 3787
    resp = resp.follow()
3790 3788

  
3789
    # limit visibility of status with document
3790
    st1.visibility = ['_receiver']
3791
    wf.store()
3791 3792

  
3792
    # change formdef receiver so the hidden status should not longer be visible
3793
    role2 = Role(name='yyy')
3794
    role2.store()
3795
    formdef.workflow_roles = {'_receiver': role2.id}
3796
    formdef.store()
3797

  
3798
    resp = login(get_app(pub), username='foo', password='foo').get(resp.request.url)
3793
    formdata = formdef.data_class().select()[0]
3794
    resp = login(get_app(pub), username='foo', password='foo').get(formdata.get_url())
3799 3795
    assert not 'Form exported in a model' in resp.body
3800
    assert 'visibility-off' not in resp.body
3796

  
3797
    # check status is visible in backoffice
3798
    resp = login(get_app(pub), username='foo', password='foo').get(formdata.get_url(backoffice=True))
3799
    assert 'visibility-off' in resp.body
3800
    assert 'Form exported in a model' in resp.body
3801 3801

  
3802 3802
def test_formdata_form_file_download(pub):
3803 3803
    create_user(pub)
wcs/qommon/http_request.py
175 175
    def is_in_backoffice(self):
176 176
        return self.get_path().startswith('/backoffice/')
177 177

  
178
    def is_api_url(self):
179
        return self.get_path().startswith('/api/')
180

  
178 181
    @property
179 182
    def META(self):
180 183
        return self.environ
wcs/workflows.py
1553 1553
    def is_visible(self, formdata, user):
1554 1554
        if not self.visibility: # no restriction -> visible
1555 1555
            return True
1556
        if get_request() and not get_request().is_in_backoffice() and not get_request().is_api_url():
1557
            # always hide in front
1558
            return False
1556 1559
        if user and user.is_admin:
1557 1560
            return True
1558 1561

  
1559
-