From 05cf4337b176d7a1bd78af5506eebb145ca681ff Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Sat, 23 Jan 2016 06:44:46 +0100
Subject: [PATCH] All vetting actions: now only a single item at a time
 (querysets: use first() )

---
 .../commentaries/vet_commentary_requests.html |  6 ++--
 commentaries/views.py                         |  4 +--
 .../comments/vet_author_replies.html          |  6 ++--
 .../comments/vet_submitted_comments.html      |  6 ++--
 comments/views.py                             |  8 +++---
 scipost/forms.py                              | 28 +++++++++----------
 scipost/models.py                             |  2 +-
 scipost/templates/scipost/register.html       | 10 ++++---
 .../scipost/vet_registration_requests.html    | 22 +++++++--------
 scipost/views.py                              |  4 +--
 .../submissions/process_new_submissions.html  | 18 ++++++------
 .../submissions/vet_submitted_reports.html    |  8 ++----
 submissions/views.py                          |  8 +++---
 13 files changed, 65 insertions(+), 65 deletions(-)

diff --git a/commentaries/templates/commentaries/vet_commentary_requests.html b/commentaries/templates/commentaries/vet_commentary_requests.html
index 22998d4d9..94011f45f 100644
--- a/commentaries/templates/commentaries/vet_commentary_requests.html
+++ b/commentaries/templates/commentaries/vet_commentary_requests.html
@@ -5,8 +5,8 @@
 {% block bodysup %}
 
 <section>
-  <h1>SciPost Commentary Page requests to vet:</h1>
-  {% for commentary_to_vet in commentary_requests_to_vet %}
+  <h1>SciPost Commentary Page request to vet:</h1>
+
   <br>
   <hr>
   <div class="row">
@@ -29,7 +29,7 @@
         <input type="submit" value="Submit" />
     </div>
   </div>
-  {% endfor %}
+
 </section>
 
 {% endblock bodysup %}
diff --git a/commentaries/views.py b/commentaries/views.py
index ebac43814..f6bd5b813 100644
--- a/commentaries/views.py
+++ b/commentaries/views.py
@@ -60,9 +60,9 @@ def request_commentary_ack(request):
 
 def vet_commentary_requests(request):
     contributor = Contributor.objects.get(user=request.user)
-    commentary_requests_to_vet = Commentary.objects.filter(vetted=False)
+    commentary_to_vet = Commentary.objects.filter(vetted=False).first() # only handle one at a time
     form = VetCommentaryForm()
-    context = {'contributor': contributor, 'commentary_requests_to_vet': commentary_requests_to_vet, 'form': form }
+    context = {'contributor': contributor, 'commentary_to_vet': commentary_to_vet, 'form': form }
     return render(request, 'commentaries/vet_commentary_requests.html', context)
 
 
diff --git a/comments/templates/comments/vet_author_replies.html b/comments/templates/comments/vet_author_replies.html
index 33b05b3b5..84478f809 100644
--- a/comments/templates/comments/vet_author_replies.html
+++ b/comments/templates/comments/vet_author_replies.html
@@ -5,8 +5,8 @@
 {% block bodysup %}
 
 <section>
-  <h1>SciPost Author Replies to vet:</h1>
-  {% for reply_to_vet in replies_to_vet %}
+  <h1>SciPost Author Reply to vet:</h1>
+
   <br>
   <hr>
 
@@ -58,7 +58,7 @@
       </form>
     </div>
   </div>
-  {% endfor %}
+
 </section>
 
 {% endblock bodysup %}
diff --git a/comments/templates/comments/vet_submitted_comments.html b/comments/templates/comments/vet_submitted_comments.html
index a257c6365..4a185057f 100644
--- a/comments/templates/comments/vet_submitted_comments.html
+++ b/comments/templates/comments/vet_submitted_comments.html
@@ -5,8 +5,8 @@
 {% block bodysup %}
 
 <section>
-  <h1>SciPost Comments to vet:</h1>
-  {% for comment_to_vet in submitted_comments_to_vet %}
+  <h1>SciPost Comment to vet:</h1>
+
   <br>
   <hr>
   {% if comment_to_vet.commentary %}
@@ -51,7 +51,7 @@
       </form>
     </div>
   </div>
-  {% endfor %}
+
 </section>
 
 {% endblock bodysup %}
diff --git a/comments/views.py b/comments/views.py
index 140d08fdf..7580c52cb 100644
--- a/comments/views.py
+++ b/comments/views.py
@@ -22,9 +22,9 @@ def comment_submission_ack(request):
 
 def vet_submitted_comments(request):
     contributor = Contributor.objects.get(user=request.user)
-    submitted_comments_to_vet = Comment.objects.filter(status=0)
+    comment_to_vet = Comment.objects.filter(status=0).first() # only handle one at a time
     form = VetCommentForm()
-    context = {'contributor': contributor, 'submitted_comments_to_vet': submitted_comments_to_vet, 'form': form }
+    context = {'contributor': contributor, 'submitted_comment_to_vet': comment_to_vet, 'form': form }
     return(render(request, 'comments/vet_submitted_comments.html', context))
 
 
@@ -145,9 +145,9 @@ def author_reply_to_report(request, report_id):
 
 def vet_author_replies(request):
     contributor = Contributor.objects.get(user=request.user)
-    replies_to_vet = AuthorReply.objects.filter(status=0)
+    reply_to_vet = AuthorReply.objects.filter(status=0).first # only handle one at a time
     form = VetAuthorReplyForm()
-    context = {'contributor': contributor, 'replies_to_vet': replies_to_vet, 'form': form }
+    context = {'contributor': contributor, 'reply_to_vet': reply_to_vet, 'form': form }
     return(render(request, 'comments/vet_author_replies.html', context))
 
 
diff --git a/scipost/forms.py b/scipost/forms.py
index 45e326456..cabc5e687 100644
--- a/scipost/forms.py
+++ b/scipost/forms.py
@@ -17,20 +17,20 @@ REGISTRATION_REFUSAL_CHOICES = (
     )
 
 class RegistrationForm(forms.Form):
-    title = forms.ChoiceField(choices=TITLE_CHOICES)
-    first_name = forms.CharField(label='First name', max_length=100)
-    last_name = forms.CharField(label='Last name', max_length=100)
-    email = forms.EmailField(label='email')
-    orcid_id = forms.CharField(label="ORCID id", max_length=20)
-    nationality = LazyTypedChoiceField(choices=countries, initial='CA', widget=CountrySelectWidget(layout='{widget}<img class="country-select-flag" id="{flag_id}" style="margin: 6px 4px 0" src="{country.flag}">'))
-    country_of_employment = LazyTypedChoiceField(choices=countries, initial='NL', widget=CountrySelectWidget(layout='{widget}<img class="country-select-flag" id="{flag_id}" style="margin: 6px 4px 0" src="{country.flag}">'))
-    affiliation = forms.CharField(label='Affiliation', max_length=300)
-    #address = forms.CharField(label='Address', max_length=1000)
-    personalwebpage = forms.URLField(label='Personal web page')
-    username = forms.CharField(label='username', max_length=100)
-    password = forms.CharField(label='password', widget=forms.PasswordInput())
-    password_verif = forms.CharField(label='verify pwd', widget=forms.PasswordInput())
-    captcha = CaptchaField()
+    title = forms.ChoiceField(choices=TITLE_CHOICES, label='* Title')
+    first_name = forms.CharField(label='* First name', max_length=100)
+    last_name = forms.CharField(label='* Last name', max_length=100)
+    email = forms.EmailField(label='* email address')
+    orcid_id = forms.CharField(label="  ORCID id", max_length=20, widget=forms.TextInput({'placeholder': 'Recommended. Get one at orcid.org'}), required=False)
+    nationality = LazyTypedChoiceField(choices=countries, label='* Nationality', initial='CA', widget=CountrySelectWidget(layout='{widget}<img class="country-select-flag" id="{flag_id}" style="margin: 6px 4px 0" src="{country.flag}">'))
+    country_of_employment = LazyTypedChoiceField(choices=countries, label='* Country of employment', initial='NL', widget=CountrySelectWidget(layout='{widget}<img class="country-select-flag" id="{flag_id}" style="margin: 6px 4px 0" src="{country.flag}">'))
+    affiliation = forms.CharField(label='* Affiliation', max_length=300)
+    address = forms.CharField(label='Address', max_length=1000, widget=forms.TextInput({'placeholder': 'For eventual snail mail correspondence'}), required=False)
+    personalwebpage = forms.URLField(label='Personal web page', widget=forms.TextInput({'placeholder': 'full URL, e.g. http://www.[yourpage].com'}), required=False)
+    username = forms.CharField(label='* username', max_length=100)
+    password = forms.CharField(label='* password', widget=forms.PasswordInput())
+    password_verif = forms.CharField(label='* verify pwd', widget=forms.PasswordInput())
+    captcha = CaptchaField(label='* Captcha')
 
 #class RegistrationFormUser(forms.ModelForm):
 #    class Meta:
diff --git a/scipost/models.py b/scipost/models.py
index 90ef55f92..7e7f1cb44 100644
--- a/scipost/models.py
+++ b/scipost/models.py
@@ -52,7 +52,7 @@ class Contributor(models.Model):
     nationality = CountryField()
     country_of_employment = CountryField()
     affiliation = models.CharField(max_length=300, verbose_name='affiliation')
