From 3aecc24b2c06cec1e70ac0658f00754db9e6ba59 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Tue, 14 Nov 2017 09:52:38 +0100
Subject: [PATCH] Possible anonymous Comments

---
 comments/forms.py                             |  9 ++++--
 .../templates/comments/_add_comment_form.html |  1 +
 .../comments/_comment_categories.html         |  1 +
 .../comments/_comment_identifier.html         | 32 ++++++++++++-------
 .../templates/comments/_single_comment.html   |  6 +++-
 comments/views.py                             |  2 +-
 journals/constants.py                         |  1 -
 .../static/scipost/assets/css/_buttons.scss   | 13 ++++++--
 .../submissions/_single_public_report.html    |  4 +++
 .../templatetags/submissions_extras.py        |  1 +
 10 files changed, 51 insertions(+), 19 deletions(-)

diff --git a/comments/forms.py b/comments/forms.py
index 94b6fa62f..ac922bb92 100644
--- a/comments/forms.py
+++ b/comments/forms.py
@@ -9,15 +9,20 @@ class CommentForm(forms.ModelForm):
         model = Comment
         fields = ['is_cor', 'is_rem', 'is_que', 'is_ans', 'is_obj',
                   'is_rep', 'is_val', 'is_lit', 'is_sug',
-                  'comment_text', 'remarks_for_editors', 'file_attachment']
+                  'comment_text', 'remarks_for_editors', 'file_attachment',
+                  'anonymous']
 
     def __init__(self, *args, **kwargs):
-        super(CommentForm, self).__init__(*args, **kwargs)
+        self.is_report_comment = kwargs.pop('is_report_comment', False)
+        super().__init__(*args, **kwargs)
         self.fields['comment_text'].widget.attrs.update(
             {'placeholder': 'NOTE: only serious and meaningful Comments will be accepted.'})
         self.fields['remarks_for_editors'].widget.attrs.update(
             {'rows': 3, 'placeholder': '(these remarks will not be publicly visible)'})
 
