From b6eb351ec39963ffda1706e0639824e324ecbf77 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Wed, 19 Sep 2018 09:28:41 +0200
Subject: [PATCH] Overwrite minimum number of referees per Proceedings issue

---
 proceedings/forms.py                          |  1 +
 .../0002_proceedings_minimum_referees.py      | 20 +++++++++++++++++++
 proceedings/models.py                         |  9 ++++++---
 .../partials/proceedings/summary.html         |  4 ++--
 .../proceedings/proceedings_details.html      |  1 +
 .../proceedings/proceedings_edit.html         |  2 +-
 submissions/utils.py                          |  8 ++++++++
 7 files changed, 39 insertions(+), 6 deletions(-)
 create mode 100644 proceedings/migrations/0002_proceedings_minimum_referees.py

diff --git a/proceedings/forms.py b/proceedings/forms.py
index 179305ab8..d83f9c21c 100644
--- a/proceedings/forms.py
+++ b/proceedings/forms.py
@@ -12,6 +12,7 @@ class ProceedingsForm(forms.ModelForm):
         model = Proceedings
         fields = (
             'issue',
+            'minimum_referees',
             'event_name',
             'event_suffix',
             'event_description',
diff --git a/proceedings/migrations/0002_proceedings_minimum_referees.py b/proceedings/migrations/0002_proceedings_minimum_referees.py
new file mode 100644
index 000000000..bc8873d31
--- /dev/null
+++ b/proceedings/migrations/0002_proceedings_minimum_referees.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.4 on 2018-09-19 07:11
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('proceedings', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='proceedings',
+            name='minimum_referees',
+            field=models.PositiveSmallIntegerField(blank=True, help_text='Require an explicit minimum number of referees for the default ref cycle.', null=True),
+        ),
+    ]
diff --git a/proceedings/models.py b/proceedings/models.py
index c2809ff46..abff3df6b 100644
--- a/proceedings/models.py
+++ b/proceedings/models.py
@@ -18,9 +18,12 @@ class Proceedings(TimeStampedModel):
     A Proceeding is a special kind of Journal Issue.
     """
     # Link to the actual Journal platform
-    issue = models.OneToOneField('journals.Issue', related_name='proceedings',
-                                 limit_choices_to={
-                                    'in_volume__in_journal__name': 'SciPostPhysProc'})
+    issue = models.OneToOneField(
+        'journals.Issue', related_name='proceedings',
+        limit_choices_to={'in_volume__in_journal__name': 'SciPostPhysProc'})
+    minimum_referees = models.PositiveSmallIntegerField(
+        help_text='Require an explicit minimum number of referees for the default ref cycle.',
+        blank=True, null=True)
 
     # Event the Proceedings is for
     event_name = models.CharField(max_length=256, blank=True)
diff --git a/proceedings/templates/partials/proceedings/summary.html b/proceedings/templates/partials/proceedings/summary.html
index 19ef5615c..56a2c6ea9 100644
--- a/proceedings/templates/partials/proceedings/summary.html
+++ b/proceedings/templates/partials/proceedings/summary.html
@@ -1,6 +1,6 @@
-<table class="proceedings summary">
+<table class="proceedings summary table table-borderless">
     <tr>
-        <th>Event name</th>
+        <th style="min-width: 200px;">Event name</th>
         <td>{{ proceedings.event_name }}</td>
     </tr>
     <tr>
diff --git a/proceedings/templates/proceedings/proceedings_details.html b/proceedings/templates/proceedings/proceedings_details.html
index b24d3bf14..546baa99b 100644
--- a/proceedings/templates/proceedings/proceedings_details.html
+++ b/proceedings/templates/proceedings/proceedings_details.html
@@ -11,6 +11,7 @@
 {% block content %}
     <h1>Proceedings details</h1>
     <h2 class="text-primary">{{ proceedings }}</h2>
+    <a href="{% url 'proceedings:proceedings_edit' proceedings.id %}" class="breadcrumb-item">Edit Proceedings</a>
     <br>
 
     {% include 'partials/proceedings/summary.html' with proceedings=proceedings %}
diff --git a/proceedings/templates/proceedings/proceedings_edit.html b/proceedings/templates/proceedings/proceedings_edit.html
index 6b837910a..c4245ec1d 100644
--- a/proceedings/templates/proceedings/proceedings_edit.html
+++ b/proceedings/templates/proceedings/proceedings_edit.html
@@ -5,7 +5,7 @@
 {% block breadcrumb_items %}
     {{ block.super }}
     <a href="{% url 'proceedings:proceedings' %}" class="breadcrumb-item">Proceedings</a>
-    <span class="breadcrumb-item">Edit new</span>
+    <span class="breadcrumb-item">Edit {{ proceedings.event_name }}</span>
 {% endblock %}
 
 {% block pagetitle %}: Edit Proceedings{% endblock pagetitle %}
diff --git a/submissions/utils.py b/submissions/utils.py
index d50204b33..d0251fe22 100644
--- a/submissions/utils.py
+++ b/submissions/utils.py
@@ -153,6 +153,14 @@ class BaseRefereeSubmissionCycle(BaseSubmissionCycle):
     This *abstract* submission cycle adds the specific actions needed for submission cycles
     that require referees to be invited.
     """
+
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+        if self.submission.proceedings:
+            # Check if proceedings has overwritten the `minimum_referees`
+            if self.submission.proceedings.minimum_referees:
+                self.minimum_referees = self.submission.proceedings.minimum_referees
+
     def update_status(self):
         if self.submission.status == STATUS_INCOMING and self.submission.is_resubmission:
             from .models import Submission
-- 
GitLab