From a77c53d362199ca879a771a889522f886033233b Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Thu, 4 Jan 2024 16:59:11 +0200 Subject: [PATCH] add registration invitation to nominated fellow emails --- scipost_django/colleges/views.py | 53 +++++++++++++++++++ .../fellowship_invitation_initial.html | 15 ++++-- .../fellowship_invitation_reminder.html | 6 +++ 3 files changed, 69 insertions(+), 5 deletions(-) diff --git a/scipost_django/colleges/views.py b/scipost_django/colleges/views.py index 9cccc1faa..e64d3f9cd 100644 --- a/scipost_django/colleges/views.py +++ b/scipost_django/colleges/views.py @@ -28,6 +28,9 @@ from colleges.permissions import ( is_edadmin_or_advisory_or_active_regular_or_senior_fellow, ) from colleges.utils import check_profile_eligibility_for_fellowship +from invitations.constants import INVITATION_EDITORIAL_FELLOW +from invitations.models import RegistrationInvitation +from scipost.constants import TITLE_DR from scipost.permissions import HTMXPermissionsDenied, HTMXResponse from submissions.models import Submission @@ -1057,6 +1060,27 @@ class FellowshipInvitationEmailInitialView(PermissionsMixin, MailView): mail_code = "fellowship_nominees/fellowship_invitation_initial" success_url = reverse_lazy("colleges:nominations") + def get_mail_config(self): + config = super().get_mail_config() + profile = self.object.nomination.profile + ( + registration_invitation, + reginv_created, + ) = RegistrationInvitation.objects.get_or_create( + profile=profile, + title=profile.title if profile.title else TITLE_DR, + first_name=profile.first_name, + last_name=profile.last_name, + email=profile.email, + created_by=self.request.user, + invited_by=self.request.user, + invitation_type=INVITATION_EDITORIAL_FELLOW, + ) + self.reg_inv = registration_invitation + config["registration_invitation"] = registration_invitation + + return config + def form_valid(self, form): """Create an event associated to this outgoing email.""" self.object.nomination.add_event( @@ -1066,6 +1090,10 @@ class FellowshipInvitationEmailInitialView(PermissionsMixin, MailView): self.object.invited_on = timezone.now() self.object.response = FellowshipInvitation.RESPONSE_INVITED self.object.save() + + # run actions on successful invitation sent + self.reg_inv.mail_sent() + return super().form_valid(form) @@ -1077,6 +1105,27 @@ class FellowshipInvitationEmailReminderView(PermissionsMixin, MailView): mail_code = "fellowship_nominees/fellowship_invitation_reminder" success_url = reverse_lazy("colleges:nominations") + def get_mail_config(self): + config = super().get_mail_config() + profile = self.object.nomination.profile + ( + registration_invitation, + reginv_created, + ) = RegistrationInvitation.objects.get_or_create( + profile=profile, + title=profile.title if profile.title else TITLE_DR, + first_name=profile.first_name, + last_name=profile.last_name, + email=profile.email, + created_by=self.request.user, + invited_by=self.request.user, + invitation_type=INVITATION_EDITORIAL_FELLOW, + ) + self.reg_inv = registration_invitation + config["registration_invitation"] = registration_invitation + + return config + def form_valid(self, form): """Create an event associated to this outgoing email.""" self.object.nomination.add_event( @@ -1086,6 +1135,10 @@ class FellowshipInvitationEmailReminderView(PermissionsMixin, MailView): self.object.invited_on = timezone.now() self.object.response = FellowshipInvitation.RESPONSE_REINVITED self.object.save() + + # run actions on successful invitation sent + self.reg_inv.mail_sent() + return super().form_valid(form) diff --git a/scipost_django/templates/email/fellowship_nominees/fellowship_invitation_initial.html b/scipost_django/templates/email/fellowship_nominees/fellowship_invitation_initial.html index 9f744a38d..37b8ed195 100644 --- a/scipost_django/templates/email/fellowship_nominees/fellowship_invitation_initial.html +++ b/scipost_django/templates/email/fellowship_nominees/fellowship_invitation_initial.html @@ -1,26 +1,31 @@ <p>Dear {{ object.nomination.profile.get_title_display }} {{ object.nomination.profile.last_name }},</p> <p> - We are sending you this email to formally invite you to join <a href="https://scipost.org">SciPost</a>'s Editorial College in {{ object.nomination.college.name }}. + We are sending you this email to formally invite you to join <a href="https://{{ domain }}/">SciPost</a>'s Editorial College in {{ object.nomination.college.name }}. </p> <p> - For the past several years, the SciPost Foundation has built a community-run, open and not-for-profit infrastructure for scientific publishing (see our <a href="https://scipost.org/about">about page</a> for a quick introduction or reminder). We are grateful for the positive reception that our journals enjoyed and look forward to strengthening our Editorial Colleges with prominent members of the scientific community. As mentioned above, on behalf of the SciPost Foundation and in light of your professional expertise and reputation, we hereby would like to invite you to join the Editorial College (Physics) by becoming one of our Editorial Fellows. + For the past several years, the SciPost Foundation has built a community-run, open and not-for-profit infrastructure for scientific publishing (see our <a href="https://{{ domain }}//about">about page</a> for a quick introduction or reminder). We are grateful for the positive reception that our journals enjoyed and look forward to strengthening our Editorial Colleges with prominent members of the scientific community. As mentioned above, on behalf of the SciPost Foundation and in light of your professional expertise and reputation, we hereby would like to invite you to join the Editorial College (Physics) by becoming one of our Editorial Fellows. </p> - <p> - Academic excellence is the most important criterion guiding our considerations of who should belong to our Editorial Colleges. The current list of Colleges and their Fellows can be found <a href="https://scipost.org/colleges/">at this page</a>. + Academic excellence is the most important criterion guiding our considerations of who should belong to our Editorial Colleges. The current list of Colleges and their Fellows can be found <a href="https://{{ domain }}//colleges/">at this page</a>. </p> <p> - Participation in the College typically takes a couple hours a week. We ask Fellows to share the workload equitably and to take charge of at least 4 submissions per year. However, you will always remain in control of your level of commitment and of which submissions you take charge of. Functioning of the Colleges proceeds according to the <a href="https://scipost.org/EdCol_by-laws">by-laws</a>, and a short summary of the editorial workflow can be found <a href="https://scipost.org/submissions/editorial_workflow">at this page</a>. + Participation in the College typically takes a couple hours a week. We ask Fellows to share the workload equitably and to take charge of at least 4 submissions per year. However, you will always remain in control of your level of commitment and of which submissions you take charge of. Functioning of the Colleges proceeds according to the <a href="https://{{ domain }}//EdCol_by-laws">by-laws</a>, and a short summary of the editorial workflow can be found <a href="https://{{ domain }}//submissions/editorial_workflow">at this page</a>. </p> <p> We would be very happy to provide you with more information should you require it. Could we kindly ask you to give us a response (by replying to this email) within the next couple of weeks? </p> +{% if not object.nomination.profile.contributor %} + <p> + Additionally, regardless of your response, we would like to cordially invite you to become a SciPost Contributor by registering on our website. This will allow you to submit your own articles, deliver reports, comment on articles, and perform all duties as Fellow should you also accept that role. For your convenience, we have prepared a pre-filled <a href="https://{{ domain }}/invitation/{{ registration_invitation.invitation_key }}">registration form</a> for you. + </p> +{% endif %} + <p>Many thanks in advance,</p> <p> Prof. J.-S. Caux, diff --git a/scipost_django/templates/email/fellowship_nominees/fellowship_invitation_reminder.html b/scipost_django/templates/email/fellowship_nominees/fellowship_invitation_reminder.html index feac51be4..7da3b26e6 100644 --- a/scipost_django/templates/email/fellowship_nominees/fellowship_invitation_reminder.html +++ b/scipost_django/templates/email/fellowship_nominees/fellowship_invitation_reminder.html @@ -4,6 +4,12 @@ Recently, we contacted you concerning our invitation to join <a href="https://scipost.org">SciPost</a>'s Editorial College in {{ object.nomination.college.name }}. With this email, we would simply like to reiterate this invitation, and inquire about your interest in joining our initiative. Please see below for more details. </p> +{% if not object.nomination.profile.contributor %} + <p> + Please also use the newly-generated pre-filled <a href="https://{{ domain }}/invitation/{{ registration_invitation.invitation_key }}">registration form</a> if you choose to sign up as a SciPost Contributor. + </p> +{% endif %} + <p>Sincerely,</p> <p> Prof. J.-S. Caux, -- GitLab