SciPost Code Repository

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

Add new notifications (submissions app)

parent 784fce4d
No related branches found
No related tags found
No related merge requests found
default_app_config = 'submissions.apps.SubmissionsConfig'
from django.apps import AppConfig
from django.db.models.signals import post_save
class SubmissionsConfig(AppConfig):
name = 'submissions'
def ready(self):
super().ready()
from . import models, signals
post_save.connect(signals.notify_new_manuscript_submitted,
sender=models.Submission)
post_save.connect(signals.notify_new_editorial_recommendation,
sender=models.EICRecommendation)
post_save.connect(signals.notify_new_editorial_assignment,
sender=models.EditorialAssignment)
post_save.connect(signals.notify_new_referee_invitation,
sender=models.RefereeInvitation)
...@@ -275,6 +275,9 @@ class EditorialAssignment(SubmissionRelatedObjectMixin, models.Model): ...@@ -275,6 +275,9 @@ class EditorialAssignment(SubmissionRelatedObjectMixin, models.Model):
self.submission.title[:30] + ' by ' + self.submission.author_list[:30] + self.submission.title[:30] + ' by ' + self.submission.author_list[:30] +
', requested on ' + self.date_created.strftime('%Y-%m-%d')) ', requested on ' + self.date_created.strftime('%Y-%m-%d'))
def get_absolute_url(self):
return reverse('submissions:assignment_request', args=(self.id,))
class RefereeInvitation(SubmissionRelatedObjectMixin, models.Model): class RefereeInvitation(SubmissionRelatedObjectMixin, models.Model):
submission = models.ForeignKey('submissions.Submission', on_delete=models.CASCADE, submission = models.ForeignKey('submissions.Submission', on_delete=models.CASCADE,
...@@ -503,8 +506,10 @@ class EICRecommendation(SubmissionRelatedObjectMixin, models.Model): ...@@ -503,8 +506,10 @@ class EICRecommendation(SubmissionRelatedObjectMixin, models.Model):
eligible_to_vote = models.ManyToManyField('scipost.Contributor', blank=True, eligible_to_vote = models.ManyToManyField('scipost.Contributor', blank=True,
related_name='eligible_to_vote') related_name='eligible_to_vote')
voted_for = models.ManyToManyField('scipost.Contributor', blank=True, related_name='voted_for') voted_for = models.ManyToManyField('scipost.Contributor', blank=True, related_name='voted_for')
voted_against = models.ManyToManyField('scipost.Contributor', blank=True, related_name='voted_against') voted_against = models.ManyToManyField('scipost.Contributor', blank=True,
voted_abstain = models.ManyToManyField('scipost.Contributor', blank=True, related_name='voted_abstain') related_name='voted_against')
voted_abstain = models.ManyToManyField('scipost.Contributor', blank=True,
related_name='voted_abstain')
voting_deadline = models.DateTimeField('date submitted', default=timezone.now) voting_deadline = models.DateTimeField('date submitted', default=timezone.now)
objects = EICRecommendationManager() objects = EICRecommendationManager()
...@@ -513,6 +518,10 @@ class EICRecommendation(SubmissionRelatedObjectMixin, models.Model): ...@@ -513,6 +518,10 @@ class EICRecommendation(SubmissionRelatedObjectMixin, models.Model):
return (self.submission.title[:20] + ' by ' + self.submission.author_list[:30] + return (self.submission.title[:20] + ' by ' + self.submission.author_list[:30] +
', ' + self.get_recommendation_display()) ', ' + self.get_recommendation_display())
def get_absolute_url(self):
# TODO: Fix this weird redirect, but it's neccesary for the notifications to have one.
return self.submission.get_absolute_url()
@property @property
def nr_for(self): def nr_for(self):
return self.voted_for.count() return self.voted_for.count()
......
from django.contrib.auth.models import User, Group
from notifications.signals import notify
def notify_new_manuscript_submitted(sender, instance, created, **kwargs):
"""
Notify the Editorial Administration about a new Submission submitted.
"""
if created:
administrators = User.objects.filter(groups__name='Editorial Administrators')
for user in administrators:
notify.send(sender=sender, recipient=user, actor=instance.submitted_by,
verb=' submitted a new manuscript.', target=instance)
def notify_new_editorial_recommendation(sender, instance, created, **kwargs):
"""
Notify the Editorial Recommendation about a new Submission submitted.
"""
if created:
administrators = User.objects.filter(groups__name='Editorial Administrators')
editor_in_charge = instance.submission.editor_in_charge
for user in administrators:
notify.send(sender=sender, recipient=user, actor=editor_in_charge,
verb=' formulated a new Editorial Recommendation.', target=instance)
def notify_new_editorial_assignment(sender, instance, created, **kwargs):
"""
Notify a College Fellow about a new EIC invitation.
"""
if created:
administration = Group.objects.get(name='Editorial Administrators')
notify.send(sender=sender, recipient=instance.to.user, actor=administration,
verb=' invited you to become Editor-in-charge.', target=instance)
def notify_new_referee_invitation(sender, instance, created, **kwargs):
"""
Notify a Referee about a new refereeing invitation.
"""
if created:
notify.send(sender=sender, recipient=instance.referee.user,
actor=instance.submission.editor_in_charge,
verb=' would like to invite you to referee a Submission.', target=instance)
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
{% block pagetitle %}: Assignment Request{% endblock pagetitle %} {% block pagetitle %}: Assignment Request{% endblock pagetitle %}
{% block content %} {% block content %}
<h1>Assignment request</h1> <h1 class="highlight">Assignment request</h1>
<h3>Can you act as Editor-in-charge? (see below to accept/decline)</h3> <h3>Can you act as Editor-in-charge? (see below to accept/decline)</h3>
{% include 'submissions/_submission_assignment_request.html' with assignment=assignment consider_assignment_form=form %} {% include 'submissions/_submission_assignment_request.html' with assignment=assignment consider_assignment_form=form %}
......
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