From 87b83d1e7b2c3fefd6e98e1824e607e3a309b39e Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Mon, 25 Jan 2016 10:58:38 +0100
Subject: [PATCH] Simplify logic for no vetting to be done: remove no_...
 templates

---
 .../no_commentary_req_to_vet.html             | 11 -------
 .../commentaries/vet_commentary_requests.html |  6 ++++
 commentaries/urls.py                          |  2 +-
 commentaries/views.py                         | 14 ++++-----
 .../comments/no_author_reply_to_vet.html      | 11 -------
 .../templates/comments/no_comment_to_vet.html | 11 -------
 .../comments/vet_author_replies.html          |  6 ++++
 comments/urls.py                              |  4 +--
 comments/views.py                             | 30 +++++++++----------
 .../scipost/no_registration_req_to_vet.html   | 11 -------
 .../scipost/vet_registration_requests.html    |  5 ++++
 scipost/urls.py                               |  2 +-
 scipost/views.py                              | 14 ++++-----
 .../no_new_submission_to_process.html         | 11 -------
 .../submissions/no_report_to_vet.html         | 11 -------
 .../submissions/process_new_submissions.html  |  6 ++++
 .../submissions/vet_submitted_reports.html    |  6 ++++
 submissions/urls.py                           |  4 +--
 submissions/views.py                          | 28 ++++++++---------
 19 files changed, 78 insertions(+), 115 deletions(-)
 delete mode 100644 commentaries/templates/commentaries/no_commentary_req_to_vet.html
 delete mode 100644 comments/templates/comments/no_author_reply_to_vet.html
 delete mode 100644 comments/templates/comments/no_comment_to_vet.html
 delete mode 100644 scipost/templates/scipost/no_registration_req_to_vet.html
 delete mode 100644 submissions/templates/submissions/no_new_submission_to_process.html
 delete mode 100644 submissions/templates/submissions/no_report_to_vet.html

diff --git a/commentaries/templates/commentaries/no_commentary_req_to_vet.html b/commentaries/templates/commentaries/no_commentary_req_to_vet.html
deleted file mode 100644
index 0c1be3813..000000000
--- a/commentaries/templates/commentaries/no_commentary_req_to_vet.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends 'scipost/base.html' %}
-
-{% block pagetitle %}: vet Commentary requests{% endblock pagetitle %}
-
-{% block bodysup %}
-
-<section>
-  <h1>There are no SciPost Commentary Page requests for you to vet.</h1>
-</section>
-
-{% endblock bodysup %}
diff --git a/commentaries/templates/commentaries/vet_commentary_requests.html b/commentaries/templates/commentaries/vet_commentary_requests.html
index 94011f45f..96413a544 100644
--- a/commentaries/templates/commentaries/vet_commentary_requests.html
+++ b/commentaries/templates/commentaries/vet_commentary_requests.html
@@ -5,6 +5,11 @@
 {% block bodysup %}
 
 <section>
+  {% if not commentary_to_vet %}
+  <h1>There are no Commentary Page requests for you to vet.</h1>
+
+  {% else %}
+
   <h1>SciPost Commentary Page request to vet:</h1>
 
   <br>
@@ -30,6 +35,7 @@
     </div>
   </div>
 
+  {% endif %}
 </section>
 
 {% endblock bodysup %}
diff --git a/commentaries/urls.py b/commentaries/urls.py
index 235cfde58..b6794e5ec 100644
--- a/commentaries/urls.py
+++ b/commentaries/urls.py
@@ -9,6 +9,6 @@ urlpatterns = [
     url(r'^request_commentary$', views.request_commentary, name='request_commentary'),
     url(r'^request_commentary_ack$', views.request_commentary_ack, name='request_commentary_ack'),
     url(r'^vet_commentary_requests$', views.vet_commentary_requests, name='vet_commentary_requests'),
-    url(r'^no_commentary_req_to_vet$', views.no_commentary_req_to_vet, name='no_commentary_req_to_vet'),
+    #url(r'^no_commentary_req_to_vet$', views.no_commentary_req_to_vet, name='no_commentary_req_to_vet'),
     url(r'^vet_commentary_request_ack/(?P<commentary_id>[0-9]+)$', views.vet_commentary_request_ack, name='vet_commentary_request_ack'),
 ]
diff --git a/commentaries/views.py b/commentaries/views.py
index ddd141d57..3c2b96d86 100644
--- a/commentaries/views.py
+++ b/commentaries/views.py
@@ -61,15 +61,15 @@ def request_commentary_ack(request):
 def vet_commentary_requests(request):
     contributor = Contributor.objects.get(user=request.user)
     commentary_to_vet = Commentary.objects.filter(vetted=False).first() # only handle one at a time
-    if commentary_to_vet is not None:
-        form = VetCommentaryForm()
-        context = {'contributor': contributor, 'commentary_to_vet': commentary_to_vet, 'form': form }
-        return render(request, 'commentaries/vet_commentary_requests.html', context)
-    return render (request, 'commentaries/no_commentary_req_to_vet.html')
+    #if commentary_to_vet is not None:
+    form = VetCommentaryForm()
+    context = {'contributor': contributor, 'commentary_to_vet': commentary_to_vet, 'form': form }
+    return render(request, 'commentaries/vet_commentary_requests.html', context)
+    #return render (request, 'commentaries/no_commentary_req_to_vet.html')
 
 
-def no_commentary_req_to_vet(request):
-    return render (request, 'commentaries/no_commentary_req_to_vet.html')    
+#def no_commentary_req_to_vet(request):
+#    return render (request, 'commentaries/no_commentary_req_to_vet.html')    
 
 
 def vet_commentary_request_ack(request, commentary_id):
diff --git a/comments/templates/comments/no_author_reply_to_vet.html b/comments/templates/comments/no_author_reply_to_vet.html
deleted file mode 100644
index ee101ad2e..000000000
--- a/comments/templates/comments/no_author_reply_to_vet.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends 'scipost/base.html' %}
-
-{% block pagetitle %}: vet author replies{% endblock pagetitle %}
-
-{% block bodysup %}
-
-<section>
-  <h1>There are no SciPost Author Replies for you to vet.</h1>
-</section>
-
-{% endblock bodysup %}
diff --git a/comments/templates/comments/no_comment_to_vet.html b/comments/templates/comments/no_comment_to_vet.html
deleted file mode 100644
index 08841b51f..000000000
--- a/comments/templates/comments/no_comment_to_vet.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends 'scipost/base.html' %}
-
-{% block pagetitle %}: vet comments{% endblock pagetitle %}
-
-{% block bodysup %}
-
-<section>
-  <h1>There are no SciPost Comments for you to vet.</h1>
-</section>
-
-{% endblock bodysup %}
diff --git a/comments/templates/comments/vet_author_replies.html b/comments/templates/comments/vet_author_replies.html
index 84478f809..c0884706c 100644
--- a/comments/templates/comments/vet_author_replies.html
+++ b/comments/templates/comments/vet_author_replies.html
@@ -5,6 +5,11 @@
 {% block bodysup %}
 
 <section>
+  {% if not reply_to_vet %}
+  <h1>There are no Author Replies for you to vet.</h1>
+
+  {% else %}
+
   <h1>SciPost Author Reply to vet:</h1>
 
   <br>
@@ -59,6 +64,7 @@
     </div>
   </div>
 
+  {% endif %}
 </section>
 
 {% endblock bodysup %}
diff --git a/comments/urls.py b/comments/urls.py
index caede0fd1..ce491bc56 100644
--- a/comments/urls.py
+++ b/comments/urls.py
@@ -7,11 +7,11 @@ urlpatterns = [
     url(r'^comment_submission_ack$', views.comment_submission_ack, name='comment_submission_ack'),
     url(r'^reply_to_comment/(?P<comment_id>[0-9]+)$', views.reply_to_comment, name='reply_to_comment'),
     url(r'^vet_submitted_comments$', views.vet_submitted_comments, name='vet_submitted_comments'),
-    url(r'^no_comment_to_vet$', views.no_comment_to_vet, name='no_comment_to_vet'),
+    #url(r'^no_comment_to_vet$', views.no_comment_to_vet, name='no_comment_to_vet'),
     url(r'^vet_submitted_comment_ack/(?P<comment_id>[0-9]+)$', views.vet_submitted_comment_ack, name='vet_submitted_comment_ack'),
     url(r'^author_reply_to_comment/(?P<comment_id>[0-9]+)$', views.author_reply_to_comment, name='author_reply_to_comment'),
     url(r'^author_reply_to_report/(?P<report_id>[0-9]+)$', views.author_reply_to_report, name='author_reply_to_report'),
     url(r'^vet_author_replies$', views.vet_author_replies, name='vet_author_replies'),
-    url(r'^no_author_reply_to_vet$', views.no_author_reply_to_vet, name='no_author_reply_to_vet'),
+    #url(r'^no_author_reply_to_vet$', views.no_author_reply_to_vet, name='no_author_reply_to_vet'),
     url(r'^vet_author_reply_ack/(?P<reply_id>[0-9]+)$', views.vet_author_reply_ack, name='vet_author_reply_ack'),
 ]
