From 4ff192e05f224a564aa34f246e1096b38f7eb4f8 Mon Sep 17 00:00:00 2001 From: Jorran de Wit <jorrandewit@outlook.com> Date: Sat, 26 May 2018 13:47:23 +0200 Subject: [PATCH] Status to EdAssignment --- .../migrations/0007_auto_20180526_1336.py | 20 +++++++++++++ submissions/constants.py | 12 ++++++++ .../migrations/0027_auto_20180526_1336.py | 30 +++++++++++++++++++ .../migrations/0028_auto_20180526_1336.py | 28 +++++++++++++++++ submissions/models.py | 13 +++++--- 5 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 conflicts/migrations/0007_auto_20180526_1336.py create mode 100644 submissions/migrations/0027_auto_20180526_1336.py create mode 100644 submissions/migrations/0028_auto_20180526_1336.py diff --git a/conflicts/migrations/0007_auto_20180526_1336.py b/conflicts/migrations/0007_auto_20180526_1336.py new file mode 100644 index 000000000..960584e35 --- /dev/null +++ b/conflicts/migrations/0007_auto_20180526_1336.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2018-05-26 11:36 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('conflicts', '0006_auto_20180526_0923'), + ] + + operations = [ + migrations.AlterField( + model_name='conflictgroup', + name='related_submissions', + field=models.ManyToManyField(blank=True, related_name='conflict_groups', to='submissions.Submission'), + ), + ] diff --git a/submissions/constants.py b/submissions/constants.py index 8483db009..a77363f82 100644 --- a/submissions/constants.py +++ b/submissions/constants.py @@ -71,6 +71,18 @@ ASSIGNMENT_REFUSAL_REASONS = ( ('DNP', 'SciPost should not even consider this paper'), ) +STATUS_PREASSIGNED, STATUS_INVITED = 'preassigned', 'invited' +STATUS_DECLINED = 'declined' +STATUS_DEPRECATED, STATUS_COMPLETED = 'deprecated', 'completed' +ASSIGNMENT_STATUSES = ( + (STATUS_PREASSIGNED, 'Pre-assigned'), + (STATUS_INVITED, 'Invited'), + (STATUS_ACCEPTED, 'Accepted'), + (STATUS_DECLINED, 'Declined'), + (STATUS_COMPLETED, 'Completed'), + (STATUS_DEPRECATED, 'Deprecated'), +) + REFEREE_QUALIFICATION = ( (None, '-'), (4, 'expert in this subject'), diff --git a/submissions/migrations/0027_auto_20180526_1336.py b/submissions/migrations/0027_auto_20180526_1336.py new file mode 100644 index 000000000..acb95b973 --- /dev/null +++ b/submissions/migrations/0027_auto_20180526_1336.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2018-05-26 11:36 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('submissions', '0026_submission_needs_conflicts_update'), + ] + + operations = [ + migrations.AddField( + model_name='editorialassignment', + name='date_invited', + field=models.DateTimeField(blank=True, null=True), + ), + migrations.AddField( + model_name='editorialassignment', + name='invitation_order', + field=models.PositiveSmallIntegerField(default=0), + ), + migrations.AddField( + model_name='editorialassignment', + name='status', + field=models.CharField(choices=[('preassigned', 'Pre-assigned'), ('invited', 'Invited'), ('accepted', 'Accepted'), ('declined', 'Declined'), ('completed', 'Completed'), ('deprecated', 'Deprecated')], default='preassigned', max_length=16), + ), + ] diff --git a/submissions/migrations/0028_auto_20180526_1336.py b/submissions/migrations/0028_auto_20180526_1336.py new file mode 100644 index 000000000..281b25158 --- /dev/null +++ b/submissions/migrations/0028_auto_20180526_1336.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.4 on 2018-05-26 11:36 +from __future__ import unicode_literals + +from django.db import migrations + + +def rename_assignment_statuses(apps, schema_editor): + """Rename EditorialAssignment incoming status.""" + EditorialAssignment = apps.get_model('submissions', 'EditorialAssignment') + + # Update statuses + EditorialAssignment.objects.filter(deprecated=True).update(status='deprecated') + EditorialAssignment.objects.filter(deprecated=False, accepted__isnull=True).update(status='invited') + EditorialAssignment.objects.filter(deprecated=False, accepted=False).update(status='declined') + EditorialAssignment.objects.filter(deprecated=False, accepted=True, completed=False).update(status='accepted') + EditorialAssignment.objects.filter(deprecated=False, accepted=True, completed=True).update(status='completed') + + +class Migration(migrations.Migration): + + dependencies = [ + ('submissions', '0027_auto_20180526_1336'), + ] + + operations = [ + migrations.RunPython(rename_assignment_statuses), + ] diff --git a/submissions/models.py b/submissions/models.py index 3eba5ff28..22a30f4bd 100644 --- a/submissions/models.py +++ b/submissions/models.py @@ -15,10 +15,10 @@ from django.utils.functional import cached_property from .behaviors import SubmissionRelatedObjectMixin from .constants import ( - ASSIGNMENT_REFUSAL_REASONS, ASSIGNMENT_NULLBOOL, SUBMISSION_TYPE, + ASSIGNMENT_REFUSAL_REASONS, ASSIGNMENT_NULLBOOL, SUBMISSION_TYPE, STATUS_PREASSIGNED, ED_COMM_CHOICES, REFEREE_QUALIFICATION, QUALITY_SPEC, RANKING_CHOICES, REPORT_REC, SUBMISSION_STATUS, REPORT_STATUSES, STATUS_UNVETTED, STATUS_INCOMING, STATUS_EIC_ASSIGNED, - SUBMISSION_CYCLES, CYCLE_DEFAULT, CYCLE_SHORT, STATUS_RESUBMITTED, DECISION_FIXED, + SUBMISSION_CYCLES, CYCLE_DEFAULT, CYCLE_SHORT, DECISION_FIXED, ASSIGNMENT_STATUSES, CYCLE_DIRECT_REC, EVENT_GENERAL, EVENT_TYPES, EVENT_FOR_AUTHOR, EVENT_FOR_EIC, REPORT_TYPES, REPORT_NORMAL, STATUS_DRAFT, STATUS_VETTED, EIC_REC_STATUSES, VOTING_IN_PREP, STATUS_INCORRECT, STATUS_UNCLEAR, STATUS_NOT_USEFUL, STATUS_NOT_ACADEMIC, DEPRECATED) @@ -370,9 +370,14 @@ class EditorialAssignment(SubmissionRelatedObjectMixin, models.Model): # attribute `deprecated' becomes True if another Fellow becomes Editor-in-charge deprecated = models.BooleanField(default=False) completed = models.BooleanField(default=False) - refusal_reason = models.CharField(max_length=3, choices=ASSIGNMENT_REFUSAL_REASONS, - blank=True, null=True) + status = models.CharField( + max_length=16, choices=ASSIGNMENT_STATUSES, default=STATUS_PREASSIGNED) + refusal_reason = models.CharField( + max_length=3, choices=ASSIGNMENT_REFUSAL_REASONS, blank=True, null=True) + invitation_order = models.PositiveSmallIntegerField(default=0) + date_created = models.DateTimeField(default=timezone.now) + date_invited = models.DateTimeField(blank=True, null=True) date_answered = models.DateTimeField(blank=True, null=True) objects = EditorialAssignmentQuerySet.as_manager() -- GitLab