SciPost Code Repository

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

Add basic `add_event` method to Submission

parent b8b7a2cf
No related branches found
No related tags found
No related merge requests found
......@@ -628,6 +628,6 @@ class SubmissionCycleChoiceForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['refereeing_cycle'].default = None
other_submission = self.instance.other_versions().first()
other_submission = self.instance.other_versions[0]
if other_submission:
self.fields['referees_reinvite'].queryset = other_submission.referee_invitations.all()
......@@ -4,8 +4,8 @@ from django.db.models import Q
from .constants import SUBMISSION_STATUS_OUT_OF_POOL, SUBMISSION_STATUS_PUBLICLY_UNLISTED,\
SUBMISSION_STATUS_PUBLICLY_INVISIBLE, STATUS_UNVETTED, STATUS_VETTED,\
STATUS_UNCLEAR, STATUS_INCORRECT, STATUS_NOT_USEFUL, STATUS_NOT_ACADEMIC,\
SUBMISSION_HTTP404_ON_EDITORIAL_PAGE, STATUS_DRAFT,\
SUBMISSION_EXCLUDE_FROM_REPORTING
SUBMISSION_HTTP404_ON_EDITORIAL_PAGE, SUBMISSION_EXCLUDE_FROM_REPORTING,\
STATUS_DRAFT, EVENT_GENERAL, EVENT_FOR_AUTHOR, EVENT_FOR_EIC
class SubmissionManager(models.Manager):
......@@ -83,7 +83,17 @@ class SubmissionManager(models.Manager):
class SubmissionEventQuerySet(models.QuerySet):
pass
def for_author(self):
"""
Return all events that are meant to be for the author(s) of a submission.
"""
return self.filter(event__in=[EVENT_FOR_AUTHOR, EVENT_GENERAL])
def for_eic(self):
"""
Return all events that are meant to be for the Editor-in-charge of a submission.
"""
return self.filter(event__in=[EVENT_FOR_EIC, EVENT_GENERAL])
class EditorialAssignmentManager(models.Manager):
......
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2017-07-24 16:18
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('submissions', '0055_auto_20170724_1734'),
]
operations = [
migrations.RenameField(
model_name='submissionevent',
old_name='blub',
new_name='text',
),
]
......@@ -11,7 +11,7 @@ from .constants import ASSIGNMENT_REFUSAL_REASONS, ASSIGNMENT_NULLBOOL,\
RANKING_CHOICES, REPORT_REC, SUBMISSION_STATUS, STATUS_UNASSIGNED,\
REPORT_STATUSES, STATUS_UNVETTED, SUBMISSION_EIC_RECOMMENDATION_REQUIRED,\
SUBMISSION_CYCLES, CYCLE_DEFAULT, CYCLE_SHORT, CYCLE_DIRECT_REC,\
EVENT_GENERAL, EVENT_TYPES
EVENT_GENERAL, EVENT_TYPES, EVENT_FOR_AUTHOR, EVENT_FOR_EIC
from .managers import SubmissionManager, EditorialAssignmentManager, EICRecommendationManager,\
ReportManager, SubmissionEventQuerySet
from .utils import ShortSubmissionCycle, DirectRecommendationSubmissionCycle,\
......@@ -134,6 +134,7 @@ class Submission(models.Model):
def reporting_deadline_has_passed(self):
return timezone.now() > self.reporting_deadline
@cached_property
def other_versions(self):
return Submission.objects.filter(
arxiv_identifier_wo_vn_nr=self.arxiv_identifier_wo_vn_nr
......@@ -158,11 +159,29 @@ class Submission(models.Model):
def count_obtained_reports(self):
return self.reports.accepted().filter(invited__isnull=False).count()
def count_refused_reports(self):
return self.reports.rejected().count()
def count_awaiting_vetting(self):
return self.reports.awaiting_vetting().count()
def add_general_event(self, message):
event = SubmissionEvent(
submission=self,
event=EVENT_GENERAL,
text=message,
)
event.save()
def add_event_for_author(self, message):
event = SubmissionEvent(
submission=self,
event=EVENT_FOR_AUTHOR,
text=message,
)
event.save()
def add_event_for_eic(self, message):
event = SubmissionEvent(
submission=self,
event=EVENT_FOR_EIC,
text=message,
)
event.save()
class SubmissionEvent(TimeStampedModel):
......@@ -179,7 +198,7 @@ class SubmissionEvent(TimeStampedModel):
submission = models.ForeignKey('submissions.Submission', on_delete=models.CASCADE,
related_name='events')
event = models.CharField(max_length=4, choices=EVENT_TYPES, default=EVENT_GENERAL)
blub = models.TextField()
text = models.TextField()
objects = SubmissionEventQuerySet.as_manager()
......
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