diff --git a/comments/views.py b/comments/views.py
index 57ec2d951..1dd6e5b89 100644
--- a/comments/views.py
+++ b/comments/views.py
@@ -23,15 +23,15 @@ def comment_submission_ack(request):
 def vet_submitted_comments(request):
     contributor = Contributor.objects.get(user=request.user)
     comment_to_vet = Comment.objects.filter(status=0).first() # only handle one at a time
-    if comment_to_vet is not None:
-        form = VetCommentForm()
-        context = {'contributor': contributor, 'comment_to_vet': comment_to_vet, 'form': form }
-        return(render(request, 'comments/vet_submitted_comments.html', context))
-    return render (request, 'comments/no_comment_to_vet.html')
+    #if comment_to_vet is not None:
+    form = VetCommentForm()
+    context = {'contributor': contributor, 'comment_to_vet': comment_to_vet, 'form': form }
+    return(render(request, 'comments/vet_submitted_comments.html', context))
+    #return render (request, 'comments/no_comment_to_vet.html')
 
 
-def no_comment_to_vet(request):
-    return render (request, 'comments/no_comment_to_vet.html')
+#def no_comment_to_vet(request):
+#    return render (request, 'comments/no_comment_to_vet.html')
 
 
 def vet_submitted_comment_ack(request, comment_id):
@@ -151,14 +151,14 @@ def author_reply_to_report(request, report_id):
 def vet_author_replies(request):
     contributor = Contributor.objects.get(user=request.user)
     reply_to_vet = AuthorReply.objects.filter(status=0).first() # only handle one at a time
-    if reply_to_vet is not None:
-        form = VetAuthorReplyForm()
-        context = {'contributor': contributor, 'reply_to_vet': reply_to_vet, 'form': form }
-        return(render(request, 'comments/vet_author_replies.html', context))
-    return render (request, 'comments/no_author_reply_to_vet.html')
-
-def no_author_reply_to_vet(request):
-    return render (request, 'comments/no_author_reply_to_vet.html')
+    #if reply_to_vet is not None:
+    form = VetAuthorReplyForm()
+    context = {'contributor': contributor, 'reply_to_vet': reply_to_vet, 'form': form }
+    return(render(request, 'comments/vet_author_replies.html', context))
+    #return render (request, 'comments/no_author_reply_to_vet.html')
+
+#def no_author_reply_to_vet(request):
+#    return render (request, 'comments/no_author_reply_to_vet.html')
 
 
 def vet_author_reply_ack(request, reply_id):
diff --git a/scipost/templates/scipost/no_registration_req_to_vet.html b/scipost/templates/scipost/no_registration_req_to_vet.html
deleted file mode 100644
index 762411b45..000000000
--- a/scipost/templates/scipost/no_registration_req_to_vet.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends 'scipost/base.html' %}
-
-{% block pagetitle %}: registrations to vet{% endblock pagetitle %}
-
-{% block bodysup %}
-
-<section>
-  <h1>There are currently no SciPost Registration requests for you to vet.</h1>
-</section>
-
-{% endblock bodysup %}
diff --git a/scipost/templates/scipost/vet_registration_requests.html b/scipost/templates/scipost/vet_registration_requests.html
index 63ba7e196..e0c10b5c1 100644
--- a/scipost/templates/scipost/vet_registration_requests.html
+++ b/scipost/templates/scipost/vet_registration_requests.html
@@ -5,6 +5,10 @@
 {% block bodysup %}
 
 <section>
+  {% if not contributor_to_vet %}
+  <h1>There are no Registration requests for you to vet.</h1>
+
+  {% else %}
 
   <h1>SciPost Registration request to vet:</h1>
   <p>This Contributor is currently on rank 0 (submitting, commenting and voting disabled).</p>
@@ -32,6 +36,7 @@
     </div>
   </div>
 
+  {% endif %}
 </section>
 
 {% endblock bodysup %}
