From 4ceaf2db3beed63cb00d2e69d84aa67ccf782e68 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Wed, 12 Apr 2017 21:16:33 +0200
Subject: [PATCH] Fix: remove double remarks

---
 scipost/templates/scipost/_remark_li.html     |  2 +-
 .../_recommendation_author_content.html       |  3 ---
 submissions/views.py                          | 25 ++++++++-----------
 3 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/scipost/templates/scipost/_remark_li.html b/scipost/templates/scipost/_remark_li.html
index a34b3868b..bf4fc637b 100644
--- a/scipost/templates/scipost/_remark_li.html
+++ b/scipost/templates/scipost/_remark_li.html
@@ -1,4 +1,4 @@
-<li>
+<li id="{{remark.id}}">
     <div class="font-weight-bold">
         {{remark.contributor.user.first_name}} {{remark.contributor.user.last_name}} <small class="text-muted">on {{remark.date}}</small>
     </div>
diff --git a/submissions/templates/submissions/_recommendation_author_content.html b/submissions/templates/submissions/_recommendation_author_content.html
index 819107071..cfbda0714 100644
--- a/submissions/templates/submissions/_recommendation_author_content.html
+++ b/submissions/templates/submissions/_recommendation_author_content.html
@@ -11,9 +11,6 @@
     <h3 class="pb-0">Requested changes</h3>
     <p class="pl-md-3">{{recommendation.requested_changes}}</p>
 
-    <h3 class="pb-0">Remarks for Editorial College</h3>
-    <p class="pl-md-3">{{recommendation.remarks_for_editorial_college}}</p>
-
     {% block recommendation_before_recommendation %}{% endblock %}
 
     <h3 class="pb-0">Recommendation</h3>
diff --git a/submissions/views.py b/submissions/views.py
index b82aeebb2..4ffee7fa8 100644
--- a/submissions/views.py
+++ b/submissions/views.py
@@ -397,21 +397,18 @@ def add_remark(request, arxiv_identifier_w_vn_nr):
     """
     submission = get_object_or_404(Submission.objects.get_pool(request.user),
                                    arxiv_identifier_w_vn_nr=arxiv_identifier_w_vn_nr)
-    if request.method == 'POST':
-        remark_form = RemarkForm(request.POST)
-        if remark_form.is_valid():
-            remark = Remark(contributor=request.user.contributor,
-                            submission=submission,
-                            date=timezone.now(),
-                            remark=remark_form.cleaned_data['remark'])
-            remark.save()
-            return redirect(reverse('submissions:pool'))
-        else:
-            errormessage = 'The form was invalidly filled.'
-            return render(request, 'scipost/error.html', {'errormessage': errormessage})
+
+    remark_form = RemarkForm(request.POST or None)
+    if remark_form.is_valid():
+        remark = Remark(contributor=request.user.contributor,
+                        submission=submission,
+                        date=timezone.now(),
+                        remark=remark_form.cleaned_data['remark'])
+        remark.save()
+        messages.success(request, 'Your remark has succesfully been posted')
     else:
-        errormessage = 'This view can only be posted to.'
-        return render(request, 'scipost/error.html', {'errormessage': errormessage})
+        messages.warning(request, 'The form was invalidly filled.')
+    return redirect(reverse('submissions:pool'))
 
 
 @login_required
-- 
GitLab