1
0
Fork 0

FIX: clear submission if skipped by user

Dieser Commit ist enthalten in:
Faizaan Gagan 2021-08-10 14:31:59 +05:30
Ursprung f00d01c50f
Commit c1fc2fd0e4
2 geänderte Dateien mit 16 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -68,7 +68,7 @@ class CustomWizard::WizardController < ::ApplicationController
result.merge!(redirect_to: submission.redirect_to)
end
wizard.final_cleanup!
submission.remove if submission.present?
end
render json: result

Datei anzeigen

@ -97,6 +97,21 @@ class CustomWizard::Submission
new(wizard, data, user_id)
end
def self.remove(submission)
if submission.present?
user_id = submission.user.id
wizard_id = submission.wizard.id
submission_id = submission.id
data = PluginStore.get("#{wizard_id}_#{KEY}", user_id)
data.delete_if { |sub| sub["id"] == submission_id}
PluginStore.set("#{wizard_id}_#{KEY}", user_id, data)
end
end
def remove
self.class.remove(self)
end
def self.cleanup_incomplete_submissions(wizard)
user_id = wizard.user.id
all_submissions = list(wizard, user_id: user_id)