From 757b24d4e6a950cc4c748271a1ef0e0ec4b7460a Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Sat, 19 May 2018 13:07:01 +0200
Subject: [PATCH] Seemingly OK

---
 comments/constants.py                         | 10 ++--
 comments/models.py                            | 19 +++++++-
 submissions/models.py                         | 14 +++++-
 .../submission_comments_summary_table.html    | 46 +++++++++++++++++++
 .../submission_reports_summary_table.html     | 46 +++++++++++++++++++
 .../submission_editorial_information.html     | 10 ++--
 .../submissions/pool/editorial_page.html      | 46 ++++++++++++-------
 .../submissions/submission_detail.html        | 10 +++-
 8 files changed, 171 insertions(+), 30 deletions(-)
 create mode 100644 submissions/templates/partials/submissions/pool/submission_comments_summary_table.html
 create mode 100644 submissions/templates/partials/submissions/pool/submission_reports_summary_table.html

diff --git a/comments/constants.py b/comments/constants.py
index 3a4a26e69..eb9075628 100644
--- a/comments/constants.py
+++ b/comments/constants.py
@@ -12,11 +12,11 @@ STATUS_UNCLEAR = -1
 STATUS_INCORRECT = -2
 STATUS_NOT_USEFUL = -3
 COMMENT_STATUS = (
-    (STATUS_VETTED, 'vetted'),
-    (STATUS_PENDING, 'not yet vetted (pending)'),
-    (STATUS_UNCLEAR, 'rejected (unclear)'),
-    (STATUS_INCORRECT, 'rejected (incorrect)'),
-    (STATUS_NOT_USEFUL, 'rejected (not useful)'),
+    (STATUS_VETTED, 'Vetted'),
+    (STATUS_PENDING, 'Not yet vetted (pending)'),
+    (STATUS_UNCLEAR, 'Rejected (unclear)'),
+    (STATUS_INCORRECT, 'Rejected (incorrect)'),
+    (STATUS_NOT_USEFUL, 'Rejected (not useful)'),
 )
 
 COMMENT_CATEGORIES = (
diff --git a/comments/models.py b/comments/models.py
index 23ceb5218..f822ca021 100644
--- a/comments/models.py
+++ b/comments/models.py
@@ -17,7 +17,9 @@ from scipost.models import Contributor
 from commentaries.constants import COMMENTARY_PUBLISHED
 
 from .behaviors import validate_file_extension, validate_max_file_size
-from .constants import COMMENT_STATUS, STATUS_PENDING
+from .constants import (
+    COMMENT_STATUS, STATUS_PENDING, STATUS_UNCLEAR, STATUS_INCORRECT, STATUS_NOT_USEFUL,
+    STATUS_VETTED)
 from .managers import CommentQuerySet
 
 
@@ -126,6 +128,21 @@ class Comment(TimeStampedModel):
             else:
                 raise Exception
 
+    @property
+    def is_vetted(self):
+        """Check if Comment is vetted."""
+        return self.status == STATUS_VETTED
+
+    @property
+    def is_unvetted(self):
+        """Check if Comment is awaiting vetting."""
+        return self.status == STATUS_PENDING
+
+    @property
+    def is_rejected(self):
+        """Check if Comment is rejected."""
+        return self.status in [STATUS_UNCLEAR, STATUS_INCORRECT, STATUS_NOT_USEFUL]
+
     def create_doi_label(self):
         self.doi_label = 'SciPost.Comment.' + str(self.id)
         self.save()
diff --git a/submissions/models.py b/submissions/models.py
index d174bbe7f..e3b917bda 100644
--- a/submissions/models.py
+++ b/submissions/models.py
@@ -20,7 +20,8 @@ from .constants import (
     SUBMISSION_STATUS, REPORT_STATUSES, STATUS_UNVETTED, STATUS_INCOMING,
     SUBMISSION_CYCLES, CYCLE_DEFAULT, CYCLE_SHORT, STATUS_RESUBMITTED, DECISION_FIXED,
     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)
+    REPORT_NORMAL, STATUS_DRAFT, STATUS_VETTED, EIC_REC_STATUSES, VOTING_IN_PREP,
+    STATUS_INCORRECT, STATUS_UNCLEAR, STATUS_NOT_USEFUL, STATUS_NOT_ACADEMIC)
 from .managers import (
     SubmissionQuerySet, EditorialAssignmentQuerySet, EICRecommendationQuerySet, ReportQuerySet,
     SubmissionEventQuerySet, RefereeInvitationQuerySet, EditorialCommunicationQueryset)
