Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_submission_changed_revision(sender, **kwargs):
if not issubclass(sender, SessionFormSubmission):
return
submission = kwargs['instance']
created = kwargs['created']
CoderedSubmissionRevision.create_from_submission(
submission, (CoderedSubmissionRevision.CREATED if created else CoderedSubmissionRevision.CHANGED)) # noqa
def create_submission_deleted_revision(sender, **kwargs):
if not issubclass(sender, CoderedSessionFormSubmission):
return
submission = kwargs['instance']
CoderedSubmissionRevision.create_from_submission(submission, SubmissionRevision.DELETED) # noqa
def create_normal_submission(self, delete_self=True):
submission_data = self.get_data()
if 'user' in submission_data:
submission_data['user'] = str(submission_data['user'])
submission = FormSubmission.objects.create(
form_data=json.dumps(submission_data, cls=StreamFormJSONEncoder),
page=self.page
)
if delete_self:
CoderedSubmissionRevision.objects.filter(submission_id=self.id).delete()
self.delete()
return submission