-    #address = models.CharField(max_length=1000, verbose_name="address")
+    address = models.CharField(max_length=1000, verbose_name="address", default='')
     personalwebpage = models.URLField(verbose_name='personal web page')
     #vetted_by = models.OneToOneField(Contributor, related_name='vetted_by') TO ACTIVATE
 
diff --git a/scipost/templates/scipost/register.html b/scipost/templates/scipost/register.html
index 1c178e1e4..a12b79da1 100644
--- a/scipost/templates/scipost/register.html
+++ b/scipost/templates/scipost/register.html
@@ -8,11 +8,13 @@
   <h1>Register to SciPost</h1>
   <div class="row">
     <div class="col-4">
-      <p>Please note that all fields are required.</p>
-      <p>Don't have an ORCID id yet?</p>
-      <p>Get one at  <a href="http://orcid.org">orcid.org</a>.</p>
+      <h3>Notes:</h3>
+      <p>Required fields are marked with a *.</p>
+      <p>An ORCID id is not formally required but helps preventing identification ambiguities.
+      You can easily get one at  <a href="http://orcid.org">orcid.org</a>.</p>
     </div>
-    <div class="col-8">
+    <div class="col-1"></div>
+    <div class="col-7">
       <form action="{% url 'scipost:register' %}" method="post">
 	{% csrf_token %}
 	<table>
diff --git a/scipost/templates/scipost/vet_registration_requests.html b/scipost/templates/scipost/vet_registration_requests.html
index 0c4d25f77..47993f324 100644
--- a/scipost/templates/scipost/vet_registration_requests.html
+++ b/scipost/templates/scipost/vet_registration_requests.html
@@ -5,32 +5,32 @@
 {% block bodysup %}
 
 <section>
-  <h1>SciPost Registration requests to vet:</h1>
-  <p>These Contributors are currently on rank 0 (submitting, commenting and voting disabled).</p>
+  <h1>SciPost Registration request to vet:</h1>
+  <p>This Contributor is currently on rank 0 (submitting, commenting and voting disabled).</p>
   <p>Use this form to promote to rank 1.</p>
-  {% for registration_to_vet in registration_requests_to_vet %}
+
   <br>
   <hr>
   <div class="row">
     <div class="col-8">
       <table>
-	<tr><td>Title:</td><td>{{ registration_to_vet.title }}</td></tr>
-	<tr><td>First name:</td><td>{{ registration_to_vet.user.first_name }}</td></tr>
-	<tr><td>Last name:</td><td>{{ registration_to_vet.user.last_name }}</td></tr>
-	<tr><td>email:</td><td>{{ registration_to_vet.user.email }}</td></tr>
-	<tr><td>user name:</td><td>{{ registration_to_vet.user.username }}</td></tr>
-	<tr><td>orcid_id:</td><td>{{ registration_to_vet.orcid_id }}</td></tr>
+	<tr><td>Title:</td><td>{{ contributor_to_vet.title }}</td></tr>
+	<tr><td>First name:</td><td>{{ contributor_to_vet.user.first_name }}</td></tr>
+	<tr><td>Last name:</td><td>{{ contributor_to_vet.user.last_name }}</td></tr>
+	<tr><td>email:</td><td>{{ contributor_to_vet.user.email }}</td></tr>
+	<tr><td>user name:</td><td>{{ contributor_to_vet.user.username }}</td></tr>
+	<tr><td>orcid_id:</td><td>{{ contributor_to_vet.orcid_id }}</td></tr>
       </table>
     </div>
     <div class="col-4">
-      <form action="{% url 'scipost:vet_registration_request_ack' contributor_id=registration_to_vet.id %}" method="post">
+      <form action="{% url 'scipost:vet_registration_request_ack' contributor_id=contributor_to_vet.id %}" method="post">
 	{% csrf_token %}
 	{{ form.as_p }}
 	<input type="submit" value="Submit" />
       </form>
     </div>
   </div>
-  {% endfor %}
+
 </section>
 
 {% endblock bodysup %}
diff --git a/scipost/views.py b/scipost/views.py
index ac3c2f884..ef7aa8921 100644
--- a/scipost/views.py
+++ b/scipost/views.py
@@ -101,9 +101,9 @@ def thanks_for_registering(request):
 
 def vet_registration_requests(request):
     contributor = Contributor.objects.get(user=request.user)
-    registration_requests_to_vet = Contributor.objects.filter(rank=0)
+    contributor_to_vet = Contributor.objects.filter(rank=0).first() # limit to one at a time
     form = VetRegistrationForm()
