From dff44e97fad8f5de0840769755ac9970a28233f6 Mon Sep 17 00:00:00 2001
From: Saurabh Kumar <theskumar@users.noreply.github.com>
Date: Tue, 26 Sep 2023 18:01:04 +0530
Subject: [PATCH] Fix "Save as Draft" for lab Funds (#3573)

Allow lab to be saved as draft without filling in the required fields.
Right now, if the lab is saved as draft it is validated for the required
fields.

Fixes https://github.com/HyphaApp/hypha/issues/3555
---
 hypha/apply/funds/models/applications.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hypha/apply/funds/models/applications.py b/hypha/apply/funds/models/applications.py
index 7a0b81c44..e4f8e79b7 100644
--- a/hypha/apply/funds/models/applications.py
+++ b/hypha/apply/funds/models/applications.py
@@ -584,8 +584,9 @@ class LabBase(EmailForm, WorkflowStreamForm, SubmittableStreamForm):  # type: ig
         return self.live
 
     def get_form(self, *args, **kwargs):
+        draft = kwargs.pop("draft", False)
         user = kwargs.get("user")
-        form_class = self.get_form_class(user=user)
+        form_class = self.get_form_class(draft=draft, user=user)
         form_params = self.get_form_parameters()
         form_params.update(kwargs)
 
@@ -599,10 +600,10 @@ class LabBase(EmailForm, WorkflowStreamForm, SubmittableStreamForm):  # type: ig
             )
 
         if request.method == "POST":
+            draft = request.POST.get("draft", False)
             form = self.get_form(
-                request.POST, request.FILES, page=self, user=request.user
+                request.POST, request.FILES, page=self, user=request.user, draft=draft
             )
-            draft = request.POST.get("draft", False)
             if form.is_valid():
                 form_submission = SubmittableStreamForm.process_form_submission(
                     self, form, draft=draft
-- 
GitLab