Projet

Général

Profil

0001-no-backoffice-info-texts-when-form-is-locked-11268.patch

Thomas Noël, 14 juin 2016 11:58

Télécharger (5,49 ko)

Voir les différences:

Subject: [PATCH] no backoffice info texts when form is locked (#11268)

 tests/test_backoffice_pages.py | 20 ++++++++++++++++++++
 wcs/forms/common.py            | 31 +++++++++++++++++--------------
 2 files changed, 37 insertions(+), 14 deletions(-)
tests/test_backoffice_pages.py
785 785
    assert '<p>Foo</p>' in resp.body
786 786
    assert '<p>Bar</p>' in resp.body
787 787

  
788
    # info text is not visible if form is locked
789
    second_user = pub.user_class(name='foobar')
790
    second_user.roles = Role.keys()
791
    second_user.store()
792
    account = PasswordAccount(id='foobar')
793
    account.set_password('foobar')
794
    account.user_id = second_user.id
795
    account.store()
796
    app2 = login(get_app(pub), username='foobar', password='foobar')
797
    resp = app2.get('/backoffice/management/form-title/%s/' % number31.id)
798
    assert 'Be warned this form is also being' in resp.body
799
    assert not 'backoffice-description' in resp.body
800
    assert not 'CLICK ME!' in resp.body
801
    assert not 'CLICK ME2!' in resp.body
802

  
788 803
    # remove info text from the status
789 804
    st1.backoffice_info_text = None
790 805
    workflow.store()
......
2188 2203

  
2189 2204
    resp = app.get('/backoffice/management/form-title/' + first_link)
2190 2205
    assert not 'Be warned this form is also being' in resp.body
2206
    assert 'button_commentable' in resp.body
2191 2207
    assert len(resp.forms) == 1
2192 2208
    resp = app2.get('/backoffice/management/form-title/' + first_link)
2193 2209
    assert 'Be warned this form is also being' in resp.body
2210
    assert not 'button_commentable' in resp.body
2194 2211
    assert len(resp.forms) == 0
2195 2212
    # revisit with first user, no change
2196 2213
    resp = app.get('/backoffice/management/form-title/' + first_link)
2197 2214
    assert not 'Be warned this form is also being' in resp.body
2215
    assert 'button_commentable' in resp.body
2198 2216
    # back to second
2199 2217
    resp = app2.get('/backoffice/management/form-title/' + first_link)
2200 2218
    assert 'Be warned this form is also being' in resp.body
2219
    assert not 'button_commentable' in resp.body
2201 2220
    resp = resp.click('(unlock actions)')
2202 2221
    resp = resp.follow()
2203 2222
    assert 'Be warned this form is also being' in resp.body
2223
    assert 'button_commentable' in resp.body
2204 2224
    assert not '(unlock actions)' in resp.body
2205 2225
    assert len(resp.forms) == 1
2206 2226

  
wcs/forms/common.py
548 548

  
549 549
        r += self.history()
550 550

  
551
        locked = False
551 552
        if form:
552 553
            all_visitors = get_publisher().get_object_visitors(object_key)
553 554
            visitors = [x for x in all_visitors if x[0] != get_session().user]
......
573 574
                    r += ' '
574 575
                    r += htmltext('</p>')
575 576
                    if not me_in_visitors:
577
                        locked = True
576 578
                        r += htmltext('<p class="action"><a href="?unlock">%s</a></p>'
577 579
                                ) % _('(unlock actions)')
578 580
                    r += htmltext('</div>')
......
580 582
                r += form.render()
581 583
                get_session().mark_visited_object(object_key)
582 584

  
583
        if (self.filled.get_status() and self.filled.get_status().backoffice_info_text) or (
584
                form and any((getattr(button, 'backoffice_info_text', None)
585
                             for button in form.get_submit_widgets()))):
586
            r += htmltext('<div class="backoffice-description bo-block">')
587
            if self.filled.get_status().backoffice_info_text:
588
                r += htmltext(self.filled.get_status().backoffice_info_text)
589
            if form:
590
                for button in form.get_submit_widgets():
591
                    if not getattr(button, 'backoffice_info_text', None):
592
                        continue
593
                    r += htmltext('<div class="action-info-text" data-button-name="%s">' % button.name)
594
                    r += htmltext(button.backoffice_info_text)
595
                    r += htmltext('</div>')
596
            r += htmltext('</div>')
585
        if not locked:
586
            if (self.filled.get_status() and self.filled.get_status().backoffice_info_text) or (
587
                    form and any((getattr(button, 'backoffice_info_text', None)
588
                                 for button in form.get_submit_widgets()))):
589
                r += htmltext('<div class="backoffice-description bo-block">')
590
                if self.filled.get_status().backoffice_info_text:
591
                    r += htmltext(self.filled.get_status().backoffice_info_text)
592
                if form:
593
                    for button in form.get_submit_widgets():
594
                        if not getattr(button, 'backoffice_info_text', None):
595
                            continue
596
                        r += htmltext('<div class="action-info-text" data-button-name="%s">' % button.name)
597
                        r += htmltext(button.backoffice_info_text)
598
                        r += htmltext('</div>')
599
                r += htmltext('</div>')
597 600

  
598 601
        r += htmltext('<a href="..">%s</a>') % _('Back to Listing')
599 602
        return r.getvalue()
600
-