diff --git a/hypha/apply/funds/models/submissions.py b/hypha/apply/funds/models/submissions.py index f1215be4f5..503c6843b0 100644 --- a/hypha/apply/funds/models/submissions.py +++ b/hypha/apply/funds/models/submissions.py @@ -1054,6 +1054,7 @@ def log_status_update(self, descriptor, source, target, **kwargs): code=SUBMISSION_DRAFT, user=by, related_obj=instance ) # notify for a new submission + instance.status = target messenger( MESSAGES.NEW_SUBMISSION, request=request, diff --git a/hypha/apply/funds/tests/test_views.py b/hypha/apply/funds/tests/test_views.py index b3289601d8..f390563fcb 100644 --- a/hypha/apply/funds/tests/test_views.py +++ b/hypha/apply/funds/tests/test_views.py @@ -5,6 +5,7 @@ from bs4 import BeautifulSoup from django.conf import settings from django.contrib.auth.models import AnonymousUser +from django.core import mail from django.http import Http404 from django.test import RequestFactory, TestCase, override_settings from django.urls import reverse @@ -26,7 +27,7 @@ SealedSubmissionFactory, ) from hypha.apply.funds.views.submission_detail import SubmissionDetailView -from hypha.apply.funds.workflows import INITIAL_STATE +from hypha.apply.funds.workflows import DRAFT_STATE, INITIAL_STATE from hypha.apply.projects.models import Project from hypha.apply.projects.models.project import CONTRACTING from hypha.apply.projects.tests.factories import ProjectFactory @@ -1252,6 +1253,25 @@ def test_can_submit_submission(self): submission = self.refresh(self.draft_proposal_submission) self.assertNotEqual(old_status, submission.status) + @override_settings(SEND_MESSAGES=True) + def test_submitting_application_in_draft_state_sends_correct_email(self): + draft_submission = ApplicationSubmissionFactory( + user=self.user, status=DRAFT_STATE + ) + data = {**prepare_form_data(draft_submission), "submit": True} + + self.post_page(draft_submission, {"submit": True, **data}, "edit") + + self.assertEqual(len(mail.outbox), 1) + self.assertIn( + "We will review and reply to your submission as quickly as possible.", + mail.outbox[0].body, + ) + self.assertNotIn( + "Please note that it is not submitted for review because it's still in draft.", + mail.outbox[0].body, + ) + def test_gets_draft_on_edit_submission(self): draft_revision = ApplicationRevisionFactory( submission=self.draft_proposal_submission