0001-backoffice-reset-advisory-locks-after-actions-10277.patch
tests/test_backoffice_pages.py | ||
---|---|---|
1796 | 1796 |
assert not '(unlock actions)' in resp.body |
1797 | 1797 |
assert len(resp.forms) == 1 |
1798 | 1798 | |
1799 |
# submit action form |
|
1800 |
resp.form['comment'] = 'HELLO' |
|
1801 |
resp = resp.form.submit('button_commentable') |
|
1802 |
# locks are reset after an action |
|
1803 |
assert not 'advisory-lock' in app2.get('/backoffice/management/form-title/') |
|
1804 |
assert not 'advisory-lock' in app.get('/backoffice/management/form-title/') |
|
1805 |
# but as the current user is redirected to the form, a lock will be |
|
1806 |
# acquired (unless the user didn't have actions anymore, but it's not the |
|
1807 |
# case here) |
|
1808 |
resp = resp.follow() |
|
1809 |
assert not 'advisory-lock' in app2.get('/backoffice/management/form-title/') |
|
1810 |
assert 'advisory-lock' in app.get('/backoffice/management/form-title/') |
|
1811 | ||
1799 | 1812 |
def test_backoffice_resubmit(pub): |
1800 | 1813 |
user = create_user(pub) |
1801 | 1814 |
create_environment(pub) |
wcs/forms/common.py | ||
---|---|---|
466 | 466 | |
467 | 467 | |
468 | 468 |
def status(self): |
469 |
object_key = 'formdata-%s-%s' % (self.formdef.url_name, self.filled.id) |
|
470 | ||
469 | 471 |
if get_request().get_query() == 'unlock': |
470 | 472 |
# mark user as active visitor of the object, then redirect to self, |
471 | 473 |
# the unlocked form will appear. |
472 |
object_key = 'formdata-%s-%s' % (self.formdef.url_name, self.filled.id) |
|
473 | 474 |
get_session().mark_visited_object(object_key) |
474 | 475 |
return redirect('./#lock-notice') |
475 | 476 | |
... | ... | |
486 | 487 | |
487 | 488 |
if form and form.is_submitted() and not form.has_errors(): |
488 | 489 |
url = self.submit(form) |
490 |
get_session().unmark_visited_object(object_key) |
|
489 | 491 |
if url is None: |
490 | 492 |
url = get_request().get_frontoffice_url() |
491 | 493 |
response = get_response() |
... | ... | |
515 | 517 |
r += self.history() |
516 | 518 | |
517 | 519 |
if form: |
518 |
object_key = 'formdata-%s-%s' % (self.formdef.url_name, self.filled.id) |
|
519 | 520 |
all_visitors = get_publisher().get_object_visitors(object_key) |
520 | 521 |
visitors = [x for x in all_visitors if x[0] != get_session().user] |
521 | 522 |
me_in_visitors = bool(get_session().user in [x[0] for x in all_visitors]) |
wcs/sessions.py | ||
---|---|---|
108 | 108 |
visitors[session.user] = max(object_timestamp, visitors.get(session.user, 0)) |
109 | 109 |
return visitors.items() |
110 | 110 | |
111 |
def unmark_visited_object(self, object_key): |
|
112 |
# remove from current session |
|
113 |
if object_key in getattr(self, 'visiting_objects', {}): |
|
114 |
del self.visiting_objects[object_key] |
|
115 |
# and from others |
|
116 |
for session in self.__class__.select(): |
|
117 |
if session.id == self.id: |
|
118 |
continue |
|
119 |
visiting_objects = getattr(session, 'visiting_objects', None) |
|
120 |
if not visiting_objects: |
|
121 |
continue |
|
122 |
if object_key in visiting_objects: |
|
123 |
del session.visiting_objects[object_key] |
|
124 |
session.store() |
|
125 | ||
111 | 126 |
qommon.sessions.BasicSession = BasicSession |
112 | 127 |
StorageSessionManager = qommon.sessions.StorageSessionManager |
113 |
- |