From dc80134fdff686594f62d9756963622a368b84e8 Mon Sep 17 00:00:00 2001
From: sandeepsajan0 <sandeepsajan0@gmail.com>
Date: Tue, 31 May 2022 16:51:50 +0530
Subject: [PATCH] Add a condition of draft state and submit for submit time in
 applicant edit view

---
 hypha/apply/funds/views.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py
index 73d045fae..336de5ab0 100644
--- a/hypha/apply/funds/views.py
+++ b/hypha/apply/funds/views.py
@@ -1030,6 +1030,11 @@ class ApplicantSubmissionEditView(BaseSubmissionEditView):
     def form_valid(self, form):
         self.object.new_data(form.cleaned_data)
 
+        # Update submit_time only when application is getting submitted from the Draft State for the first time.
+        if self.object.status == DRAFT_STATE and 'submit' in self.request.POST:
+            self.object.submit_time = timezone.now()
+            self.object.save(update_fields=['submit_time'])
+
         if 'save' in self.request.POST:
             self.object.create_revision(draft=True, by=self.request.user)
             messages.success(self.request, _('Submission saved successfully'))
@@ -1067,9 +1072,6 @@ class ApplicantSubmissionEditView(BaseSubmissionEditView):
                 notify=not (revision or submitting_proposal) or self.object.status == DRAFT_STATE,  # Use the other notification
             )
 
-        self.object.submit_time = timezone.now()
-        self.object.save(update_fields=['submit_time'])
-
         # Required for django-file-form: delete temporary files for the new files
         # uploaded while edit.
         form.delete_temporary_files()
-- 
GitLab