From 29e5b68beea83b17781d379c642a71cf4d4af71f Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Fri, 21 Jul 2017 09:36:53 +0200
Subject: [PATCH] Update Report to accept blank fields

---
 .../migrations/0048_auto_20170721_0936.py     | 30 +++++++++++++++++++
 submissions/models.py                         | 29 +++++++++++++++---
 2 files changed, 55 insertions(+), 4 deletions(-)
 create mode 100644 submissions/migrations/0048_auto_20170721_0936.py

diff --git a/submissions/migrations/0048_auto_20170721_0936.py b/submissions/migrations/0048_auto_20170721_0936.py
new file mode 100644
index 000000000..657a04939
--- /dev/null
+++ b/submissions/migrations/0048_auto_20170721_0936.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.3 on 2017-07-21 07:36
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('submissions', '0047_submission_acceptance_date'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='report',
+            name='requested_changes',
+            field=models.TextField(blank=True, verbose_name='requested changes'),
+        ),
+        migrations.AlterField(
+            model_name='report',
+            name='strengths',
+            field=models.TextField(blank=True),
+        ),
+        migrations.AlterField(
+            model_name='report',
+            name='weaknesses',
+            field=models.TextField(blank=True),
+        ),
+    ]
diff --git a/submissions/models.py b/submissions/models.py
index 6aa62b532..5c8eb64ca 100644
--- a/submissions/models.py
+++ b/submissions/models.py
@@ -235,14 +235,26 @@ class RefereeInvitation(models.Model):
 ###########
 
 class Report(models.Model):
-    """ Both types of reports, invited or contributed. """
+    """
+    Both types of reports, invited or contributed.
+
+    This Report model acts as both a regular `Report` and a `FollowupReport`; A normal Report
+    should have all fields required, whereas a FollowupReport only has the `report` field as
+    a required field.
+
+    Important note!
+    Due to the construction of the two different types within a single model, it is important
+    to explicitly implement the perticular differences in for example the form used.
+    """
     status = models.CharField(max_length=16, choices=REPORT_STATUSES, default=STATUS_UNVETTED)
     submission = models.ForeignKey('submissions.Submission', related_name='reports',
                                    on_delete=models.CASCADE)
     vetted_by = models.ForeignKey('scipost.Contributor', related_name="report_vetted_by",
                                   blank=True, null=True, on_delete=models.CASCADE)
+
     # `invited' filled from RefereeInvitation objects at moment of report submission
     invited = models.BooleanField(default=False)
+
     # `flagged' if author of report has been flagged by submission authors (surname check only)
     flagged = models.BooleanField(default=False)
     date_submitted = models.DateTimeField('date submitted')
@@ -250,11 +262,13 @@ class Report(models.Model):
     qualification = models.PositiveSmallIntegerField(
         choices=REFEREE_QUALIFICATION,
         verbose_name="Qualification to referee this: I am ")
+
     # Text-based reporting
-    strengths = models.TextField()
-    weaknesses = models.TextField()
+    strengths = models.TextField(blank=True)
+    weaknesses = models.TextField(blank=True)
     report = models.TextField()
-    requested_changes = models.TextField(verbose_name="requested changes")
+    requested_changes = models.TextField(verbose_name="requested changes", blank=True)
+
     # Qualities:
     validity = models.PositiveSmallIntegerField(choices=RANKING_CHOICES, default=101)
     significance = models.PositiveSmallIntegerField(choices=RANKING_CHOICES, default=101)
@@ -276,6 +290,13 @@ class Report(models.Model):
         return (self.author.user.first_name + ' ' + self.author.user.last_name + ' on ' +
                 self.submission.title[:50] + ' by ' + self.submission.author_list[:50])
 
+    def is_followup_report(self, kip=None):
+        """
+        Check if current Report is a `FollowupReport`. A Report is a `FollowupReport` if the
+        author of the report already has a vetted report in the series of the specific Submission.
+        """
+        return self.author.report_set.accepted().filter(submission=self.submission).exists()
+
 
 ##########################
 # EditorialCommunication #
-- 
GitLab