diff --git a/scipost_django/submissions/templates/submissions/pool/_referee_invitations.html b/scipost_django/submissions/templates/submissions/pool/_referee_invitations.html index 1121256e66172336de958f720065e9b500baaec5..766635bf76216aac0f529acbf435d6281b23b2e7 100644 --- a/scipost_django/submissions/templates/submissions/pool/_referee_invitations.html +++ b/scipost_django/submissions/templates/submissions/pool/_referee_invitations.html @@ -41,7 +41,7 @@ {% if not invitation.cancelled %} <span class="text-danger">Invitation email not sent!!</span> <br> - <a class="btn btn-sm btn-danger text-white" href="{% url 'submissions:invite_referee' identifier_w_vn_nr=invitation.submission.preprint.identifier_w_vn_nr profile_id=invitation.profile.id auto_reminders_allowed=invitation.auto_reminders_allowed|yesno:"1,0" %}"> + <a class="btn btn-sm btn-danger text-white" href="{% url 'submissions:invite_referee' identifier_w_vn_nr=invitation.submission.preprint.identifier_w_vn_nr profile_id=invitation.profile.id profile_email=invitation.email_address auto_reminders_allowed=invitation.auto_reminders_allowed %}"> {% include 'bi/arrow-right.html' %} Resend </a> {% endif %} diff --git a/scipost_django/submissions/urls/__init__.py b/scipost_django/submissions/urls/__init__.py index dc150bd2d709b11915a6e855bee0d68fa38f8da4..ee41f96def0ed0636deb77d9d7c242e710e96746 100644 --- a/scipost_django/submissions/urls/__init__.py +++ b/scipost_django/submissions/urls/__init__.py @@ -309,7 +309,7 @@ urlpatterns = [ name="add_referee_profile", ), path( - "invite_referee/<identifier:identifier_w_vn_nr>/<int:profile_id>/<int:auto_reminders_allowed>", + "invite_referee/<identifier:identifier_w_vn_nr>/<int:profile_id>/<str:profile_email>/auto_remind/<str:auto_reminders_allowed>", views.invite_referee, name="invite_referee", ), diff --git a/scipost_django/submissions/views/__init__.py b/scipost_django/submissions/views/__init__.py index 00eea54e906c5e2b476805f47d8d05d8b60cbcfd..92602d9b6befd5363469305bd1d30dd36cea0164 100644 --- a/scipost_django/submissions/views/__init__.py +++ b/scipost_django/submissions/views/__init__.py @@ -1220,9 +1220,11 @@ def add_referee_profile(request, identifier_w_vn_nr): @login_required @fellowship_or_admin_required() @transaction.atomic -def invite_referee(request, identifier_w_vn_nr, profile_id, auto_reminders_allowed): +def invite_referee( + request, identifier_w_vn_nr, profile_id, profile_email, auto_reminders_allowed +): """ - Invite a referee linked to a Profile. + Invite a referee linked to a Profile using their profile email. If the Profile has a Contributor object, a simple invitation is sent. If there is no associated Contributor, a registration invitation is included. """ @@ -1231,6 +1233,13 @@ def invite_referee(request, identifier_w_vn_nr, profile_id, auto_reminders_allow preprint__identifier_w_vn_nr=identifier_w_vn_nr, ) profile = get_object_or_404(Profile, pk=profile_id) + auto_reminders_allowed = auto_reminders_allowed == "True" + + # We cannot proceed if the Profile has no email address + # or if the email address is not linked to the Profile. + profile_email = profile.emails.get(email=profile_email) + if profile_email is None: + raise Http404 contributor = None if hasattr(profile, "contributor") and profile.contributor: @@ -1243,7 +1252,7 @@ def invite_referee(request, identifier_w_vn_nr, profile_id, auto_reminders_allow title=profile.title if profile.title else TITLE_DR, first_name=profile.first_name, last_name=profile.last_name, - email_address=profile.email, + email_address=profile_email.email, auto_reminders_allowed=auto_reminders_allowed, invited_by=request.user.contributor, ) @@ -1269,19 +1278,18 @@ def invite_referee(request, identifier_w_vn_nr, profile_id, auto_reminders_allow invitation=referee_invitation, ) else: # no Contributor, so registration invitation - ( - 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, - invitation_type=INVITATION_REFEREEING, - created_by=request.user, - invited_by=request.user, - invitation_key=referee_invitation.invitation_key, + 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.email, + invitation_type=INVITATION_REFEREEING, + created_by=request.user, + invited_by=request.user, + invitation_key=referee_invitation.invitation_key, + ) ) mail_request = MailEditorSubview( request,