workflows: record error when user to assign cannot be found (#52068)
This commit is contained in:
parent
86a24e5987
commit
d5cf589068
|
@ -5911,10 +5911,16 @@ def test_create_carddata_user_association(two_pubs):
|
|||
formdata.data = {}
|
||||
formdata.user_id = user.id
|
||||
formdata.just_created()
|
||||
if two_pubs.loggederror_class:
|
||||
two_pubs.loggederror_class.wipe()
|
||||
formdata.perform_workflow()
|
||||
|
||||
assert carddef.data_class().count() == 1
|
||||
assert carddef.data_class().select()[0].user is None
|
||||
if two_pubs.loggederror_class:
|
||||
assert two_pubs.loggederror_class.count() == 1
|
||||
logged_error = two_pubs.loggederror_class.select()[0]
|
||||
assert logged_error.summary == 'Failed to attach user (not found: "zzz")'
|
||||
|
||||
# user association on invalid template
|
||||
carddef.data_class().wipe()
|
||||
|
|
|
@ -451,6 +451,12 @@ class CreateFormdataWorkflowStatusItem(WorkflowStatusItem):
|
|||
new_formdata.user = value
|
||||
else:
|
||||
new_formdata.user = get_publisher().user_class.lookup_by_string(value)
|
||||
if value and not new_formdata.user:
|
||||
get_publisher().record_error(
|
||||
_('Failed to attach user (not found: "%s")') % value,
|
||||
formdata=formdata,
|
||||
status_item=self,
|
||||
)
|
||||
|
||||
if self.keep_submission_context:
|
||||
new_formdata.submission_context = formdata.submission_context or {}
|
||||
|
|
Loading…
Reference in New Issue