diff --git a/submissions/migrations/0055_auto_20170724_1734.py b/submissions/migrations/0055_auto_20170724_1734.py new file mode 100644 index 0000000000000000000000000000000000000000..aeab30e64171c0ae2c5b0c3247c932b218882b80 --- /dev/null +++ b/submissions/migrations/0055_auto_20170724_1734.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.3 on 2017-07-24 15:34 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone +import scipost.db.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('submissions', '0054_auto_20170721_1148'), + ] + + operations = [ + migrations.CreateModel( + name='SubmissionEvent', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created', models.DateTimeField(default=django.utils.timezone.now)), + ('latest_activity', scipost.db.fields.AutoDateTimeField(blank=True, default=django.utils.timezone.now, editable=False)), + ('event', models.CharField(choices=[('gen', 'General comment'), ('eic', 'Comment for Editor-in-charge'), ('auth', 'Comment for author')], default='gen', max_length=4)), + ('blub', models.TextField()), + ('submission', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='events', to='submissions.Submission')), + ], + options={ + 'abstract': False, + }, + ), + migrations.AlterModelOptions( + name='editorialcommunication', + options={'ordering': ['timestamp']}, + ), + migrations.AlterField( + model_name='editorialcommunication', + name='submission', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='editorial_communications', to='submissions.Submission'), + ), + ] diff --git a/submissions/models.py b/submissions/models.py index 2ecdcd874c1deec2a974979970a32346812ec5f2..3c67c2d08725935f1326543929700a4801d389f9 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -10,12 +10,14 @@ from .constants import ASSIGNMENT_REFUSAL_REASONS, ASSIGNMENT_NULLBOOL,\ SUBMISSION_TYPE, ED_COMM_CHOICES, REFEREE_QUALIFICATION, QUALITY_SPEC,\ 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 + SUBMISSION_CYCLES, CYCLE_DEFAULT, CYCLE_SHORT, CYCLE_DIRECT_REC,\ + EVENT_GENERAL, EVENT_TYPES from .managers import SubmissionManager, EditorialAssignmentManager, EICRecommendationManager,\ - ReportManager + ReportManager, SubmissionEventQuerySet from .utils import ShortSubmissionCycle, DirectRecommendationSubmissionCycle,\ GeneralSubmissionCycle +from scipost.behaviors import TimeStampedModel from scipost.constants import TITLE_CHOICES from scipost.fields import ChoiceArrayField from scipost.models import Contributor @@ -163,19 +165,28 @@ class Submission(models.Model): return self.reports.awaiting_vetting().count() -class SubmissionEvent(models.Model): - partner = models.ForeignKey('partners.Partner', on_delete=models.CASCADE, - related_name='events') - event = models.CharField(max_length=64, choices=PARTNER_EVENTS) - comments = models.TextField(blank=True) - noted_on = models.DateTimeField(auto_now_add=True) - noted_by = models.ForeignKey(User, on_delete=models.CASCADE) +class SubmissionEvent(TimeStampedModel): + """ + The SubmissionEvent's goal is to act as a messaging/logging model + for the Submission cycle. Its main audience will be the author(s) and + the Editor-in-charge of a Submission. + + Be aware! + Both the author and editor-in-charge will read the submission event. + Make sure the right text is given to the right event-type, to protect + the fellow's identity. + """ + 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() + + objects = SubmissionEventQuerySet.as_manager() def __str__(self): return '%s: %s' % (str(self.partner), self.get_event_display()) - ###################### # Editorial workflow # ###################### @@ -338,13 +349,17 @@ class EditorialCommunication(models.Model): Each individual communication between Editor-in-charge to and from Referees and Authors becomes an instance of this class. """ - submission = models.ForeignKey('submissions.Submission', on_delete=models.CASCADE) + submission = models.ForeignKey('submissions.Submission', on_delete=models.CASCADE, + related_name='editorial_communications') referee = models.ForeignKey('scipost.Contributor', related_name='referee_in_correspondence', blank=True, null=True, on_delete=models.CASCADE) comtype = models.CharField(max_length=4, choices=ED_COMM_CHOICES) timestamp = models.DateTimeField(default=timezone.now) text = models.TextField() + class Meta: + ordering = ['timestamp'] + def __str__(self): output = self.comtype if self.referee is not None: