Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hypha/apply/funds/models/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, but it might cause issues at another place because it is mentioned in Line 1042-43 that "instance status here would be the old phase and we have to pass new phase as an arg" like it is done in Line 1070 . You may need to look for edge cases if it is not causing any other issue then it is fine otherwise i would suggest to use similar approach as we used below in MESSAGES.TRANSITION at line 1070.

messenger(
MESSAGES.NEW_SUBMISSION,
request=request,
Expand Down
22 changes: 21 additions & 1 deletion hypha/apply/funds/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading