backoffice: fix card creation in a popup & worflow trace (#74225)
gitea-wip/wcs/pipeline/pr-main This commit looks good Details

This commit is contained in:
Lauréline Guérin 2023-01-31 10:57:52 +01:00
parent 33edd5b837
commit b72d603053
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
3 changed files with 12 additions and 5 deletions

View File

@ -1160,6 +1160,13 @@ def test_carddata_add_related(pub):
assert resp.text.count('/backoffice/data/adult/add/?_popup=1') == 1
assert '/backoffice/data/child/add/?_popup=1' in resp
resp = app.get('/backoffice/data/child/add/?_popup=1')
resp.form['f1'] = 'foo'
resp.form['f2'] = 'bar'
resp = resp.form.submit('submit')
carddata = child.data_class().select()[0]
assert carddata.get_workflow_traces()
# user ha no creation rights on child
child.backoffice_submission_roles = None
child.store()

View File

@ -349,7 +349,7 @@ class CardFillPage(FormFillPage):
# redirect to cards index page if the user is not allowed to see the cards
return '%s/data/' % get_publisher().get_backoffice_url()
def redirect_after_submitted(self, form, filled):
def redirect_after_submitted(self, url, filled):
if get_request().form.get('_popup'):
popup_response_data = json.dumps(
{
@ -362,7 +362,7 @@ class CardFillPage(FormFillPage):
context={'popup_response_data': popup_response_data},
is_django_native=True,
)
return super().redirect_after_submitted(form, filled)
return super().redirect_after_submitted(url, filled)
def create_form(self, *args, **kwargs):
form = super().create_form(*args, **kwargs)

View File

@ -367,11 +367,11 @@ class FormFillPage(PublicFormFillPage):
self.set_tracking_code(filled)
get_session().remove_magictoken(get_request().form.get('magictoken'))
self.clean_submission_context()
return self.redirect_after_submitted(form, filled)
def redirect_after_submitted(self, form, filled):
filled.record_workflow_event('backoffice-created')
url = filled.perform_workflow()
return self.redirect_after_submitted(url, filled)
def redirect_after_submitted(self, url, filled):
if url:
pass # always redirect to an URL the workflow returned
elif not self.formdef.is_of_concern_for_user(self.user, filled):