From d83a328a4421fdac4447e81a6f6318d60543f320 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Fri, 21 Jul 2017 10:58:19 +0200
Subject: [PATCH] Display all None-value fields as single dash

---
 submissions/constants.py                      |  5 +-
 .../migrations/0050_auto_20170721_1042.py     | 68 +++++++++++++++++++
 .../migrations/0051_auto_20170721_1049.py     | 25 +++++++
 .../migrations/0052_auto_20170721_1057.py     | 30 ++++++++
 submissions/models.py                         |  8 +--
 5 files changed, 131 insertions(+), 5 deletions(-)
 create mode 100644 submissions/migrations/0050_auto_20170721_1042.py
 create mode 100644 submissions/migrations/0051_auto_20170721_1049.py
 create mode 100644 submissions/migrations/0052_auto_20170721_1057.py

diff --git a/submissions/constants.py b/submissions/constants.py
index 2b247ffa6..6fa524e42 100644
--- a/submissions/constants.py
+++ b/submissions/constants.py
@@ -124,6 +124,7 @@ ASSIGNMENT_REFUSAL_REASONS = (
 )
 
 REFEREE_QUALIFICATION = (
+    (None, '-'),
     (4, 'expert in this subject'),
     (3, 'very knowledgeable in this subject'),
     (2, 'knowledgeable in this subject'),
@@ -132,6 +133,7 @@ REFEREE_QUALIFICATION = (
 )
 
 QUALITY_SPEC = (
+    (None, '-'),
     (6, 'perfect'),
     (5, 'excellent'),
     (4, 'good'),
@@ -143,7 +145,7 @@ QUALITY_SPEC = (
 
 # Only values between 0 and 100 are kept, anything outside those limits is discarded.
 RANKING_CHOICES = (
-    (101, '-'),
+    (None, '-'),
     (100, 'top'),
     (80, 'high'),
     (60, 'good'),
@@ -153,6 +155,7 @@ RANKING_CHOICES = (
 )
 
 REPORT_REC = (
+    (None, '-'),
     (1, 'Publish as Tier I (top 10% of papers in this journal, qualifies as Select) NOTE: SELECT NOT YET OPEN, STARTS EARLY 2017'),
     (2, 'Publish as Tier II (top 50% of papers in this journal)'),
     (3, 'Publish as Tier III (meets the criteria of this journal)'),
diff --git a/submissions/migrations/0050_auto_20170721_1042.py b/submissions/migrations/0050_auto_20170721_1042.py
new file mode 100644
index 000000000..f81add966
--- /dev/null
+++ b/submissions/migrations/0050_auto_20170721_1042.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.3 on 2017-07-21 08:42
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+def report_101_to_none(apps, schema_editor):
+    Report = apps.get_model('submissions', 'Report')
+    for rep in Report.objects.all():
+        if rep.clarity == 101:
+            rep.clarity = None
+        if rep.originality == 101:
+            rep.originality = None
+        if rep.significance == 101:
+            rep.significance = None
+        if rep.validity == 101:
+            rep.validity = None
+        rep.save()
+    print('\nChanged all Report fields: {clarites,originality,significance,validity} with value'
+          ' `101` to `None`.')
+
+
+def report_none_to_101(apps, schema_editor):
+    Report = apps.get_model('submissions', 'Report')
+    for rep in Report.objects.all():
+        if not rep.clarity:
+            rep.clarity = 101
+        if not rep.originality:
+            rep.originality = 101
+        if not rep.significance:
+            rep.significance = 101
+        if not rep.validity:
+            rep.validity = 101
+        rep.save()
+    print('\nChanged all Report fields: {clarites,originality,significance,validity} with value'
+          ' `None` to `101`.')
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('submissions', '0049_auto_20170721_1010'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='report',
+            name='clarity',
+            field=models.PositiveSmallIntegerField(blank=True, choices=[(None, '-'), (100, 'top'), (80, 'high'), (60, 'good'), (40, 'ok'), (20, 'low'), (0, 'poor')], null=True),
+        ),
+        migrations.AlterField(
+            model_name='report',
+            name='originality',
+            field=models.PositiveSmallIntegerField(blank=True, choices=[(None, '-'), (100, 'top'), (80, 'high'), (60, 'good'), (40, 'ok'), (20, 'low'), (0, 'poor')], null=True),
+        ),
+        migrations.AlterField(
+            model_name='report',
+            name='significance',
+            field=models.PositiveSmallIntegerField(blank=True, choices=[(None, '-'), (100, 'top'), (80, 'high'), (60, 'good'), (40, 'ok'), (20, 'low'), (0, 'poor')], null=True),
+        ),
+        migrations.AlterField(
+            model_name='report',
+            name='validity',
+            field=models.PositiveSmallIntegerField(blank=True, choices=[(None, '-'), (100, 'top'), (80, 'high'), (60, 'good'), (40, 'ok'), (20, 'low'), (0, 'poor')], null=True),
+        ),
+        migrations.RunPython(report_101_to_none, report_none_to_101),
+    ]
diff --git a/submissions/migrations/0051_auto_20170721_1049.py b/submissions/migrations/0051_auto_20170721_1049.py
new file mode 100644
index 000000000..5ccf06a41
--- /dev/null
+++ b/submissions/migrations/0051_auto_20170721_1049.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.3 on 2017-07-21 08:49
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('submissions', '0050_auto_20170721_1042'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='report',
+            name='formatting',
+            field=models.SmallIntegerField(blank=True, choices=[(None, '-'), (6, 'perfect'), (5, 'excellent'), (4, 'good'), (3, 'reasonable'), (2, 'acceptable'), (1, 'below threshold'), (0, 'mediocre')], null=True, verbose_name='Quality of paper formatting'),
+        ),
+        migrations.AlterField(
+            model_name='report',
+            name='grammar',
+            field=models.SmallIntegerField(blank=True, choices=[(None, '-'), (6, 'perfect'), (5, 'excellent'), (4, 'good'), (3, 'reasonable'), (2, 'acceptable'), (1, 'below threshold'), (0, 'mediocre')], null=True, verbose_name='Quality of English grammar'),
+        ),
+    ]
diff --git a/submissions/migrations/0052_auto_20170721_1057.py b/submissions/migrations/0052_auto_20170721_1057.py
new file mode 100644
index 000000000..c89df6fc0
--- /dev/null
+++ b/submissions/migrations/0052_auto_20170721_1057.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.3 on 2017-07-21 08:57
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('submissions', '0051_auto_20170721_1049'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='eicrecommendation',
+            name='recommendation',
+            field=models.SmallIntegerField(choices=[(None, '-'), (1, 'Publish as Tier I (top 10% of papers in this journal, qualifies as Select) NOTE: SELECT NOT YET OPEN, STARTS EARLY 2017'), (2, 'Publish as Tier II (top 50% of papers in this journal)'), (3, 'Publish as Tier III (meets the criteria of this journal)'), (-1, 'Ask for minor revision'), (-2, 'Ask for major revision'), (-3, 'Reject')]),
+        ),
+        migrations.AlterField(
+            model_name='report',
+            name='qualification',
+            field=models.PositiveSmallIntegerField(choices=[(None, '-'), (4, 'expert in this subject'), (3, 'very knowledgeable in this subject'), (2, 'knowledgeable in this subject'), (1, 'generally qualified'), (0, 'not qualified')], verbose_name='Qualification to referee this: I am'),
+        ),
+        migrations.AlterField(
+            model_name='report',
+            name='recommendation',
+            field=models.SmallIntegerField(choices=[(None, '-'), (1, 'Publish as Tier I (top 10% of papers in this journal, qualifies as Select) NOTE: SELECT NOT YET OPEN, STARTS EARLY 2017'), (2, 'Publish as Tier II (top 50% of papers in this journal)'), (3, 'Publish as Tier III (meets the criteria of this journal)'), (-1, 'Ask for minor revision'), (-2, 'Ask for major revision'), (-3, 'Reject')]),
+        ),
+    ]
diff --git a/submissions/models.py b/submissions/models.py
index ee7b65f05..7209ea33b 100644
--- a/submissions/models.py
+++ b/submissions/models.py
@@ -271,13 +271,13 @@ class Report(models.Model):
     requested_changes = models.TextField(verbose_name="requested changes", blank=True)
 
     # Qualities:
-    validity = models.PositiveSmallIntegerField(choices=RANKING_CHOICES, default=101,
+    validity = models.PositiveSmallIntegerField(choices=RANKING_CHOICES,
                                                 null=True, blank=True)
-    significance = models.PositiveSmallIntegerField(choices=RANKING_CHOICES, default=101,
+    significance = models.PositiveSmallIntegerField(choices=RANKING_CHOICES,
                                                     null=True, blank=True)
-    originality = models.PositiveSmallIntegerField(choices=RANKING_CHOICES, default=101,
+    originality = models.PositiveSmallIntegerField(choices=RANKING_CHOICES,
                                                    null=True, blank=True)
-    clarity = models.PositiveSmallIntegerField(choices=RANKING_CHOICES, default=101,
+    clarity = models.PositiveSmallIntegerField(choices=RANKING_CHOICES,
                                                null=True, blank=True)
     formatting = models.SmallIntegerField(choices=QUALITY_SPEC, null=True, blank=True,
                                           verbose_name="Quality of paper formatting")
-- 
GitLab