+        if not self.is_report_comment:
+            del self.fields['anonymous']
+
 
 class VetCommentForm(forms.Form):
     action_option = forms.ChoiceField(widget=forms.RadioSelect, choices=COMMENT_ACTION_CHOICES,
diff --git a/comments/templates/comments/_add_comment_form.html b/comments/templates/comments/_add_comment_form.html
index 3a02aca52..034d32a09 100644
--- a/comments/templates/comments/_add_comment_form.html
+++ b/comments/templates/comments/_add_comment_form.html
@@ -52,6 +52,7 @@
 
       <div class="row">
           <div class="col-12">
+              {% if form.anonymous %}{{ form.anonymous|bootstrap }}{% endif %}
               <input type="submit" name="submit" value="Submit your Comment for vetting" class="btn btn-primary" id="submit-id-submit">
               <p class="mt-2" id="goodCommenter"><i>By clicking on Submit, you agree with the <a target="_blank" href="{% url 'scipost:terms_and_conditions' %}">Terms and Conditions</a>, in particular that <span class="text-danger">your identity will be attached to the Comment</span>.</i></p>
           </div>
diff --git a/comments/templates/comments/_comment_categories.html b/comments/templates/comments/_comment_categories.html
index 60b7720e7..07e3c1d53 100644
--- a/comments/templates/comments/_comment_categories.html
+++ b/comments/templates/comments/_comment_categories.html
@@ -31,4 +31,5 @@
             <div>suggestion for further work</div>
         {% endif %}
     </div>
+    <br>
 {% endif %}
diff --git a/comments/templates/comments/_comment_identifier.html b/comments/templates/comments/_comment_identifier.html
index fa6faab3c..2d518eced 100644
--- a/comments/templates/comments/_comment_identifier.html
+++ b/comments/templates/comments/_comment_identifier.html
@@ -1,25 +1,33 @@
 {% load comment_extras %}
+{% load user_groups %}
+{% load submissions_extras %}
 
-<div class="commentid" id="comment_id{{comment.id}}">
-    <h3>
-        {% if comment.is_author_reply %}Author{% endif %}
+{% is_edcol_admin request.user as is_edcol_admin %}
 
-        <a href="{{comment.author.get_absolute_url}}">{{comment.author.user.first_name}} {{comment.author.user.last_name}}</a>
-        on {{comment.date_submitted|date:'Y-m-d'}}
+<div class="commentid" id="comment_id{{ comment.id }}">
+    <h3>
+        {% if request.user.contributor and request.user.contributor == comment.core_content_object.editor_in_charge or is_edcol_admin and request.user|is_not_author_of_submission:comment.core_content_object.arxiv_identifier_w_vn_nr %}
+            <h3>{% if comment.anonymous %}(chose public anonymity) {% endif %}<a href="{{ comment.author.get_absolute_url }}">{{ comment.author.user.first_name }} {{ comment.author.user.last_name }}</a>
+              on {{ comment.date_submitted|date:'Y-m-d' }}
+            </h3>
+        {% elif comment.anonymous %}
+            Anonymous on {{comment.date_submitted|date:'Y-m-d'}}
+        {% else %}
+            {% if comment.is_author_reply %}Author{% endif %}
+            <a href="{{comment.author.get_absolute_url}}">{{comment.author.user.first_name}} {{comment.author.user.last_name}}</a>
+            on {{comment.date_submitted|date:'Y-m-d'}}
+        {% endif %}
 	{% if comment.doi_string %}&nbsp; <small>doi:  {{ comment.doi_string }}</small>{% endif %}
     </h3>
 
 
     {% if comment|is_reply_to_comment %}
-        (in reply to <a href="{{comment.content_object.get_absolute_url}}">{{comment.content_object.author.user.first_name}} {{comment.content_object.author.user.last_name}}</a> on {{comment.content_object.date_submitted|date:'Y-m-d'}})
+        (in reply to <a href="{{comment.content_object.get_absolute_url}}">{% if comment.content_object.anonymous %}Anonymous Comment{% else %}{{comment.content_object.author.user.first_name}} {{comment.content_object.author.user.last_name}}{% endif %}</a> on {{comment.content_object.date_submitted|date:'Y-m-d'}})
     {% elif comment|is_reply_to_report %}
-        (in reply to <a href="{{comment.content_object.get_absolute_url}}">
+        (in reply to
 
-        Report {{comment.content_object.report_nr}}
-        {% if not comment.content_object.anonymous %}
-            by {{comment.content_object.author.user.first_name}} {{comment.content_object.author.user.last_name}}
-        {% endif %}
+        <a href="{{comment.content_object.get_absolute_url}}">Report {{comment.content_object.report_nr}}{% if not comment.content_object.anonymous %} by {{comment.content_object.author.user.first_name}} {{comment.content_object.author.user.last_name}}{% endif %}</a>
 
-        </a> on {{comment.content_object.date_submitted|date:'Y-m-d'}})
+        on {{comment.content_object.date_submitted|date:'Y-m-d'}})
     {% endif %}
 </div>
diff --git a/comments/templates/comments/_single_comment.html b/comments/templates/comments/_single_comment.html
index ee94826ec..665503b06 100644
--- a/comments/templates/comments/_single_comment.html
+++ b/comments/templates/comments/_single_comment.html
@@ -1,6 +1,10 @@
 {% load scipost_extras %}
 {% load filename %}
 {% load file_extentions %}
+{% load user_groups %}
+
+{% is_edcol_admin request.user as is_edcol_admin %}
+{% is_editorial_college request.user as is_editorial_college %}
 
 <div class="comment">
     {% include 'comments/_comment_identifier.html' with comment=comment %}
@@ -25,7 +29,7 @@
             </p>
         {% endif %}
     </p>
-    {% if user|is_in_group:'Editorial College' or user|is_in_group:'Editorial Administrators' %}
+    {% if is_editorial_college or is_edcol_admin %}
         {% if comment.remarks_for_editors %}
             <h3>Remarks for editors:</h3>
             <p>{{ comment.remarks_for_editors|linebreaks }}</p>
diff --git a/comments/views.py b/comments/views.py
index 901131578..2de669312 100644
--- a/comments/views.py
+++ b/comments/views.py
@@ -181,7 +181,7 @@ def reply_to_report(request, report_id):
     # Verify if this is from an author:
     is_author = report.submission.authors.filter(user=request.user).exists()
 
-    form = CommentForm(request.POST or None, request.FILES or None)
+    form = CommentForm(request.POST or None, request.FILES or None, is_report_comment=True)
     if form.is_valid():
         newcomment = form.save(commit=False)
         newcomment.content_object = report
diff --git a/journals/constants.py b/journals/constants.py
index bc5554b2b..da5c678ea 100644
--- a/journals/constants.py
+++ b/journals/constants.py
@@ -14,7 +14,6 @@ SCIPOST_JOURNALS_SUBMIT = (
 # Journal closed for submission
 SCIPOST_JOURNALS_NO_SUBMIT = (
     (SCIPOST_JOURNAL_PHYSICS_SELECT, 'SciPost Physics Select'),
-    (SCIPOST_JOURNAL_PHYSICS_PROC, 'SciPost Physics Proceedings'),
 )
 
 # All allowed journals
diff --git a/scipost/static/scipost/assets/css/_buttons.scss b/scipost/static/scipost/assets/css/_buttons.scss
index 4c1d9d4bb..6abdc7c02 100644
--- a/scipost/static/scipost/assets/css/_buttons.scss
+++ b/scipost/static/scipost/assets/css/_buttons.scss
@@ -39,13 +39,13 @@
 .voting-group {
     border-radius: $card-border-radius;
     color: $scipost-darkblue;
-    box-shadow: 0 1px 0 0 $gray-600;
+    border: 1px solid $gray-600;
 
     > div {
         padding: 0.25rem 0.5rem;
         font-size: 0.8rem;
         border-radius: 0;
-        line-height: 1.25;
+        line-height: 1;
         margin: 0;
         display: inline-block;
         color: #002b49;
@@ -98,3 +98,12 @@
         }
     }
 }
+
+.category-group {
+    display: inline-block;
+    margin-bottom: 0.5rem;
+
+    > div {
+        line-height: 1.3;
+    }
+}
diff --git a/submissions/templates/submissions/_single_public_report.html b/submissions/templates/submissions/_single_public_report.html
index efdc5c514..c39fcdc22 100644
--- a/submissions/templates/submissions/_single_public_report.html
+++ b/submissions/templates/submissions/_single_public_report.html
@@ -6,6 +6,10 @@
         <h3><a href="{% url 'comments:reply_to_report' report_id=report.id %}">Reply to this Report</a> (authors only)</h3>
     {% endif %}
 
+    {% if report.comments.vetted.exists %}
+        <br>
+    {% endif %}
+
     {% for reply in report.comments.vetted %}
         {% include 'comments/_single_comment_with_link.html' with comment=reply perms=perms user=user %}
     {% endfor %}
diff --git a/submissions/templatetags/submissions_extras.py b/submissions/templatetags/submissions_extras.py
index 9cb66171d..d98be57a1 100644
--- a/submissions/templatetags/submissions_extras.py
+++ b/submissions/templatetags/submissions_extras.py
@@ -21,6 +21,7 @@ def is_viewable_by_authors(recommendation):
                                                 'accepted', 'rejected',
                                                 'published', 'withdrawn']
 
+
 @register.filter
 def user_is_referee(submission, user):
     return submission.referee_invitations.filter(referee__user=user).exists()
-- 
GitLab