@@ -566,6 +567,17 @@ class Report(SubmissionRelatedObjectMixin, models.Model):
         """Return if Report is publicly available."""
         return self.status == STATUS_VETTED
 
+    @property
+    def is_unvetted(self):
+        """Return if Report is awaiting vetting."""
+        return self.status == STATUS_UNVETTED
+
+    @property
+    def is_rejected(self):
+        """Return if Report is rejected."""
+        return self.status in [
+            STATUS_INCORRECT, STATUS_UNCLEAR, STATUS_NOT_USEFUL, STATUS_NOT_ACADEMIC]
+
     @property
     def notification_name(self):
         """Return string representation of this Report as shown in Notifications."""
diff --git a/submissions/templates/partials/submissions/pool/submission_comments_summary_table.html b/submissions/templates/partials/submissions/pool/submission_comments_summary_table.html
new file mode 100644
index 000000000..22831e745
--- /dev/null
+++ b/submissions/templates/partials/submissions/pool/submission_comments_summary_table.html
@@ -0,0 +1,46 @@
+<table class="table bg-light table-hover v-center">
+    <thead>
+        <tr>
+            <th>Referee</th>
+            <th>Status</th>
+            <th>Recommendation</th>
+            <th>Type</th>
+            <th>Date</th>
+        </tr>
+    </thead>
+    <tbody>
+        {% for comment in submission.comments.all %}
+            <tr>
+                <td>
+                    {{ comment.author }}
+                    {% if comment.anonymous %}
+                        <br>
+                        <b><span class="text-danger">Author chose public anonymity</span></b>
+                    {% endif %}
+                </td>
+                <td>
+                    {% if comment.is_vetted %}
+                        <i class="fa fa-check-circle text-success"></i>
+                    {% elif comment.is_rejected %}
+                        <i class="fa fa-times-circle text-danger"></i>
+                    {% endif %}
+                    {{ comment.get_status_display }}
+                    {% if comment.is_unvetted %}
+                        <br>
+                        <a href="{% url 'comments:vet_submitted_comment' comment.id %}">Vet this Comment here</a>
+                    {% elif comment.is_vetted %}
+                        <br>
+                        <a href="{{ comment.get_absolute_url }}">View full Comment here</a>
+                    {% endif %}
+                </td>
+                <td><em>{{ comment.comment_text|truncatewords:6 }}</em></td>
+                <td>{% if comment.is_author_reply %}Author Reply{% else %}Comment{% endif %}</td>
+                <td>{{ comment.date_submitted }}</td>
+            </tr>
+        {% empty %}
+            <tr>
+                <td class="text-center py-3" colspan="5">There are no Comments yet.</td>
+            </tr>
+        {% endfor %}
+    </tbody>
+</table>
diff --git a/submissions/templates/partials/submissions/pool/submission_reports_summary_table.html b/submissions/templates/partials/submissions/pool/submission_reports_summary_table.html
new file mode 100644
index 000000000..7661eed38
--- /dev/null
+++ b/submissions/templates/partials/submissions/pool/submission_reports_summary_table.html
@@ -0,0 +1,46 @@
+<table class="table bg-light table-hover v-center">
+    <thead>
+        <tr>
+            <th>Referee</th>
+            <th>Status</th>
+            <th>Recommendation</th>
+            <th>Type</th>
+            <th>Date</th>
+        </tr>
+    </thead>
+    <tbody>
+        {% for report in submission.reports.all %}
+            <tr>
+                <td>
+                    {{ report.author }}
+                    {% if report.anonymous %}
+                        <br>
+                        <b><span class="text-danger">Author chose public anonymity</span></b>
+                    {% endif %}
+                </td>
+                <td>
+                    {% if report.is_vetted %}
+                        <i class="fa fa-check-circle text-success"></i>
+                    {% elif report.is_rejected %}
+                        <i class="fa fa-times-circle text-danger"></i>
+                    {% endif %}
+                    {{ report.get_status_display }}
+                    {% if report.is_unvetted %}
+                        <br>
+                        <a href="{% url 'submissions:vet_submitted_report' report.id %}">Vet this Report here</a>
+                    {% elif report.is_vetted %}
+                        <br>
+                        <a href="{{ report.get_absolute_url }}">View full Report here</a>
+                    {% endif %}
+                </td>
+                <td>{{ report.get_recommendation_display }}</td>
+                <td>{% if report.invited %}Invited Report{% else %}Contributed Report{% endif %}</td>
+                <td>{{ report.date_submitted }}</td>
+            </tr>
+        {% empty %}
+            <tr>
+                <td class="text-center py-3" colspan="5">There are no Reports yet.</td>
+            </tr>
+        {% endfor %}
+    </tbody>
+</table>
diff --git a/submissions/templates/partials/submissions/submission_editorial_information.html b/submissions/templates/partials/submissions/submission_editorial_information.html
index c873fbd2c..67390baf8 100644
--- a/submissions/templates/partials/submissions/submission_editorial_information.html
+++ b/submissions/templates/partials/submissions/submission_editorial_information.html
@@ -3,13 +3,15 @@
 <h3 class="highlight">Editorial information</h3>
 <a href="javascript:;" class="btn btn-default mb-2" data-toggle="toggle" data-target="#editorialinformation">Show/hide editorial information</a>
 
