From 4d6026ed29bc86a190bdb53218c08e5e04a5c917 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Thu, 17 May 2018 22:45:54 +0200
Subject: [PATCH] Start 1.

---
 .../submission_author_information.html        |  95 +++++++++++++++
 .../submission_editorial_information.html     | 111 ++++++++++++++++++
 .../submissions/submission_detail.html        |  54 +++------
 submissions/views.py                          |   9 +-
 4 files changed, 226 insertions(+), 43 deletions(-)
 create mode 100644 submissions/templates/partials/submissions/submission_author_information.html
 create mode 100644 submissions/templates/partials/submissions/submission_editorial_information.html

diff --git a/submissions/templates/partials/submissions/submission_author_information.html b/submissions/templates/partials/submissions/submission_author_information.html
new file mode 100644
index 000000000..ed192e918
--- /dev/null
+++ b/submissions/templates/partials/submissions/submission_author_information.html
@@ -0,0 +1,95 @@
+{% load bootstrap %}
+
+<h2 class="highlight">Author information</h2>
+<a href="javascript:;" class="btn btn-default mb-2" data-toggle="toggle" data-target="#authorinformation">Show/hide author information</a>
+
+<div id="authorinformation" class="mt-2">
+    <div class="mb-4">
+        <h3>Status summary:</h3>
+        <table class="table table-borderless">
+            <tr>
+                <td>Submission status:</td>
+                <td><span class="label label-secondary">{{ submission.get_status_display }}</span></td>
+            </tr>
+            <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">No Editorial Recommendation is formulated yet.</span>
+                    {% endif %}
+                </td>
+            </tr>
+            <tr>
+                <td>Submission is publicly available:</td>
+                <td>
+                    {% if submission.visible_public %}
+                        <i class="fa fa-check-circle text-success" aria-hidden="true"></i>
+                        <span class="text-muted">Available in public pages and search results.</span>
+                    {% else %}
+                        <i class="fa fa-times-circle text-danger" aria-hidden="true"></i>
+                        <span class="text-muted">Only available for editors and authors.</span>
+                    {% endif %}
+                </td>
+            </tr>
+            {% if submission.publication and submission.publication.is_published %}
+                <tr>
+                    <td>Submission is published as:</td>
+                    <td>
+                        <a href="{{submission.publication.get_absolute_url}}">
+                        {% if submission.publication.in_issue %}
+                            {{submission.publication.in_issue.in_volume.in_journal.abbreviation_citation}} <strong>{{submission.publication.in_issue.in_volume.number}}</strong>, {{submission.publication.get_paper_nr}}
+                        {% else %}
+                            {{submission.publication.in_journal.abbreviation_citation}}, {{submission.publication.paper_nr}}
+                        {% endif %}
+                        ({{submission.publication.publication_date|date:'Y'}})</a>
+                    </td>
+                </tr>
+            {% endif %}
+        </table>
+    </div>
+
+    <div class="mb-4">
+        <h3 class="mb-2">Editorial Recommendation:</h3>
+        {% for recommendation in submission.eicrecommendations.active %}
+            {% include 'partials/submissions/recommendation_author_content.html' with recommendation=recommendation %}
+        {% empty %}
+            No Editorial Recommendation is formulated yet.
+        {% endfor %}
+    </div>
+
+    <div class="mb-4">
+        <h3>Events:</h3>
+        <div id="eventslist">
+            {% include 'partials/submissions/submission_events.html' with events=submission.events.for_author %}
+        </div>
+    </div>
+
+
+    <div class="mb-4" id="proofsslist">
+        <h3>Proofs:</h3>
+        <ul class="list-group list-group-flush events-list">
+            {% for proofs in submission.production_stream.proofs.for_authors %}
+                <li>
+                    <a href="{{ proofs.get_absolute_url }}" target="_blank">Download version {{ proofs.version }}</a> &middot; uploaded: {{ proofs.created|date:"DATE_FORMAT" }} &middot;
+                    status: <span class="label label-secondary label-sm">{{ proofs.get_status_display }}</span>
+                    {% if proofs.status == 'accepted_sup' or proofs.status == 'sent' %}
+                        {% if proofs_decision_form and is_author %}
+                            <h3 class="mb-0 mt-2">Please advise the Production Team on your findings on Proofs version {{ proofs.version }}</h3>
+                            <form method="post" enctype="multipart/form-data" action="{% url 'production:author_decision' proofs.slug %}" class="my-2">
+                                {% csrf_token %}
+                                {{ proofs_decision_form|bootstrap }}
+                                <input class="btn btn-primary btn-sm" type="submit" value="Submit">
+                            </form>
+                        {% endif %}
+                    {% endif %}
+                </li>
+            {% empty %}
+                <li class="list-group-item">No proofs are available yet.</li>
+            {% endfor %}
+        </ul>
+    </div>
+</div>
+
+<hr class="divider">
diff --git a/submissions/templates/partials/submissions/submission_editorial_information.html b/submissions/templates/partials/submissions/submission_editorial_information.html
new file mode 100644
index 000000000..fde63531b
--- /dev/null
+++ b/submissions/templates/partials/submissions/submission_editorial_information.html
@@ -0,0 +1,111 @@
+{% load bootstrap %}
+
+<h2 class="highlight">Editorial information</h2>
+<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 class="mb-4">
+        <h3>Status summary:</h3>
+
+        {% if submission.editor_in_charge and request.user.contributor == submission.editor_in_charge %}
+            <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>
+        {% endif %}
+        <table class="table table-borderless">
+            <tr>
+                <td>Submission status:</td>
+                <td><span class="label label-secondary">{{ submission.get_status_display }}</span></td>
+            </tr>
+            <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">No Editorial Recommendation is formulated yet.</span>
+                    {% endif %}
+                </td>
+            </tr>
+            <tr>
+                <td>Submission is publicly available:</td>
+                <td>
+                    {% if submission.visible_public %}
+                        <i class="fa fa-check-circle text-success" aria-hidden="true"></i>
+                        <span class="text-muted">Available in public pages and search results.</span>
+                    {% else %}
+                        <i class="fa fa-times-circle text-danger" aria-hidden="true"></i>
+                        <span class="text-muted">Only available for editors and authors.</span>
+                    {% endif %}
+                </td>
+            </tr>
+            <tr>
+                <td>Submission is current version:</td>
+                <td>
+                    {% if submission.is_current %}
+                        <i class="fa fa-check-circle text-success" aria-hidden="true"></i>
+                        <span class="text-muted">This is the current version.</span>
+                    {% else %}
+                        <i class="fa fa-times-circle text-danger" aria-hidden="true"></i>
+                        <span class="text-muted">This is not the current version.</span>
+                    {% endif %}
+                </td>
+            </tr>
+            {% if submission.publication and submission.publication.is_published %}
+                <tr>
+                    <td>Submission is published as:</td>
+                    <td>
+                        <a href="{{submission.publication.get_absolute_url}}">
+                        {% if submission.publication.in_issue %}
+                            {{submission.publication.in_issue.in_volume.in_journal.abbreviation_citation}} <strong>{{submission.publication.in_issue.in_volume.number}}</strong>, {{submission.publication.get_paper_nr}}
+                        {% else %}
+                            {{submission.publication.in_journal.abbreviation_citation}}, {{submission.publication.paper_nr}}
+                        {% endif %}
+                        ({{submission.publication.publication_date|date:'Y'}})</a>
+                    </td>
+                </tr>
+            {% endif %}
+        </table>
+    </div>
+
+    <div class="mb-4">
+        <h3 class="mb-2">Editorial Recommendation:</h3>
+        {% for recommendation in submission.eicrecommendations.active %}
+            {% include 'partials/submissions/recommendation_author_content.html' with recommendation=recommendation %}
+        {% empty %}
+            No Editorial Recommendation is formulated yet.
+        {% endfor %}
+    </div>
+
+    <div class="mb-4">
+        <h3>Events:</h3>
+        <div id="eventslist">
+            {% include 'partials/submissions/submission_events.html' with events=submission.events.for_author %}
+        </div>
+    </div>
+
+
+    <div class="mb-4" id="proofsslist">
+        <h3>Proofs:</h3>
+        <ul class="list-group list-group-flush events-list">
+            {% for proofs in submission.production_stream.proofs.for_authors %}
+                <li>
+                    <a href="{{ proofs.get_absolute_url }}" target="_blank">Download version {{ proofs.version }}</a> &middot; uploaded: {{ proofs.created|date:"DATE_FORMAT" }} &middot;
+                    status: <span class="label label-secondary label-sm">{{ proofs.get_status_display }}</span>
+                    {% if proofs.status == 'accepted_sup' or proofs.status == 'sent' %}
+                        {% if proofs_decision_form and is_author %}
+                            <h3 class="mb-0 mt-2">Please advise the Production Team on your findings on Proofs version {{ proofs.version }}</h3>
+                            <form method="post" enctype="multipart/form-data" action="{% url 'production:author_decision' proofs.slug %}" class="my-2">
+                                {% csrf_token %}
+                                {{ proofs_decision_form|bootstrap }}
+                                <input class="btn btn-primary btn-sm" type="submit" value="Submit">
+                            </form>
+                        {% endif %}
+                    {% endif %}
+                </li>
+            {% empty %}
+                <li class="list-group-item">No proofs are available yet.</li>
+            {% endfor %}
+        </ul>
+    </div>
+</div>
+
+<hr class="divider">
diff --git a/submissions/templates/submissions/submission_detail.html b/submissions/templates/submissions/submission_detail.html
index f42474d5a..f14586d26 100644
--- a/submissions/templates/submissions/submission_detail.html
+++ b/submissions/templates/submissions/submission_detail.html
@@ -27,7 +27,13 @@
 
         <div class="pl-2">
             {% if submission.publication and submission.publication.is_published %}
-                <h3>- Published as <a href="{{submission.publication.get_absolute_url}}">{{submission.publication.in_issue.in_volume.in_journal.abbreviation_citation}} <strong>{{submission.publication.in_issue.in_volume.number}}</strong>, {{submission.publication.get_paper_nr}} ({{submission.publication.publication_date|date:'Y'}})</a></h3>
+                <h3>- Published as <a href="{{submission.publication.get_absolute_url}}">
+                    {% if submission.publication.in_issue %}
+                        {{submission.publication.in_issue.in_volume.in_journal.abbreviation_citation}} <strong>{{submission.publication.in_issue.in_volume.number}}</strong>, {{submission.publication.get_paper_nr}}
+                    {% else %}
+                        {{submission.publication.in_journal.abbreviation_citation}}, {{submission.publication.paper_nr}}
+                    {% endif %}
+                    ({{submission.publication.publication_date|date:'Y'}})</a></h3>
             {% endif %}
 
 
@@ -74,46 +80,20 @@
 
 </div>
 
-{% if can_read_editorial_information or is_author %}
-    {% for recommendation in recommendations %}
-        {# Use this crazy logic block because of the totally unclear template logic if one tries to merge this #}
-        {% if is_author and recommendation|is_viewable_by_authors %}
-            {% include 'partials/submissions/recommendation_author_content.html' with recommendation=recommendation %}
-        {% elif can_read_editorial_information %}
-            {% include 'partials/submissions/recommendation_author_content.html' with recommendation=recommendation %}
-        {% endif %}
-    {% endfor %}
+{% if is_author %}
+    {% include 'partials/submissions/submission_author_information.html' with submission=submission %}
+{% elif is_author_unchecked %}
 
-    <div class="mb-4">
-        <h3>Events</h3>
-        <div id="eventslist">
-            {% include 'partials/submissions/submission_events.html' with events=submission.events.for_author %}
-        </div>
+    <div class="border border-warning py-2 px-3 mb-4">
+        <h3>Advise</h3>
+        The system flagged you as a potential author of this Submission.
+        Please go to your <a href="{% url 'scipost:personal_page' %}">personal page</a>
+        under the Submissions tab to clarify this.
     </div>
 {% endif %}
 
-{% if is_author or perms.scipost.can_oversee_refereeing %}
-    <div class="mb-4" id="proofsslist">
-        <h3>Proofs</h3>
-        <ul>
-            {% for proofs in submission.production_stream.proofs.for_authors %}
-                <li>
-                    <a href="{{ proofs.get_absolute_url }}" target="_blank">Download version {{ proofs.version }}</a> &middot; uploaded: {{ proofs.created|date:"DATE_FORMAT" }} &middot;
-                    status: <span class="label label-secondary label-sm">{{ proofs.get_status_display }}</span>
-                    {% if proofs.status == 'accepted_sup' or proofs.status == 'sent' %}
-                        {% if proofs_decision_form and is_author %}
-                            <h3 class="mb-0 mt-2">Please advise the Production Team on your findings on Proofs version {{ proofs.version }}</h3>
-                            <form method="post" enctype="multipart/form-data" action="{% url 'production:author_decision' proofs.slug %}" class="my-2">
-                                {% csrf_token %}
-                                {{ proofs_decision_form|bootstrap }}
-                                <input class="btn btn-primary btn-sm" type="submit" value="Submit">
-                            </form>
-                        {% endif %}
-                    {% endif %}
-                </li>
-            {% endfor %}
-        </ul>
-    </div>
+{% if can_read_editorial_information %}
+    {% include 'partials/submissions/submission_editorial_information.html' with submission=submission %}
 {% endif %}
 
 {% if perms.scipost.can_submit_comments %}
diff --git a/submissions/views.py b/submissions/views.py
index 587d49fc9..27562a478 100644
--- a/submissions/views.py
+++ b/submissions/views.py
@@ -221,7 +221,7 @@ def submission_detail(request, arxiv_identifier_w_vn_nr):
                 contributor__user=request.user).exists():
                     raise Http404
 
