diff --git a/hypha/apply/funds/models/applications.py b/hypha/apply/funds/models/applications.py index 19f7846b30e4a48417ea8eb580764d40cf6db01a..a617a41b5d9f730cb29377dc228600f9df7e6b84 100644 --- a/hypha/apply/funds/models/applications.py +++ b/hypha/apply/funds/models/applications.py @@ -356,10 +356,11 @@ class RoundBase(WorkflowStreamForm, SubmittableStreamForm): # type: ignore # Overriding serve method to pass submission id to get_form method copy_open_submission = request.GET.get('open_call_submission') if request.method == 'POST': + draft = bool(request.POST.get('draft')) form = self.get_form(request.POST, request.FILES, page=self, user=request.user) if form.is_valid(): - form_submission = self.process_form_submission(form) + form_submission = self.process_form_submission(form, draft) return self.render_landing_page(request, form_submission, *args, **kwargs) else: form = self.get_form(page=self, user=request.user, submission_id=copy_open_submission) diff --git a/hypha/apply/funds/models/utils.py b/hypha/apply/funds/models/utils.py index caa8194a2d7205fd4d212abed754e20cdc19b389..18aa1e96e094306ce7bcf28a825230cfd6c11599 100644 --- a/hypha/apply/funds/models/utils.py +++ b/hypha/apply/funds/models/utils.py @@ -65,14 +65,22 @@ class SubmittableStreamForm(AbstractStreamForm): def get_submission_class(self): return self.submission_class - def process_form_submission(self, form): + def process_form_submission(self, form, draft): if not form.user.is_authenticated: form.user = None - return self.get_submission_class().objects.create( - form_data=form.cleaned_data, - form_fields=self.get_defined_fields(), - **self.get_submit_meta_data(user=form.user), - ) + if draft: + return self.get_submission_class().objects.create( + form_data=form.cleaned_data, + form_fields=self.get_defined_fields(), + **self.get_submit_meta_data(user=form.user), + status='draft', + ) + else: + return self.get_submission_class().objects.create( + form_data=form.cleaned_data, + form_fields=self.get_defined_fields(), + **self.get_submit_meta_data(user=form.user), + ) def get_submit_meta_data(self, **kwargs): return kwargs diff --git a/hypha/apply/funds/templates/funds/application_base.html b/hypha/apply/funds/templates/funds/application_base.html index d9aa80f42efa00bb01540da8b32f4706d94b63d3..02fdd8bd48489813ce8584bfe14de297c9badf87 100644 --- a/hypha/apply/funds/templates/funds/application_base.html +++ b/hypha/apply/funds/templates/funds/application_base.html @@ -53,7 +53,7 @@ {% endif %} {% endif %} {% endfor %} - <button class="link link--button-tertiary" type="submit" disabled>Save as a draft</button> + <input class="link link--button-tertiary" type="submit" value="Save Draft" name="draft" /> <button class="link link--button-secondary" type="submit" disabled>Submit for review</button> </form> <p class="wrapper--error message-no-js js-hidden">You must have Javascript enabled to use this form.</p>