no backoffice info texts when form is locked (#11268)

This commit is contained in:
Thomas NOËL 2016-06-13 19:03:56 +02:00
parent 7f9b638571
commit f582dd8405
2 changed files with 37 additions and 14 deletions

View File

@ -786,6 +786,21 @@ def test_backoffice_info_text(pub):
assert '<p>Foo</p>' in resp.body
assert '<p>Bar</p>' in resp.body
# info text is not visible if form is locked
second_user = pub.user_class(name='foobar')
second_user.roles = Role.keys()
second_user.store()
account = PasswordAccount(id='foobar')
account.set_password('foobar')
account.user_id = second_user.id
account.store()
app2 = login(get_app(pub), username='foobar', password='foobar')
resp = app2.get('/backoffice/management/form-title/%s/' % number31.id)
assert 'Be warned this form is also being' in resp.body
assert not 'backoffice-description' in resp.body
assert not 'CLICK ME!' in resp.body
assert not 'CLICK ME2!' in resp.body
# remove info text from the status
st1.backoffice_info_text = None
workflow.store()
@ -2189,19 +2204,24 @@ def test_backoffice_advisory_lock(pub):
resp = app.get('/backoffice/management/form-title/' + first_link)
assert not 'Be warned this form is also being' in resp.body
assert 'button_commentable' in resp.body
assert len(resp.forms) == 1
resp = app2.get('/backoffice/management/form-title/' + first_link)
assert 'Be warned this form is also being' in resp.body
assert not 'button_commentable' in resp.body
assert len(resp.forms) == 0
# revisit with first user, no change
resp = app.get('/backoffice/management/form-title/' + first_link)
assert not 'Be warned this form is also being' in resp.body
assert 'button_commentable' in resp.body
# back to second
resp = app2.get('/backoffice/management/form-title/' + first_link)
assert 'Be warned this form is also being' in resp.body
assert not 'button_commentable' in resp.body
resp = resp.click('(unlock actions)')
resp = resp.follow()
assert 'Be warned this form is also being' in resp.body
assert 'button_commentable' in resp.body
assert not '(unlock actions)' in resp.body
assert len(resp.forms) == 1

View File

@ -577,6 +577,7 @@ class FormStatusPage(Directory):
r += self.history()
locked = False
if form:
all_visitors = get_publisher().get_object_visitors(object_key)
visitors = [x for x in all_visitors if x[0] != get_session().user]
@ -602,6 +603,7 @@ class FormStatusPage(Directory):
r += ' '
r += htmltext('</p>')
if not me_in_visitors:
locked = True
r += htmltext('<p class="action"><a href="?unlock">%s</a></p>'
) % _('(unlock actions)')
r += htmltext('</div>')
@ -609,20 +611,21 @@ class FormStatusPage(Directory):
r += form.render()
get_session().mark_visited_object(object_key)
if (self.filled.get_status() and self.filled.get_status().backoffice_info_text) or (
form and any((getattr(button, 'backoffice_info_text', None)
for button in form.get_submit_widgets()))):
r += htmltext('<div class="backoffice-description bo-block">')
if self.filled.get_status().backoffice_info_text:
r += htmltext(self.filled.get_status().backoffice_info_text)
if form:
for button in form.get_submit_widgets():
if not getattr(button, 'backoffice_info_text', None):
continue
r += htmltext('<div class="action-info-text" data-button-name="%s">' % button.name)
r += htmltext(button.backoffice_info_text)
r += htmltext('</div>')
r += htmltext('</div>')
if not locked:
if (self.filled.get_status() and self.filled.get_status().backoffice_info_text) or (
form and any((getattr(button, 'backoffice_info_text', None)
for button in form.get_submit_widgets()))):
r += htmltext('<div class="backoffice-description bo-block">')
if self.filled.get_status().backoffice_info_text:
r += htmltext(self.filled.get_status().backoffice_info_text)
if form:
for button in form.get_submit_widgets():
if not getattr(button, 'backoffice_info_text', None):
continue
r += htmltext('<div class="action-info-text" data-button-name="%s">' % button.name)
r += htmltext(button.backoffice_info_text)
r += htmltext('</div>')
r += htmltext('</div>')
r += htmltext('<a href="..">%s</a>') % _('Back to Listing')
return r.getvalue()