-    if submission.open_for_commenting and request.user.perms.has_perms('scipost.can_submit_comments'):
+    if submission.open_for_commenting and request.user.has_perms('scipost.can_submit_comments'):
         context['comment_form'] = CommentForm()
 
     invited_reports = submission.reports.accepted().invited()
@@ -231,7 +231,7 @@ def submission_detail(request, arxiv_identifier_w_vn_nr):
 
     # User is referee for the Submission
     if request.user.is_authenticated:
-        invitations = submission.referee_invitations.filter(referee__user=request.user)
+        context['invitations'] = submission.referee_invitations.filter(referee__user=request.user)
 
         # User may read eg. Editorial Recommendations if he/she is in the Pool.
         context['can_read_editorial_information'] = submission.fellows.filter(
@@ -242,9 +242,7 @@ def submission_detail(request, arxiv_identifier_w_vn_nr):
             context['can_read_editorial_information'] = request.user.has_perm(
                 'can_oversee_refereeing')
 
-    else:
-        invitations = None
-    if invitations:
+    if 'invitations' in context and context['invitations']:
         context['communication'] = submission.editorial_communications.for_referees().filter(
             referee__user=request.user)
 
@@ -260,7 +258,6 @@ def submission_detail(request, arxiv_identifier_w_vn_nr):
         'author_replies': author_replies,
         'is_author': is_author,
         'is_author_unchecked': is_author_unchecked,
-        'invitations': invitations,
     })
     return render(request, 'submissions/submission_detail.html', context)
 
-- 
GitLab