From 0f9f6bbea04e68908eeeab773d687733f299e4ab Mon Sep 17 00:00:00 2001
From: Shrikrishna Singh <krishnasingh.ss30@gmail.com>
Date: Tue, 9 Jun 2020 16:09:56 +0530
Subject: [PATCH] Allow editing submission to be save as draft without
 validation

---
 .../funds/templates/funds/applicationsubmission_form.html      | 2 +-
 hypha/apply/funds/views.py                                     | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/hypha/apply/funds/templates/funds/applicationsubmission_form.html b/hypha/apply/funds/templates/funds/applicationsubmission_form.html
index c7060b015..d9d38d521 100644
--- a/hypha/apply/funds/templates/funds/applicationsubmission_form.html
+++ b/hypha/apply/funds/templates/funds/applicationsubmission_form.html
@@ -24,7 +24,7 @@
                 {% endif %}
             {% endfor %}
             {% for button_name, button_type, button_value in buttons %}
-                <input class="button button--submit button--top-space button--{{ button_type }}" type="submit" name="{{ button_name }}" value="{{ button_value }}" />
+                <input class="button button--submit button--top-space button--{{ button_type }}" type="submit" name="{{ button_name }}" value="{{ button_value }}"{% if button_value == 'Save Draft' %} formnovalidate{% endif %}/>
             {% endfor %}
         </form>
     </div>
diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py
index a7fec42b8..70229bcc0 100644
--- a/hypha/apply/funds/views.py
+++ b/hypha/apply/funds/views.py
@@ -887,7 +887,8 @@ class BaseSubmissionEditView(UpdateView):
         return super().get_context_data(buttons=self.buttons(), **kwargs)
 
     def get_form_class(self):
-        return self.object.get_form_class()
+        draft = self.request.POST.get('save', False)
+        return self.object.get_form_class(draft)
 
 
 @method_decorator(staff_required, name='dispatch')
-- 
GitLab