Skip to content

Commit 64a4435

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

2 files changed

Lines changed: 22 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: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from bs4 import BeautifulSoup
66
from django.conf import settings
77
from django.contrib.auth.models import AnonymousUser
8+
from django.core import mail
89
from django.http import Http404
910
from django.test import RequestFactory, TestCase, override_settings
1011
from django.urls import reverse
@@ -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,25 @@ 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(
1259+
user=self.user, status=DRAFT_STATE
1260+
)
1261+
data = {**prepare_form_data(draft_submission), "submit": True}
1262+
1263+
self.post_page(draft_submission, {"submit": True, **data}, "edit")
1264+
1265+
self.assertEqual(len(mail.outbox), 1)
1266+
self.assertIn(
1267+
"We will review and reply to your submission as quickly as possible.",
1268+
mail.outbox[0].body,
1269+
)
1270+
self.assertNotIn(
1271+
"Please note that it is not submitted for review because it's still in draft.",
1272+
mail.outbox[0].body,
1273+
)
1274+
12551275
def test_gets_draft_on_edit_submission(self):
12561276
draft_revision = ApplicationRevisionFactory(
12571277
submission=self.draft_proposal_submission

0 commit comments

Comments
 (0)