From 381d85d26a435ab4e67cd2ccdb176566b2375330 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Thu, 19 Apr 2018 06:36:36 +0200
Subject: [PATCH] Proceeding prep commit

Fixes:
  - Submission type should only be required for SciPost Physics.
  - Changed failing jQuery CDN.
  - ArXiv query result html update to improve reading.
  - Summernote loading debugging (sometimes failed to load).
---
 colleges/models.py                            | 14 ++++++-----
 colleges/views.py                             |  8 ++-----
 mails/widgets.py                              |  9 ++++---
 .../scipost/personal_page/account.html        |  9 +++++++
 scipost/templates/scipost/bare_base.html      |  2 +-
 submissions/forms.py                          | 24 ++++++++++++-------
 submissions/models.py                         |  4 ++--
 .../submissions/arxiv_queryresult.html        |  4 ++--
 .../admin/editorial_assignment_form.html      |  2 +-
 .../recommendation_prepare_for_voting.html    |  2 +-
 .../templates/submissions/referee_form.html   |  6 ++---
 11 files changed, 49 insertions(+), 35 deletions(-)

diff --git a/colleges/models.py b/colleges/models.py
index 8f4f8ac11..312021771 100644
--- a/colleges/models.py
+++ b/colleges/models.py
@@ -13,13 +13,15 @@ from .managers import FellowQuerySet
 
 
 class Fellowship(TimeStampedModel):
-    """
-    Editorial College Fellowship connecting Editorial College and Contributors,
-    possibly with a limiting start/until date.
+    """A Fellowship gives access to the Submission Pool to Contributors.
+
+    Editorial College Fellowship connects the Editorial College and Contributors,
+    possibly with a limiting start/until date and/or a Proceedings event.
 
     The date range will effectively be used while determining 'the pool' for a specific
     Submission, so it has a direct effect on the submission date.
     """
+
     contributor = models.ForeignKey('scipost.Contributor', on_delete=models.CASCADE,
                                     related_name='fellowships')
     start_date = models.DateField(null=True, blank=True)
@@ -39,15 +41,15 @@ class Fellowship(TimeStampedModel):
         return _str
 
     def get_absolute_url(self):
+        """Return the admin fellowship page."""
         return reverse('colleges:fellowship', args=(self.id,))
 
     def sibling_fellowships(self):
-        """
-        Return all Fellowships that are directly related to the Fellow of this Fellowship.
-        """
+        """Return all Fellowships that are directly related to the Fellow of this Fellowship."""
         return self.contributor.fellowships.all()
 
     def is_active(self):
+        """Check if the instance is within start and until date."""
         today = datetime.date.today()
         if not self.start_date:
             if not self.until_date:
diff --git a/colleges/views.py b/colleges/views.py
index 14e476585..babe8a453 100644
--- a/colleges/views.py
+++ b/colleges/views.py
@@ -19,9 +19,7 @@ from .models import Fellowship
 @login_required
 @permission_required('scipost.can_manage_college_composition', raise_exception=True)
 def fellowships(request):
-    """
-    List all fellowships to be able to edit them, or create new ones.
-    """
+    """List all fellowships to be able to edit them, or create new ones."""
     fellowships = Fellowship.objects.active()
 
     context = {
@@ -33,9 +31,7 @@ def fellowships(request):
 @login_required
 @permission_required('scipost.can_manage_college_composition', raise_exception=True)
 def fellowship_detail(request, id):
-    """
-    View details of a specific fellowship
-    """
+    """View details of a specific fellowship."""
     fellowship = get_object_or_404(Fellowship, id=id)
 
     context = {
diff --git a/mails/widgets.py b/mails/widgets.py
index f9cfaf114..d13bcf86b 100644
--- a/mails/widgets.py
+++ b/mails/widgets.py
@@ -52,9 +52,8 @@ class SummernoteEditor(widgets.Textarea):
     def trigger_summernote(self, el_id, options):
         str = """
         <script type='text/javascript'>