-<div id="editorialinformation" class="mt-2">
+<div id="editorialinformation" class="mt-2" style="display:none;">
     <div class="mb-4">
-        <h3>Status summary:</h3>
-
-        {% if submission.editor_in_charge and request.user.contributor == submission.editor_in_charge %}
+        {% if submission.editor_in_charge == request.user.contributor %}
             <p><strong>You are the Editor-in-charge, go to the <a href="{% url 'submissions:editorial_page' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">Editorial Page</a> to take editorial actions.</strong></p>
+        {% elif perms.scipost.can_oversee_refereeing and not is_author and not is_author_unchecked %}
+            <p><strong>You are Editorial Administrator. See <a href="{% url 'submissions:editorial_page' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">Editorial Page</a> for detailed information.</strong></p>
         {% endif %}
+
+        <h3>Status summary:</h3>
         <table class="table table-borderless">
             <tr>
                 <td>Submission status:</td>
diff --git a/submissions/templates/submissions/pool/editorial_page.html b/submissions/templates/submissions/pool/editorial_page.html
index 9eafee976..bd0181168 100644
--- a/submissions/templates/submissions/pool/editorial_page.html
+++ b/submissions/templates/submissions/pool/editorial_page.html
@@ -22,7 +22,7 @@
         <h3>by {{submission.author_list}}</h3>
 
         <div class="ml-2 mt-2">
-            <h3>- Go to the <a href="{% url 'submissions:submission' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">Submissions Page</a> to view Reports and Comments</h3>
+            <h3>- Go to the <a href="{% url 'submissions:submission' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">Submission Page</a> to view Reports and Comments</h3>
         </div>
 
         <h3 class="mt-4">Submission summary</h3>
@@ -67,14 +67,10 @@
     </div>
 </div>
 
-
-<div class="card card-grey my-4">
-    <div class="card-body">
-        <h2 class="card-title">Editorial Workflow</h2>
-        <a href="{% url 'submissions:editorial_workflow' %}">How-to guide: summary of the editorial workflow</a>
-    </div>
+<div class="py-2 mb-2">
+    <h2 class="highlight">Editorial Workflow</h2>
+    <a href="{% url 'submissions:editorial_workflow' %}">How-to guide: summary of the editorial workflow</a>
 </div>
-
 <div class="row"><!-- Status -->
     <div class="col">
         <h3>Editorial status:</h3>
@@ -83,12 +79,19 @@
                 <td>Submission status:</td>
                 <td><span class="label label-secondary">{{ submission.get_status_display }}</span></td>
             </tr>
-            {% if submission.eicrecommendations.active.first %}
-                <tr>
-                    <td>Recommendation status:</td>
-                    <td><span class="label label-secondary">{{ submission.eicrecommendations.active.first.get_status_display }}</span></td>
-                </tr>
-            {% endif %}
+            <tr>
+                <td>Recommendation status:</td>
+                <td>
+                    {% if submission.eicrecommendations.active.first %}
+                        <span class="label label-secondary">{{ submission.eicrecommendations.active.first.get_status_display }}</span>
+                    {% else %}
+                        <span class="label label-secondary mb-1">No Editorial Recommendation is formulated yet.</span>
+                        {% if submission.eic_recommendation_required %}
+                            <br><a href="{% url 'submissions:eic_recommendation' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">Formulate an Editorial Recommendation here.</a>
+                        {% endif %}
+                    {% endif %}
+                </td>
+            </tr>
             <tr>
                 <td>Refereeing cycle:</td>
                 <td>{{ submission.get_refereeing_cycle_display }}</td>
