From 7094eb346e7e3c21b27d6eb4a00e7c4d515bae0f Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Sat, 22 Apr 2017 19:21:24 +0200
Subject: [PATCH] Add refereeing overview for EdAdmin.

Need to rerun `add_groups_and_permissions` command.
---
 .../commands/add_groups_and_permissions.py    |  5 +++
 .../submissions/refereeing_overview.html      | 45 +++++++++++++++++++
 submissions/urls.py                           |  1 +
 submissions/views.py                          |  8 ++++
 4 files changed, 59 insertions(+)
 create mode 100644 submissions/templates/submissions/refereeing_overview.html

diff --git a/scipost/management/commands/add_groups_and_permissions.py b/scipost/management/commands/add_groups_and_permissions.py
index e3977e696..9d8d1f39b 100644
--- a/scipost/management/commands/add_groups_and_permissions.py
+++ b/scipost/management/commands/add_groups_and_permissions.py
@@ -132,6 +132,10 @@ class Command(BaseCommand):
             codename='can_referee',
             name='Can act as a referee and submit reports on Submissions',
             content_type=content_type)
+        can_oversee_refereeing, created = Permission.objects.get_or_create(
+            codename='can_oversee_refereeing',
+            name='Can oversee refereeing',
+            content_type=content_type)
 
         # Voting
         can_prepare_recommendations_for_voting, created = Permission.objects.get_or_create(
@@ -178,6 +182,7 @@ class Command(BaseCommand):
         EditorialAdmin.permissions.add(
             can_view_pool,
             can_assign_submissions,
+            can_oversee_refereeing,
             can_prepare_recommendations_for_voting,
             can_fix_College_decision,
             can_publish_accepted_submission,
diff --git a/submissions/templates/submissions/refereeing_overview.html b/submissions/templates/submissions/refereeing_overview.html
new file mode 100644
index 000000000..33afefb2b
--- /dev/null
+++ b/submissions/templates/submissions/refereeing_overview.html
@@ -0,0 +1,45 @@
+{% extends 'submissions/_pool_base.html' %}
+
+{% block pagetitle %}: overview of refereeing{% endblock pagetitle %}
+
+{% load scipost_extras %}
+{% load bootstrap %}
+
+{% block breadcrumb_items %}
+    {{block.super}}
+    <a href="{% url 'scipost:personal_page' %}" class="breadcrumb-item">Personal page</a>
+    <span class="breadcrumb-item">Refereeing overview</span>
+{% endblock %}
+
+{% block content %}
+
+<div class="row">
+    <div class="col-12">
+        <div class="card card-grey">
+            <div class="card-block">
+                <h1>Refereeing overview</h1>
+	    </div>
+	</div>
+    </div>
+</div>
+
+{% for submission in submissions_under_refereeing %}
+
+<hr/>
+<div class="row">
+  <div class="col-12">
+    <h3>{{ submission.title }}</h3>
+    <p>{{ submission.author_list }}</p>
+    <h4>Refereeing deadline: {{ submission.reporting_deadline }}</h4>
+    <h4>Refereeing status summary:</h4>
+    {% include 'submissions/_submission_refereeing_status.html' with submission=submission %}
+    <h3 class="mb-2">Detail of refereeing invitations:</h3>
+    {% include 'submissions/_submission_refereeing_invitations.html' with submission=submission invitations=ref_invitations %}
+  </div>
+</div>
+
+{% endfor %}
+
+
+
+{% endblock content %}
diff --git a/submissions/urls.py b/submissions/urls.py
index 042f2f393..48e208052 100644
--- a/submissions/urls.py
+++ b/submissions/urls.py
@@ -63,6 +63,7 @@ urlpatterns = [
         views.set_refereeing_deadline, name='set_refereeing_deadline'),
     url(r'^close_refereeing_round/(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})$',
         views.close_refereeing_round, name='close_refereeing_round'),
+    url(r'^refereeing_overview$', views.refereeing_overview, name='refereeing_overview'),
     url(r'^communication/(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})/(?P<comtype>[a-zA-Z]{4,})$',
         views.communication, name='communication'),
     url(r'^communication/(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})/(?P<comtype>[a-zA-Z]{4,})/(?P<referee_id>[0-9]+)$',
diff --git a/submissions/views.py b/submissions/views.py
index 99eb79e51..81375ff8b 100644
--- a/submissions/views.py
+++ b/submissions/views.py
@@ -930,6 +930,14 @@ def close_refereeing_round(request, arxiv_identifier_w_vn_nr):
                             kwargs={'arxiv_identifier_w_vn_nr': arxiv_identifier_w_vn_nr}))
 
 
+@permission_required('scipost.can_oversee_refereeing', raise_exception=True)
+def refereeing_overview(request):
+    submissions_under_refereeing = Submission.objects.filter(
+        status='EICassigned').order_by('submission_date')
+    context= {'submissions_under_refereeing': submissions_under_refereeing,}
+    return render(request, 'submissions/refereeing_overview.html', context)
+
+
 @login_required
 def communication(request, arxiv_identifier_w_vn_nr, comtype, referee_id=None):
     """
-- 
GitLab