Skip to content

Commit

Permalink
📝 [#3005] Document new task orchestration
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Nov 17, 2023
1 parent 51c5b91 commit 55d3d3c
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions docs/developers/backend/core/submissions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Globally, the various actions and plugin categories are processed in order:

#. If applicable, an :ref:`appointment <developers_appointment_plugins>` is
created. If this fails, the submission is blocked and the user sees an error
message and can try again.
message and can try again (note: this step is deprecated and not needed for the new appointment flow).
#. Pre-registration step. Each :ref:`registration plugin <developers_registration_plugins>` can perform
pre-registration task, like for example generating and setting a submission reference ID. If no registration backend
is configured, then an internal ID is generated and set on the submission.
Expand All @@ -40,5 +40,41 @@ Globally, the various actions and plugin categories are processed in order:

The confirmation email can show submission details, appointment details
(including links to cancel or change the appointment), payment details
(including a link to pay if not done so already) and custom information as part
(including a link to pay if not done so already), cosign details and custom information as part
of the form.

Under the hood
--------------

The steps described above are orchestrated by :meth:`openforms.submissions.tasks.on_post_submission_event`.
This method schedules the following tasks/chains:

- Task :meth:`openforms.submissions.tasks.user_uploads.cleanup_temporary_files_for`
- A chain with the following tasks:

- :meth:`openforms.appointments.tasks.maybe_register_appointment`
- :meth:`openforms.registrations.tasks.pre_registration`
- :meth:`openforms.submissions.tasks.pdf.generate_report_task`
- :meth:`openforms.registrations.tasks.registration`
- :meth:`openforms.payments.tasks.update_submission_payment_status`
- :meth:`openforms.submissions.tasks.finalise_completion` which schedules the following tasks (not in a chain):

- :meth:`openforms.submissions.tasks.schedule_emails`
- :meth:`openforms.submissions.tasks.cleanup.maybe_hash_identifying_attributes`

The IDs of the tasks scheduled in the chain are saved in a model
:class:`openforms.submissions.models.PostCompletionTasksIDs` which is linked (foreign key) to the submission.
With the task IDs, we can inspect the status of the tasks and communicate the status of the chain back to the frontend,
so that the confirmation page can be shown.

Method :meth:`openforms.submissions.tasks.on_post_submission_event` is not only called upon completing a submission, but
also when the following events happen:

- Payment is completed
- Submission is cosigned
- A retry flow is triggered (either because the registration failed or because the payment status update failed).

There is a possibility that the payment and the cosign happen at the same time. Since the task
:meth:`openforms.submissions.tasks.schedule_emails` is a Celery Once task, this should not lead to two confirmation
emails being sent at the same time. Since the content of the confirmation email is deduced by the state of the submission,
even in this edge case the email body should contain the correct information.

0 comments on commit 55d3d3c

Please sign in to comment.