SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 7d7736de authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Fix contributor mail-receive setting check

parent 47962cfe
No related branches found
No related tags found
No related merge requests found
...@@ -178,7 +178,7 @@ class CitationNotification(models.Model): ...@@ -178,7 +178,7 @@ class CitationNotification(models.Model):
if self.invitation: if self.invitation:
return self.invitation.last_name return self.invitation.last_name
elif self.contributor: elif self.contributor:
return self.contributor.last_name return self.contributor.user.last_name
@property @property
def get_title(self): def get_title(self):
......
...@@ -71,8 +71,9 @@ class CitationNotificationsProcessView(PermissionsMixin, RequestArgumentMixin, ...@@ -71,8 +71,9 @@ class CitationNotificationsProcessView(PermissionsMixin, RequestArgumentMixin,
Form is valid; use the MailEditorMixin to send out the mail if Form is valid; use the MailEditorMixin to send out the mail if
(possible) Contributor didn't opt-out from mails. (possible) Contributor didn't opt-out from mails.
""" """
citation = form.get_all_notifications().filter(contributor__isnull=False).first()
contributor = citation.contributor
form.get_all_notifications().update(processed=True) form.get_all_notifications().update(processed=True)
contributor = form.get_all_notifications().filter(contributor__isnull=False).first()
self.send_mail = (contributor and contributor.accepts_SciPost_emails) or not contributor self.send_mail = (contributor and contributor.accepts_SciPost_emails) or not contributor
return super().form_valid(form) return super().form_valid(form)
......
...@@ -54,7 +54,7 @@ Dear {{ notification.get_title }} {{ notification.last_name }}, ...@@ -54,7 +54,7 @@ Dear {{ notification.get_title }} {{ notification.last_name }},
The SciPost Team The SciPost Team
</p> </p>
{% if notification.get_first_related_contributor %} {% if notification.get_first_related_contributor and notification.get_first_related_contributor.activation_key %}
<p style="font-size: 10px;"> <p style="font-size: 10px;">
Don\'t want to receive such emails? <a href="https://scipost.org/{% url 'scipost:unsubscribe' notification.get_first_related_contributor.id notification.get_first_related_contributor.activation_key %}">Unsubscribe</a> Don\'t want to receive such emails? <a href="https://scipost.org/{% url 'scipost:unsubscribe' notification.get_first_related_contributor.id notification.get_first_related_contributor.activation_key %}">Unsubscribe</a>
</p> </p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment