Skip to content

Commit d5d76de

Browse files
committed
Fix application status in confirmation email context (4678)
1 parent 10f89c4 commit d5d76de

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

hypha/apply/funds/models/submissions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@ def log_status_update(self, descriptor, source, target, **kwargs):
10541054
code=SUBMISSION_DRAFT, user=by, related_obj=instance
10551055
)
10561056
# notify for a new submission
1057+
instance.status = target
10571058
messenger(
10581059
MESSAGES.NEW_SUBMISSION,
10591060
request=request,

hypha/apply/funds/tests/test_views.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import wagtail.blocks
55
from bs4 import BeautifulSoup
6+
from django.core import mail
67
from django.conf import settings
78
from django.contrib.auth.models import AnonymousUser
89
from django.http import Http404
@@ -26,7 +27,7 @@
2627
SealedSubmissionFactory,
2728
)
2829
from hypha.apply.funds.views.submission_detail import SubmissionDetailView
29-
from hypha.apply.funds.workflows import INITIAL_STATE
30+
from hypha.apply.funds.workflows import DRAFT_STATE, INITIAL_STATE
3031
from hypha.apply.projects.models import Project
3132
from hypha.apply.projects.models.project import CONTRACTING
3233
from hypha.apply.projects.tests.factories import ProjectFactory
@@ -1252,6 +1253,23 @@ def test_can_submit_submission(self):
12521253
submission = self.refresh(self.draft_proposal_submission)
12531254
self.assertNotEqual(old_status, submission.status)
12541255

1256+
@override_settings(SEND_MESSAGES=True)
1257+
def test_submitting_application_in_draft_state_sends_correct_email(self):
1258+
draft_submission = ApplicationSubmissionFactory(user=self.user, status=DRAFT_STATE)
1259+
data = {**prepare_form_data(draft_submission), "submit": True}
1260+
1261+
self.post_page(draft_submission, {"submit": True, **data}, "edit")
1262+
1263+
self.assertEqual(len(mail.outbox), 1)
1264+
self.assertIn(
1265+
"We will review and reply to your submission as quickly as possible.",
1266+
mail.outbox[0].body,
1267+
)
1268+
self.assertNotIn(
1269+
"Please note that it is not submitted for review because it's still in draft.",
1270+
mail.outbox[0].body,
1271+
)
1272+
12551273
def test_gets_draft_on_edit_submission(self):
12561274
draft_revision = ApplicationRevisionFactory(
12571275
submission=self.draft_proposal_submission

0 commit comments

Comments
 (0)