-    context = {'contributor': contributor, 'registration_requests_to_vet': registration_requests_to_vet, 'form': form }
+    context = {'contributor': contributor, 'contributor_to_vet': contributor_to_vet, 'form': form }
     return render(request, 'scipost/vet_registration_requests.html', context)
 
 
diff --git a/submissions/templates/submissions/process_new_submissions.html b/submissions/templates/submissions/process_new_submissions.html
index ae62957ea..0f6f52af4 100644
--- a/submissions/templates/submissions/process_new_submissions.html
+++ b/submissions/templates/submissions/process_new_submissions.html
@@ -5,30 +5,30 @@
 {% block bodysup %}
 
 <section>
-  <h1>SciPost Submissions to Process</h1>
-  {% for submission in submissions_to_process %}
+  <h1>SciPost Submission to Process</h1>
+
   <br>
   <hr>
   <div class="row">
     <div class="col-8">
       <table>
-	<tr><td>Title: </td><td>{{ submission.title }}</td></tr>
-	<tr><td>Author(s): </td><td>{{ submission.author_list }}</td></tr>
-	<tr><td>arxiv Link: </td><td><a href="{{ submission.arxiv_link }}">{{ submission.arxiv_link }}</a></td></tr>
-	<tr><td>Date submitted: </td><td>{{ submission.submission_date }}</td></tr>
+	<tr><td>Title: </td><td>{{ submission_to_process.title }}</td></tr>
+	<tr><td>Author(s): </td><td>{{ submission_to_process.author_list }}</td></tr>
+	<tr><td>arxiv Link: </td><td><a href="{{ submission_to_process.arxiv_link }}">{{ submission_to_process.arxiv_link }}</a></td></tr>
+	<tr><td>Date submitted: </td><td>{{ submission_to_process.submission_date }}</td></tr>
       </table>
       <br />
       <h4>Abstract:</h4>
-      <p>{{ submission.abstract }}</p>
+      <p>{{ submission_to_process.abstract }}</p>
     </div>
     <div class="col-4">
-      <form action="{% url 'submissions:process_new_submission_ack' submission_id=submission.id %}" method="post">
+      <form action="{% url 'submissions:process_new_submission_ack' submission_id=submission_to_process.id %}" method="post">
         {% csrf_token %}
         {{ form.as_ul }}
         <input type="submit" value="Submit" />
     </div>
   </div>
-  {% endfor %}
+
 </section>
 
 {% endblock bodysup %}
diff --git a/submissions/templates/submissions/vet_submitted_reports.html b/submissions/templates/submissions/vet_submitted_reports.html
index e0238fb44..509784d79 100644
--- a/submissions/templates/submissions/vet_submitted_reports.html
+++ b/submissions/templates/submissions/vet_submitted_reports.html
@@ -4,10 +4,9 @@
 
 {% block bodysup %}
 
-{% if submitted_reports_to_vet %}
 <section>
-  <h1>SciPost Reports to vet:</h1>
-  {% for report_to_vet in submitted_reports_to_vet %}
+  <h1>SciPost Report to vet:</h1>
+
   <br>
   <hr>
   <h3>Submission associated to Report:</h3>
@@ -42,8 +41,7 @@
       </form>
     </div>
   </div>
-  {% endfor %}
+
 </section>
-{% endif %}
 
 {% endblock bodysup %}
diff --git a/submissions/views.py b/submissions/views.py
index a087cefd7..10db541c0 100644
--- a/submissions/views.py
+++ b/submissions/views.py
@@ -59,9 +59,9 @@ def submit_manuscript_ack(request):
 
 
 def process_new_submissions(request):
-    submissions_to_process = Submission.objects.filter(status='0')
+    submission_to_process = Submission.objects.filter(status='0').first() # only handle one at at time
     form = ProcessSubmissionForm()
-    context = {'submissions_to_process': submissions_to_process, 'form': form }
+    context = {'submission_to_process': submission_to_process, 'form': form }
     return render(request, 'submissions/process_new_submissions.html', context)
 
 
@@ -190,9 +190,9 @@ def submit_report_ack(request):
 
 def vet_submitted_reports(request):
     contributor = Contributor.objects.get(user=request.user)
-    submitted_reports_to_vet = Report.objects.filter(status=0)
+    report_to_vet = Report.objects.filter(status=0).first() # only handle one at a time
     form = VetReportForm()
-    context = {'contributor': contributor, 'submitted_reports_to_vet': submitted_reports_to_vet, 'form': form }
+    context = {'contributor': contributor, 'report_to_vet': report_to_vet, 'form': form }
     return(render(request, 'submissions/vet_submitted_reports.html', context))
 
 
-- 
GitLab