Delete draft when submitting case study (#52)

This commit is contained in:
Anna Sidwell 2018-04-16 10:57:05 +10:00
parent 054668e1e8
commit a41df71793
2 changed files with 6 additions and 4 deletions

View File

@ -533,10 +533,6 @@ function initDrafts() {
button.switchStateSaveFailed(); button.switchStateSaveFailed();
}) })
}) })
document.forms['case-study-form'].addEventListener('submit', () => {
// XXX We're submitting, so kosh the saved data
})
} }
// https://github.com/snikch/jquery.dirtyforms // https://github.com/snikch/jquery.dirtyforms

View File

@ -54,6 +54,12 @@ class BaseForm(LoginRequiredMixin, CreateView):
def form_valid(self, form): def form_valid(self, form):
self.object = form.save() self.object = form.save()
self.send_email() self.send_email()
# Delete the corresponding draft
draft = CaseStudyDraft.objects.get(author=request.user)
if draft:
draft.delete()
return super().form_valid(form) return super().form_valid(form)