From 983f54cf886a3b301c0d7c1bb3acc4022f5fd162 Mon Sep 17 00:00:00 2001
From: Thomas NOEL
Date: Mon, 13 Jun 2016 19:03:56 +0200
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(-)
diff --git a/tests/test_backoffice_pages.py b/tests/test_backoffice_pages.py
index f650d5f..ffdb26d 100644
--- a/tests/test_backoffice_pages.py
+++ b/tests/test_backoffice_pages.py
@@ -785,6 +785,21 @@ def test_backoffice_info_text(pub):
assert 'Foo
' in resp.body
assert 'Bar
' 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()
@@ -2188,19 +2203,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
diff --git a/wcs/forms/common.py b/wcs/forms/common.py
index 6d8250d..f110004 100644
--- a/wcs/forms/common.py
+++ b/wcs/forms/common.py
@@ -548,6 +548,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]
@@ -573,6 +574,7 @@ class FormStatusPage(Directory):
r += ' '
r += htmltext('
')
if not me_in_visitors:
+ locked = True
r += htmltext('%s
'
) % _('(unlock actions)')
r += htmltext('')
@@ -580,20 +582,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('')
- 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('
' % button.name)
- r += htmltext(button.backoffice_info_text)
- r += htmltext('
')
- r += htmltext('
')
+ 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('')
+ 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('
' % button.name)
+ r += htmltext(button.backoffice_info_text)
+ r += htmltext('
')
+ r += htmltext('
')
r += htmltext('%s') % _('Back to Listing')
return r.getvalue()
--
2.8.1