onaio/onadata

Create Entity only if submission is approved when form submission review is enabled

Closed this issue · 0 comments

Enhancement

When submission review is enabled, creating Entities from forms should only be successful if a submission is approved.

Benefits of implementing the feature/enhancement

Only approved submissions will create Entities when submission reviewed is enabled. This ensures no Entities are created from rejected submissions.

Suggested implementation plan(Steps to be taken to implement feature)

  1. Modify the post_save signal handler on Instance model that creates an Entity, to only create an Entity if submission review is not enabled for form. To determine that submission review is enabled for form, we check if a record exists in MetaData model whose data_type field has a value of submission_review and whose data_value field has a value of true.
  2. Add a post_save signal handler on SubmissionReview model, to create an Entity only if Entity for submission does not exist and the SubmissionReview's status field has a value of Approved.
  3. Alter MetaData model, add index for fields object_id, data_type.

Limitations

  1. Rejecting a previously approved submission will not delete the Entity that was created when the submission was approved.