-            var $ = jQuery;
-            $(document).ready(function() {
-                $('#%s').summernote(%s)
+            $(function() {
+                $('#%s').summernote(%s);
             });
         </script>""" % (el_id, options)
         return str
@@ -66,7 +65,7 @@ class SummernoteEditor(widgets.Textarea):
         }
         js = ('//cdnjs.cloudflare.com/ajax/libs/summernote/0.8.8/summernote-bs4.js',)
 
-        if self.include_jquery:
-            js = ('//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js',) + js
+        # if self.include_jquery:
+        #     js = ('//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js',) + js
 
         return Media(css=css, js=js)
diff --git a/scipost/templates/partials/scipost/personal_page/account.html b/scipost/templates/partials/scipost/personal_page/account.html
index bfda86979..43e350ba7 100644
--- a/scipost/templates/partials/scipost/personal_page/account.html
+++ b/scipost/templates/partials/scipost/personal_page/account.html
@@ -102,6 +102,15 @@
 
                     {% if fellowship.guest %}
                         (Guest Fellowship)
+                        <br>
+                        Your Proceedings:
+                        <ul>
+                            {% for proc in fellowship.proceedings.all %}
+                                <li>{{ proc }}</li>
+                            {% empty %}
+                                <li><em>No proceedings assigned yet.</em></li>
+                            {% endfor %}
+                        </ul>
                     {% else %}
                         (Regular Fellowship)
                     {% endif %}
diff --git a/scipost/templates/scipost/bare_base.html b/scipost/templates/scipost/bare_base.html
index fbfb7b288..5efb4b3ae 100644
--- a/scipost/templates/scipost/bare_base.html
+++ b/scipost/templates/scipost/bare_base.html
@@ -9,7 +9,7 @@
     <link href="https://fonts.googleapis.com/css?family=Merriweather+Sans:300,400,700" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="{% static 'scipost/SciPost.css' %}" />
     <link rel="stylesheet" type="text/css" href="{% static 'fa/css/font-awesome.min.css' %}" />
-    <script async src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
+    <script async src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
     <script async src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
 
     {% render_bundle 'main' 'css' %}
diff --git a/submissions/forms.py b/submissions/forms.py
index c07f76b1f..7aa45b91c 100644
--- a/submissions/forms.py
+++ b/submissions/forms.py
@@ -24,7 +24,7 @@ from .models import (
 from common.helpers import get_new_secrets_key
 from colleges.models import Fellowship
 from invitations.models import RegistrationInvitation
-from journals.constants import SCIPOST_JOURNAL_PHYSICS_PROC
+from journals.constants import SCIPOST_JOURNAL_PHYSICS_PROC, SCIPOST_JOURNAL_PHYSICS
 from scipost.constants import SCIPOST_SUBJECT_AREAS, INVITATION_REFEREEING
 from scipost.services import ArxivCaller
 from scipost.models import Contributor
@@ -290,6 +290,7 @@ class RequestSubmissionForm(SubmissionChecks, forms.ModelForm):
             del self.fields['proceedings']
 
         # Update placeholder for the other fields
+        self.fields['submission_type'].required = False
         self.fields['arxiv_link'].widget.attrs.update({
             'placeholder': 'ex.:  arxiv.org/abs/1234.56789v1'})
         self.fields['abstract'].widget.attrs.update({'cols': 100})
@@ -322,9 +323,8 @@ class RequestSubmissionForm(SubmissionChecks, forms.ModelForm):
         return cleaned_data
 
     def clean_author_list(self):
-        """
-        Important check!
-
+        """Check if author list matches the Contributor submitting.
+    
         The submitting user must be an author of the submission.
         Also possibly may be extended to check permissions and give ultimate submission
         power to certain user groups.
@@ -336,12 +336,20 @@ class RequestSubmissionForm(SubmissionChecks, forms.ModelForm):
             raise forms.ValidationError(error_message, code='not_an_author')
         return author_list
 
+    def clean_submission_type(self):
+        """Validate Submission type.
+
+        The SciPost Physics journal requires a Submission type to be specified.
+        """
+        submission_type = self.cleaned_data['submission_type']
+        journal = self.cleaned_data['submitted_to_journal']
+        if journal == SCIPOST_JOURNAL_PHYSICS and not submission_type:
+            self.add_error('submission_type', 'Please specify the submission type.')
+        return submission_type
+
     @transaction.atomic
     def copy_and_save_data_from_resubmission(self, submission):
-        """
-        Fill given Submission with data coming from last_submission in the SubmissionChecks
-        blueprint.
-        """
+        """Fill given Submission with data coming from last_submission."""
         if not self.last_submission:
             raise Submission.DoesNotExist
 
diff --git a/submissions/models.py b/submissions/models.py
index 9c3bbcf7b..2f62dcdcb 100644
--- a/submissions/models.py
+++ b/submissions/models.py
@@ -71,8 +71,8 @@ class Submission(models.Model):
                                         default=CYCLE_DEFAULT)
     fellows = models.ManyToManyField('colleges.Fellowship', blank=True,
                                      related_name='pool')
-    # visible_pool = models.BooleanField(default=True)
-    # visible_public = models.BooleanField(default=False)
+    visible_pool = models.BooleanField(default=True)
+    visible_public = models.BooleanField(default=False)
     subject_area = models.CharField(max_length=10, choices=SCIPOST_SUBJECT_AREAS,
                                     verbose_name='Primary subject area', default='Phys:QP')
     submission_type = models.CharField(max_length=10, choices=SUBMISSION_TYPE)
diff --git a/submissions/templates/partials/submissions/arxiv_queryresult.html b/submissions/templates/partials/submissions/arxiv_queryresult.html
index b6cb2a65f..b528ee9c6 100644
--- a/submissions/templates/partials/submissions/arxiv_queryresult.html
+++ b/submissions/templates/partials/submissions/arxiv_queryresult.html
@@ -1,12 +1,12 @@
 <div class="card-body">
     <h3 class="card-title">{{ item.title }}</h3>
     <div class="card-text">
-        <div class="authors mb-2" id="arxiv_authors_{{ id }}" style="display: none;">
+        <a href="javascript:;" data-toggle="toggle" data-target="#arxiv_authors_{{ id }}">Toggle authors</a> &middot; <a href="{{ item.link }}" target="_blank">{{ item.id }}</a>
+        <div class="authors mt-2" id="arxiv_authors_{{ id }}" style="display: none;">
             {% for author in item.authors %}
                 {{ author.name }}{% if not forloop.last %},{% endif %}
             {% endfor %}
         </div>
-        <a href="javascript:;" data-toggle="toggle" data-target="#arxiv_authors_{{ id }}">Toggle authors</a> &middot; <a href="{{ item.link }}" target="_blank">{{ item.id }}</a>
     </div>
     <p class="card-text text-muted">Published: {{ item.published }}</p>
 </div>
diff --git a/submissions/templates/submissions/admin/editorial_assignment_form.html b/submissions/templates/submissions/admin/editorial_assignment_form.html
index 0761db76b..7e8925a5c 100644
--- a/submissions/templates/submissions/admin/editorial_assignment_form.html
+++ b/submissions/templates/submissions/admin/editorial_assignment_form.html
@@ -66,7 +66,7 @@
 <div class="row">
     <div class="col-12">
         {% if coauthorships %}
-            <div class="card card-outline-danger">
+            <div class="card border-danger">
                 <div class="card-body">
                     <h3 class="card-title text-danger">The system identified the following potential coauthorships (from arXiv database)</h3>
                     <p class="card-text text-danger">(only up to 5 most recent shown; if within the last 3 years, referee is disqualified):</p>
diff --git a/submissions/templates/submissions/admin/recommendation_prepare_for_voting.html b/submissions/templates/submissions/admin/recommendation_prepare_for_voting.html
index 8f9b07810..63312fef3 100644
--- a/submissions/templates/submissions/admin/recommendation_prepare_for_voting.html
+++ b/submissions/templates/submissions/admin/recommendation_prepare_for_voting.html
@@ -49,7 +49,7 @@
 <div class="row">
     <div class="col-12">
         {% if coauthorships %}
-            <div class="card card-outline-danger">
+            <div class="card border-danger">
                 <div class="card-body">
                     <h3 class="card-title text-danger">The system identified the following potential coauthorships (from arXiv database)</h3>
                     <p class="card-text text-danger">(only up to 5 most recent shown; if within the last 3 years, referee is disqualified):</p>
diff --git a/submissions/templates/submissions/referee_form.html b/submissions/templates/submissions/referee_form.html
index 8fae92385..af5b42f0c 100644
--- a/submissions/templates/submissions/referee_form.html
+++ b/submissions/templates/submissions/referee_form.html
@@ -52,16 +52,16 @@
 {% if queryresults.entries %}
 <div class="row">
     <div class="col-12">
-        <div class="card card-outline-danger">
+        <div class="card border-danger">
             <div class="card-body">
                 <h3 class="card-title text-danger">The system identified the following potential coauthorships (from arXiv database)</h3>
                 <p class="card-text text-danger">(only up to 5 most recent shown; if within the last 3 years, referee is disqualified):</p>
             </div>
             <div class="card-body">
-                <ul class="list-group list-group-flush">
+                <ul class="list-group list-group-flush px-0">
                     {% for entry in queryresults.entries %}
                         <li class="list-group-item">
-                            {% include 'partials/submissions/arxiv_queryresult.html' with item=entry %}
+                            {% include 'partials/submissions/arxiv_queryresult.html' with item=entry id=forloop.counter %}
                         </li>
                     {% endfor %}
                 </ul>
-- 
GitLab