From e1625af5f0a4ec5d0b9e6c7caaf37f482396fbaf Mon Sep 17 00:00:00 2001
From: Fredrik Jonsson <frjo@xdeb.org>
Date: Tue, 21 Jun 2022 09:10:31 +0200
Subject: [PATCH] Move confirmation mail template to where all other mail
 templates are. Make messages names a bit more clear.

---
 hypha/apply/activity/messaging.py              | 10 +++++-----
 .../migrations/0063_alter_event_type.py        | 18 ++++++++++++++++++
 hypha/apply/activity/options.py                |  4 ++--
 .../email/submission_confirmation.html}        |  0
 .../email/{edit.html => submission_edit.html}  |  0
 hypha/apply/funds/views.py                     |  2 +-
 6 files changed, 26 insertions(+), 8 deletions(-)
 create mode 100644 hypha/apply/activity/migrations/0063_alter_event_type.py
 rename hypha/apply/{funds/templates/funds/email/confirmation.html => activity/templates/messages/email/submission_confirmation.html} (100%)
 rename hypha/apply/activity/templates/messages/email/{edit.html => submission_edit.html} (100%)

diff --git a/hypha/apply/activity/messaging.py b/hypha/apply/activity/messaging.py
index 07d56b18c..7a17592f6 100644
--- a/hypha/apply/activity/messaging.py
+++ b/hypha/apply/activity/messaging.py
@@ -64,7 +64,7 @@ neat_related = {
     MESSAGES.TRANSITION: 'old_phase',
     MESSAGES.BATCH_TRANSITION: 'transitions',
     MESSAGES.APPLICANT_EDIT: 'revision',
-    MESSAGES.EDIT: 'revision',
+    MESSAGES.EDIT_SUBMISSION: 'revision',
     MESSAGES.COMMENT: 'comment',
     MESSAGES.SCREENING: 'old_status',
     MESSAGES.REVIEW_OPINION: 'opinion',
@@ -240,7 +240,7 @@ class ActivityAdapter(AdapterBase):
         MESSAGES.TRANSITION: 'handle_transition',
         MESSAGES.BATCH_TRANSITION: 'handle_batch_transition',
         MESSAGES.NEW_SUBMISSION: _('Submitted {source.title} for {source.page.title}'),
-        MESSAGES.EDIT: _('Edited'),
+        MESSAGES.EDIT_SUBMISSION: _('Edited'),
         MESSAGES.APPLICANT_EDIT: _('Edited'),
         MESSAGES.UPDATE_LEAD: _('Lead changed from {old_lead} to {source.lead}'),
         MESSAGES.BATCH_UPDATE_LEAD: _('Batch Lead changed to {new_lead}'),
@@ -431,7 +431,7 @@ class SlackAdapter(AdapterBase):
         MESSAGES.UPDATE_LEAD: _('The lead of <{link}|{source.title}> has been updated from {old_lead} to {source.lead} by {user}'),
         MESSAGES.BATCH_UPDATE_LEAD: 'handle_batch_lead',
         MESSAGES.COMMENT: _('A new {comment.visibility} comment has been posted on <{link}|{source.title}> by {user}'),
-        MESSAGES.EDIT: _('{user} has edited <{link}|{source.title}>'),
+        MESSAGES.EDIT_SUBMISSION: _('{user} has edited <{link}|{source.title}>'),
         MESSAGES.APPLICANT_EDIT: _('{user} has edited <{link}|{source.title}>'),
         MESSAGES.REVIEWERS_UPDATED: 'reviewers_updated',
         MESSAGES.BATCH_REVIEWERS_UPDATED: 'handle_batch_reviewers',
@@ -738,9 +738,9 @@ class SlackAdapter(AdapterBase):
 class EmailAdapter(AdapterBase):
     adapter_type = 'Email'
     messages = {
-        MESSAGES.NEW_SUBMISSION: 'funds/email/confirmation.html',
+        MESSAGES.NEW_SUBMISSION: 'messages/email/submission_confirmation.html',
         MESSAGES.COMMENT: 'notify_comment',
-        MESSAGES.EDIT: 'messages/email/edit.html',
+        MESSAGES.EDIT_SUBMISSION: 'messages/email/submission_edit.html',
         MESSAGES.TRANSITION: 'handle_transition',
         MESSAGES.BATCH_TRANSITION: 'handle_batch_transition',
         MESSAGES.DETERMINATION_OUTCOME: 'handle_determination',
diff --git a/hypha/apply/activity/migrations/0063_alter_event_type.py b/hypha/apply/activity/migrations/0063_alter_event_type.py
new file mode 100644
index 000000000..6bc9d7fcb
--- /dev/null
+++ b/hypha/apply/activity/migrations/0063_alter_event_type.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.2.13 on 2022-06-21 07:41
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('activity', '0062_remove_payment_requests_activities'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='event',
+            name='type',
+            field=models.CharField(choices=[('UPDATE_LEAD', 'Update Lead'), ('BATCH_UPDATE_LEAD', 'Batch Update Lead'), ('EDIT_SUBMISSION', 'Edit'), ('APPLICANT_EDIT', 'Applicant Edit'), ('NEW_SUBMISSION', 'New Submission'), ('SCREENING', 'Screening'), ('TRANSITION', 'Transition'), ('BATCH_TRANSITION', 'Batch Transition'), ('DETERMINATION_OUTCOME', 'Determination Outcome'), ('BATCH_DETERMINATION_OUTCOME', 'Batch Determination Outcome'), ('INVITED_TO_PROPOSAL', 'Invited To Proposal'), ('REVIEWERS_UPDATED', 'Reviewers Updated'), ('BATCH_REVIEWERS_UPDATED', 'Batch Reviewers Updated'), ('PARTNERS_UPDATED', 'Partners Updated'), ('PARTNERS_UPDATED_PARTNER', 'Partners Updated Partner'), ('READY_FOR_REVIEW', 'Ready For Review'), ('BATCH_READY_FOR_REVIEW', 'Batch Ready For Review'), ('NEW_REVIEW', 'New Review'), ('COMMENT', 'Comment'), ('PROPOSAL_SUBMITTED', 'Proposal Submitted'), ('OPENED_SEALED', 'Opened Sealed Submission'), ('REVIEW_OPINION', 'Review Opinion'), ('DELETE_SUBMISSION', 'Delete Submission'), ('DELETE_REVIEW', 'Delete Review'), ('CREATED_PROJECT', 'Created Project'), ('UPDATED_VENDOR', 'Updated Contracting information'), ('UPDATE_PROJECT_LEAD', 'Update Project Lead'), ('EDIT_REVIEW', 'Edit Review'), ('SEND_FOR_APPROVAL', 'Send for Approval'), ('APPROVE_PROJECT', 'Project was Approved'), ('PROJECT_TRANSITION', 'Project was Transitioned'), ('REQUEST_PROJECT_CHANGE', 'Project change requested'), ('UPLOAD_DOCUMENT', 'Document was Uploaded to Project'), ('REMOVE_DOCUMENT', 'Document was Removed from Project'), ('UPLOAD_CONTRACT', 'Contract was Uploaded to Project'), ('APPROVE_CONTRACT', 'Contract was Approved'), ('CREATE_INVOICE', 'Invoice was created for Project'), ('UPDATE_INVOICE_STATUS', 'Updated Invoice Status'), ('DELETE_INVOICE', 'Delete Invoice'), ('SENT_TO_COMPLIANCE', 'Project was sent to Compliance'), ('UPDATE_INVOICE', 'Updated Invoice'), ('SUBMIT_REPORT', 'Submit Report'), ('SKIPPED_REPORT', 'Skipped Report'), ('REPORT_FREQUENCY_CHANGED', 'Report Frequency Changed'), ('REPORT_NOTIFY', 'Report Notify'), ('CREATE_REMINDER', 'Reminder Created'), ('DELETE_REMINDER', 'Reminder Deleted'), ('REVIEW_REMINDER', 'Reminder to Review'), ('BATCH_DELETE_SUBMISSION', 'Delete Batch Submissions')], max_length=50),
+        ),
+    ]
diff --git a/hypha/apply/activity/options.py b/hypha/apply/activity/options.py
index 4defda408..3cda193df 100644
--- a/hypha/apply/activity/options.py
+++ b/hypha/apply/activity/options.py
@@ -4,7 +4,7 @@ from enum import Enum
 class MESSAGES(Enum):
     UPDATE_LEAD = 'Update Lead'
     BATCH_UPDATE_LEAD = 'Batch Update Lead'
-    EDIT = 'Edit'
+    EDIT_SUBMISSION = 'Edit'
     APPLICANT_EDIT = "Applicant Edit"
     NEW_SUBMISSION = 'New Submission'
     SCREENING = 'Screening'
@@ -49,7 +49,7 @@ class MESSAGES(Enum):
     REPORT_NOTIFY = 'Report Notify'
     CREATE_REMINDER = 'Reminder Created'
     DELETE_REMINDER = 'Reminder Deleted'
-    REVIEW_REMINDER = 'Reminde to Review'
+    REVIEW_REMINDER = 'Reminder to Review'
     BATCH_DELETE_SUBMISSION = 'Delete Batch Submissions'
 
     @classmethod
diff --git a/hypha/apply/funds/templates/funds/email/confirmation.html b/hypha/apply/activity/templates/messages/email/submission_confirmation.html
similarity index 100%
rename from hypha/apply/funds/templates/funds/email/confirmation.html
rename to hypha/apply/activity/templates/messages/email/submission_confirmation.html
diff --git a/hypha/apply/activity/templates/messages/email/edit.html b/hypha/apply/activity/templates/messages/email/submission_edit.html
similarity index 100%
rename from hypha/apply/activity/templates/messages/email/edit.html
rename to hypha/apply/activity/templates/messages/email/submission_edit.html
diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py
index 3f6b24696..22158b4e6 100644
--- a/hypha/apply/funds/views.py
+++ b/hypha/apply/funds/views.py
@@ -998,7 +998,7 @@ class AdminSubmissionEditView(BaseSubmissionEditView):
             revision = self.object.create_revision(by=self.request.user)
             if revision:
                 messenger(
-                    MESSAGES.EDIT,
+                    MESSAGES.EDIT_SUBMISSION,
                     request=self.request,
                     user=self.request.user,
                     source=self.object,
-- 
GitLab