diff --git a/scipost/urls.py b/scipost/urls.py
index 2c0e85202..e171dece8 100644
--- a/scipost/urls.py
+++ b/scipost/urls.py
@@ -23,7 +23,7 @@ urlpatterns = [
     url(r'^already_activated$', views.already_activated, name='already_activated'),
     url(r'^vet_registration_requests$', views.vet_registration_requests, name='vet_registration_requests'),
     url(r'^vet_registration_request_ack/(?P<contributor_id>[0-9]+)$', views.vet_registration_request_ack, name='vet_registration_request_ack'),
-    url(r'^no_registration_req_to_vet$', views.no_registration_req_to_vet, name='no_registration_req_to_vet'),
+    #url(r'^no_registration_req_to_vet$', views.no_registration_req_to_vet, name='no_registration_req_to_vet'),
     ## Authentication
     url(r'^login$', views.login_view, name='login'),
     url(r'^logout$', views.logout_view, name='logout'),
diff --git a/scipost/views.py b/scipost/views.py
index 14b6dff54..a89d22cd6 100644
--- a/scipost/views.py
+++ b/scipost/views.py
@@ -174,15 +174,15 @@ def already_activated(request):
 def vet_registration_requests(request):
     contributor = Contributor.objects.get(user=request.user)
     contributor_to_vet = Contributor.objects.filter(user__is_active=True, rank=0).first() # limit to one at a time
-    if contributor_to_vet is not None:
-        form = VetRegistrationForm()
-        context = {'contributor': contributor, 'contributor_to_vet': contributor_to_vet, 'form': form }
-        return render(request, 'scipost/vet_registration_requests.html', context)
-    return render (request, 'scipost/no_registration_req_to_vet.html')
+    #if contributor_to_vet is not None:
+    form = VetRegistrationForm()
+    context = {'contributor': contributor, 'contributor_to_vet': contributor_to_vet, 'form': form }
+    return render(request, 'scipost/vet_registration_requests.html', context)
+    #return render (request, 'scipost/no_registration_req_to_vet.html')
 
 
-def no_registration_req_to_vet(request):
-    return render(request, 'scipost/no_registration_req_to_vet.html')
+#def no_registration_req_to_vet(request):
+#    return render(request, 'scipost/no_registration_req_to_vet.html')
 
 def vet_registration_request_ack(request, contributor_id):
     # process the form
diff --git a/submissions/templates/submissions/no_new_submission_to_process.html b/submissions/templates/submissions/no_new_submission_to_process.html
deleted file mode 100644
index 6b09da037..000000000
--- a/submissions/templates/submissions/no_new_submission_to_process.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends 'scipost/base.html' %}
-
-{% block pagetitle %}: process submissions{% endblock pagetitle %}
-
-{% block bodysup %}
-
-<section>
-  <h1>There are no SciPost Submissions for you to vet.</h1>
-</section>
-
-{% endblock bodysup %}
diff --git a/submissions/templates/submissions/no_report_to_vet.html b/submissions/templates/submissions/no_report_to_vet.html
deleted file mode 100644
index def2c3278..000000000
--- a/submissions/templates/submissions/no_report_to_vet.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{% extends 'scipost/base.html' %}
-
-{% block pagetitle %}: vet reports{% endblock pagetitle %}
-
-{% block bodysup %}
-
-<section>
-  <h1>There are no SciPost Reports for you to vet.</h1>
-</section>
-
-{% endblock bodysup %}
diff --git a/submissions/templates/submissions/process_new_submissions.html b/submissions/templates/submissions/process_new_submissions.html
index 0f6f52af4..dc562b423 100644
--- a/submissions/templates/submissions/process_new_submissions.html
+++ b/submissions/templates/submissions/process_new_submissions.html
@@ -5,6 +5,11 @@
 {% block bodysup %}
 
 <section>
+  {% if not submission_to_process %}
+  <h1>There are no Submissions for you to process.</h1>
+
+  {% else %}
+
   <h1>SciPost Submission to Process</h1>
 
   <br>
@@ -29,6 +34,7 @@
     </div>
   </div>
 
+  {% endif %}
 </section>
 
 {% endblock bodysup %}
diff --git a/submissions/templates/submissions/vet_submitted_reports.html b/submissions/templates/submissions/vet_submitted_reports.html
index 509784d79..9061b5a61 100644
--- a/submissions/templates/submissions/vet_submitted_reports.html
+++ b/submissions/templates/submissions/vet_submitted_reports.html
@@ -5,6 +5,11 @@
 {% block bodysup %}
 
 <section>
