From c2e1a5ad9a883ef95bf758c7851aa078532b2877 Mon Sep 17 00:00:00 2001 From: Jorran de Wit <jorrandewit@outlook.com> Date: Sun, 1 Oct 2017 14:36:17 +0200 Subject: [PATCH] Tweaking --- production/admin.py | 7 ++++++- production/models.py | 6 +++++- .../production/partials/production_stream_card.html | 13 +++++++++++-- production/templates/production/proofs.html | 2 +- production/views.py | 2 ++ 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/production/admin.py b/production/admin.py index 8d7fef8b4..00de781be 100644 --- a/production/admin.py +++ b/production/admin.py @@ -30,6 +30,11 @@ class ProductionStreamAdmin(GuardedModelAdmin): ) -admin.site.register(Proof) +class ProductionProofsAdmin(admin.ModelAdmin): + list_display = ['stream', 'version', 'status', 'accessible_for_authors'] + list_filter = ['status', 'accessible_for_authors'] + + +admin.site.register(Proof, ProductionProofsAdmin) admin.site.register(ProductionUser) admin.site.register(ProductionStream, ProductionStreamAdmin) diff --git a/production/models.py b/production/models.py index 84f7ea4a6..c04f85841 100644 --- a/production/models.py +++ b/production/models.py @@ -117,11 +117,15 @@ class Proof(models.Model): objects = ProofsQuerySet.as_manager() class Meta: - ordering = ['version'] + ordering = ['stream', 'version'] def get_absolute_url(self): return reverse('production:proof_pdf', kwargs={'slug': self.slug}) + def __str__(self): + return 'Proof {version} for Stream {stream}'.format( + version=self.version, stream=self.stream.submission.title) + def save(self, *args, **kwargs): # Control Report count per Submission. if not self.version: diff --git a/production/templates/production/partials/production_stream_card.html b/production/templates/production/partials/production_stream_card.html index b495d127a..d171c8b6e 100644 --- a/production/templates/production/partials/production_stream_card.html +++ b/production/templates/production/partials/production_stream_card.html @@ -46,8 +46,17 @@ </div> </li> {% endif %} - {% if perms.scipost.can_upload_proofs and stream.status != 'accepted' and stream.status != 'completed' and stream.status != 'cited' %} - <li><a href="{% url 'production:upload_proofs' stream_id=stream.id %}">Upload Proofs</a></li> + {% if perms.scipost.can_upload_proofs and stream.status != 'accepted' and stream.status != 'completed' and stream.status != 'cited' and upload_proofs_form %} + <li> + <a href="javascript:;" data-toggle="toggle" data-target="#upload_proofs">Upload Proofs</a> + <div id="upload_proofs" style="display: none;"> + <form class="my-3" action="{% url 'production:upload_proofs' stream_id=stream.id %}" method="post" enctype="multipart/form-data"> + {% csrf_token %} + {{ upload_proofs_form|bootstrap_inline }} + <input type="submit" class="btn btn-outline-primary" name="submit" value="Upload"> + </form> + </div> + </li> {% endif %} {% if perms.scipost.can_publish_accepted_submission %} {% if not stream.submission.publication %} diff --git a/production/templates/production/proofs.html b/production/templates/production/proofs.html index dbd22466a..cf4698159 100644 --- a/production/templates/production/proofs.html +++ b/production/templates/production/proofs.html @@ -40,7 +40,7 @@ <li><a href="{% url 'production:send_proofs' proof.stream.id proof.version %}">Send proofs to authors</a></li> {% endif %} {% if proof.status != 'uploaded' %} - <li><a href="{% url 'production:toggle_accessibility' proof.stream.id proof.version %}">{{ proof.accessible_for_authors|yesno:'Make accessible,Hide' }} for authors</a></li> + <li><a href="{% url 'production:toggle_accessibility' proof.stream.id proof.version %}">{{ proof.accessible_for_authors|yesno:'Hide,Make accessible' }} for authors</a></li> {% endif %} {% endif %} </ul> diff --git a/production/views.py b/production/views.py index 168eb2e49..4e5ee9832 100644 --- a/production/views.py +++ b/production/views.py @@ -86,6 +86,7 @@ def stream(request, stream_id): prodevent_form = ProductionEventForm() assign_officer_form = AssignOfficerForm() assign_supervisor_form = AssignSupervisorForm() + upload_proofs_form = ProofUploadForm() status_form = StreamStatusForm(instance=stream, production_user=request.user.production_user) context = { @@ -94,6 +95,7 @@ def stream(request, stream_id): 'assign_officer_form': assign_officer_form, 'assign_supervisor_form': assign_supervisor_form, 'status_form': status_form, + 'upload_proofs_form': upload_proofs_form, } if request.GET.get('json'): -- GitLab