@@ -183,7 +186,9 @@
         <div class="row">
             <div class="col-12">
                 <h3>Refereeing status summary:</h3>
+
                 {% include 'partials/submissions/pool/referee_invitations_status.html' with submission=submission %}
+                <a href="#reports-summary">View Reports and Comments on this Submission</a>
             </div>
         </div>
 
@@ -284,7 +289,7 @@
                                 {% if submission.eicrecommendations.last %}
                                     <a href="{% url 'submissions:reformulate_eic_recommendation' submission.arxiv_identifier_w_vn_nr %}">Reformulate Editorial Recommendation</a>
                                 {% else %}
-                                    <a href="{% url 'submissions:eic_recommendation' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">Formulate an Editorial Recommendation</a>
+                                    <a href="{% url 'submissions:eic_recommendation' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">Formulate an Editorial Recommendation.</a>
                                 {% endif %}
                                 <p>
                                     If you recommend revisions, this will be communicated directly to the Authors, who will be asked to resubmit.
@@ -304,7 +309,13 @@
 {% endif %}
 
 {% if full_access %}
-    <h2 class="mt-3">Communications</h2>
+    <h3 class="mt-3 mb-2" id="reports-summary">Reports</h3>
+    {% include 'partials/submissions/pool/submission_reports_summary_table.html' with submission=submission %}
+
+    <h3 class="mt-3 mb-2">Comments</h3>
+    {% include 'partials/submissions/pool/submission_comments_summary_table.html' with submission=submission %}
+
+    <h3 class="mt-3">Communications</h3>
     <ul>
         {% if submission.editor_in_charge == request.user.contributor %}
             <li><a href="{% url 'submissions:communication' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr comtype='EtoA' %}">Draft and send a communication with the submitting Author</a></li>
@@ -329,8 +340,9 @@
         </div>
     </div>
 
-    <h2 class="mt-3">Events</h2>
+    <h3 class="mt-3">Events</h3>
     {% include 'partials/submissions/submission_events.html' with events=submission.events.for_eic %}
+
 {% endif %}
 
 <div class="mb-5"></div>
diff --git a/submissions/templates/submissions/submission_detail.html b/submissions/templates/submissions/submission_detail.html
index 99e0513f7..37e4b2fff 100644
--- a/submissions/templates/submissions/submission_detail.html
+++ b/submissions/templates/submissions/submission_detail.html
@@ -104,7 +104,7 @@
     <div class="col-12">
         <h3 class="highlight">Actions</h3>
         <ul>
-            {% if submission.is_open_for_reporting and perms.scipost.can_referee %}
+            {% if submission.is_open_for_reporting or 1 and perms.scipost.can_referee %}
                 {% if not is_author and not is_author_unchecked %}
                     <li>
                         <h3><a href="{% url 'submissions:submit_report' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">{% if unfinished_report_for_user %}Finish your report{% else %}Contribute a Report{% endif %}</a></h3>
@@ -117,6 +117,10 @@
                             The system flagged you as a potential author of this Submission. Please <a href="{% url 'scipost:claim_authorships' %}">clarify this here</a>. You are not allowed to contributor a Report until your authorship has been verified.
                         </div>
                     </li>
+                {% elif is_author %}
+                    <li>
+                        <a href="javascript:;" disabled>Contribute a Report</a> <br><span class="text-danger">You are a verified author. Therefore, you can not submit a Report.</span>.
+                    </li>
                 {% endif %}
             {% elif unfinished_report_for_user %}
                 <li><i class="fa fa-exclamation"></i> You have an unfinished report for this submission. You can <a href="{% url 'submissions:submit_report' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">finish your report here</a>.</li>
@@ -130,7 +134,9 @@
             {% else %}
                 <li>Commenting on this Submission is closed.</li>
             {% endif %}
-
+            {% if submission.editor_in_charge == request.user.contributor %}
+                <li><a href="{% url 'submissions:editorial_page' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}">Go to the Editorial Page</a></li>
+            {% endif %}
             {% if perms.scipost.can_manage_reports %}
                 <li>
                     <a href="{% url 'submissions:treated_submission_pdf_compile' submission.arxiv_identifier_w_vn_nr %}">Update the Refereeing Package pdf</a>
-- 
GitLab