+  {% if not report_to_vet %}
+  <h1>There are no Reports for you to vet.</h1>
+
+  {% else %}
+
   <h1>SciPost Report to vet:</h1>
 
   <br>
@@ -42,6 +47,7 @@
     </div>
   </div>
 
+  {% endif %}
 </section>
 
 {% endblock bodysup %}
diff --git a/submissions/urls.py b/submissions/urls.py
index cae34b058..7b1a94ba6 100644
--- a/submissions/urls.py
+++ b/submissions/urls.py
@@ -10,12 +10,12 @@ urlpatterns = [
     url(r'^submit_manuscript$', views.submit_manuscript, name='submit_manuscript'),
     url(r'^submit_manuscript_ack$', views.submit_manuscript_ack, name='submit_manuscript_ack'),
     url(r'^process_new_submissions$', views.process_new_submissions, name='process_new_submissions'),
-    url(r'^no_new_submission_to_process$', views.no_new_submission_to_process, name='no_new_submission_to_process'),
+    #url(r'^no_new_submission_to_process$', views.no_new_submission_to_process, name='no_new_submission_to_process'),
     url(r'^process_new_submission_ack/(?P<submission_id>[0-9]+)$', views.process_new_submission_ack, name='process_new_submission_ack'),
     # Reports
     url(r'^submit_report/(?P<submission_id>[0-9]+)$', views.submit_report, name='submit_report'),
     url(r'^submit_report_ack$', views.submit_report_ack, name='submit_report_ack'),
     url(r'^vet_submitted_reports$', views.vet_submitted_reports, name='vet_submitted_reports'),
-    url(r'^no_report_to_vet$', views.no_report_to_vet, name='no_report_to_vet'),
+    #url(r'^no_report_to_vet$', views.no_report_to_vet, name='no_report_to_vet'),
     url(r'^vet_submitted_report_ack/(?P<report_id>[0-9]+)$', views.vet_submitted_report_ack, name='vet_submitted_report_ack'),
 ]
diff --git a/submissions/views.py b/submissions/views.py
index 1db8f9c58..873436b91 100644
--- a/submissions/views.py
+++ b/submissions/views.py
@@ -60,15 +60,15 @@ def submit_manuscript_ack(request):
 
 def process_new_submissions(request):
     submission_to_process = Submission.objects.filter(status='0').first() # only handle one at at time
-    if submission_to_process is not None:
-        form = ProcessSubmissionForm()
-        context = {'submission_to_process': submission_to_process, 'form': form }
-        return render(request, 'submissions/process_new_submissions.html', context)
-    return render(request, 'submissions/no_new_submission_to_process.html')
+    #if submission_to_process is not None:
+    form = ProcessSubmissionForm()
+    context = {'submission_to_process': submission_to_process, 'form': form }
+    return render(request, 'submissions/process_new_submissions.html', context)
+    #return render(request, 'submissions/no_new_submission_to_process.html')
 
 
-def no_new_submission_to_process(request):
-    return render(request, 'submissions/no_new_submission_to_process.html')
+#def no_new_submission_to_process(request):
+#    return render(request, 'submissions/no_new_submission_to_process.html')
 
 
 def process_new_submission_ack(request, submission_id):
@@ -197,15 +197,15 @@ def submit_report_ack(request):
 def vet_submitted_reports(request):
     contributor = Contributor.objects.get(user=request.user)
     report_to_vet = Report.objects.filter(status=0).first() # only handle one at a time
-    if report_to_vet is not None:
-        form = VetReportForm()
-        context = {'contributor': contributor, 'report_to_vet': report_to_vet, 'form': form }
-        return(render(request, 'submissions/vet_submitted_reports.html', context))
-    return render(request, 'submissions/no_report_to_vet.html')
+    #if report_to_vet is not None:
+    form = VetReportForm()
+    context = {'contributor': contributor, 'report_to_vet': report_to_vet, 'form': form }
+    return(render(request, 'submissions/vet_submitted_reports.html', context))
+    #return render(request, 'submissions/no_report_to_vet.html')
 
 
-def no_report_to_vet(request):
-    return render(request, 'submissions/no_report_to_vet.html')
+#def no_report_to_vet(request):
+#    return render(request, 'submissions/no_report_to_vet.html')
 
 
 def vet_submitted_report_ack(request, report_id):
-- 
GitLab