diff --git a/scipost/management/commands/add_groups_and_permissions.py b/scipost/management/commands/add_groups_and_permissions.py index 35c942debfea0ce2b0ac7025bef904e99b56acf2..9f36daa9743bb4577b32fdf3de121e677e8ec4a4 100644 --- a/scipost/management/commands/add_groups_and_permissions.py +++ b/scipost/management/commands/add_groups_and_permissions.py @@ -230,7 +230,6 @@ class Command(BaseCommand): can_view_production, can_attend_VGMs, can_manage_mailchimp, - can_manage_reports, ]) AdvisoryBoard.permissions.set([ can_manage_registration_invitations, @@ -245,6 +244,7 @@ class Command(BaseCommand): can_view_production, can_publish_accepted_submission, can_attend_VGMs, + can_manage_reports, ]) EditorialCollege.permissions.set([ can_view_pool, diff --git a/scipost/templates/scipost/personal_page.html b/scipost/templates/scipost/personal_page.html index 1447f92185da91b42f1cdeb9d11c544f88a7eb4e..9cdbf70f2364e1180760d713625d8e16bdca2e87 100644 --- a/scipost/templates/scipost/personal_page.html +++ b/scipost/templates/scipost/personal_page.html @@ -261,9 +261,10 @@ </ul> {% if perms.scipost.can_manage_reports %} - <h3>Reports</h3> + <h3>Refereeing</h3> <ul> <li><a href="{% url 'submissions:reports_accepted_list' %}">Accepted Reports</a>{% if nr_reports_without_pdf %} ({{nr_reports_without_pdf}} unfinished){% endif %}</li> + <li><a href="{% url 'submissions:treated_submissions_list' %}">Fully treated Submissions</a>{% if nr_treated_submissions_without_pdf %} ({{nr_treated_submissions_without_pdf}} unfinished){% endif %}</li> </ul> {% endif %} diff --git a/scipost/views.py b/scipost/views.py index 47f7a2027ab138e9c9882d1e8eaf90c90b00ba52..6dab6269d67c6bb34cca486dd813152f04ebc427 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -98,7 +98,7 @@ def documentsSearchResults(query): .filter(publication_query).order_by('-publication_date')) commentary_search_queryset = (Commentary.objects.vetted() .filter(commentary_query).order_by('-pub_date')) - submission_search_queryset = (Submission.objects.public() + submission_search_queryset = (Submission.objects.public_unlisted() .filter(submission_query).order_by('-submission_date')) thesislink_search_list = (ThesisLink.objects.vetted() .filter(thesislink_query).order_by('-defense_date')) @@ -175,7 +175,7 @@ def index(request): '''Main page.''' context = { 'latest_newsitems': NewsItem.objects.all().order_by('-date')[:1], - 'submissions': Submission.objects.public().order_by('-submission_date')[:3], + 'submissions': Submission.objects.public_unlisted().order_by('-submission_date')[:3], 'publications': Publication.objects.published().order_by('-publication_date')[:3] } return render(request, 'scipost/index.html', context) @@ -795,8 +795,6 @@ def personal_page(request): nr_submissions_to_assign = 0 nr_recommendations_to_prepare_for_voting = 0 if contributor.is_SP_Admin(): - intwodays = now + timezone.timedelta(days=2) - # count the number of pending registration requests nr_reg_to_vet = Contributor.objects.filter(user__is_active=True, status=0).count() nr_reg_awaiting_validation = (Contributor.objects.awaiting_validation() @@ -805,6 +803,7 @@ def personal_page(request): nr_submissions_to_assign = Submission.objects.filter(status__in=['unassigned']).count() nr_recommendations_to_prepare_for_voting = EICRecommendation.objects.filter( submission__status__in=['voting_in_preparation']).count() + nr_assignments_to_consider = 0 active_assignments = None nr_reports_to_vet = 0 @@ -898,13 +897,15 @@ def personal_page(request): 'own_submissions': own_submissions, 'own_commentaries': own_commentaries, 'own_thesislinks': own_thesislinks, - 'own_comments': own_comments, 'own_authorreplies': own_authorreplies, + 'own_comments': own_comments, + 'own_authorreplies': own_authorreplies, } # Only add variables if user has right permission if request.user.has_perm('scipost.can_manage_reports'): context['nr_reports_without_pdf'] = (Report.objects.accepted() .filter(pdf_report='').count()) + context['nr_treated_submissions_without_pdf'] = Submission.objects.treated().count() return render(request, 'scipost/personal_page.html', context) @@ -1116,7 +1117,7 @@ def contributor_info(request, contributor_id): """ contributor = get_object_or_404(Contributor, pk=contributor_id) contributor_publications = Publication.objects.published().filter(authors=contributor) - contributor_submissions = Submission.objects.public().filter(authors=contributor) + contributor_submissions = Submission.objects.public_unlisted().filter(authors=contributor) contributor_commentaries = Commentary.objects.filter(authors=contributor) contributor_theses = ThesisLink.objects.vetted().filter(author_as_cont=contributor) contributor_comments = (Comment.objects.vetted() diff --git a/submissions/forms.py b/submissions/forms.py index 190f0c93360ead118747739f20c46f11850ef2a7..ed1b46e059bd96aac5eecdb5131dfb8c1c75d5ea 100644 --- a/submissions/forms.py +++ b/submissions/forms.py @@ -32,7 +32,7 @@ class SubmissionSearchForm(forms.Form): def search_results(self): """Return all Submission objects according to search""" - return Submission.objects.public_overcomplete().filter( + return Submission.objects.public_newest().filter( title__icontains=self.cleaned_data.get('title', ''), author_list__icontains=self.cleaned_data.get('author', ''), abstract__icontains=self.cleaned_data.get('abstract', ''), @@ -332,6 +332,12 @@ class RequestSubmissionForm(SubmissionChecks, forms.ModelForm): return submission +class SubmissionReportsForm(forms.ModelForm): + class Meta: + model = Submission + fields = ['pdf_refereeing_pack'] + + ###################### # Editorial workflow # ###################### diff --git a/submissions/templates/submissions/_submission_summary.html b/submissions/templates/submissions/_submission_summary.html index 334f2d67912757293c26183e4412ee0e8f6d1601..bd73de899bd2310a56487055812f81aea616a864 100644 --- a/submissions/templates/submissions/_submission_summary.html +++ b/submissions/templates/submissions/_submission_summary.html @@ -1,6 +1,7 @@ {% extends 'submissions/_submission_summary_short.html' %} {% block submission_summary_footer %} + <a href="{% url 'submissions:refereeing_package_pdf' submission.arxiv_identifier_w_vn_nr %}" target="_blank">Download pdf package</a> <h3 class="mt-3">Abstract</h3> <p>{{submission.abstract}}</p> {% endblock %} diff --git a/submissions/templates/submissions/_submission_summary_short.html b/submissions/templates/submissions/_submission_summary_short.html index bf6915e89f54fe758948d39f7ae3d7c438025498..a5e999c09085d7ff121f00ad501ae30edc04af47 100644 --- a/submissions/templates/submissions/_submission_summary_short.html +++ b/submissions/templates/submissions/_submission_summary_short.html @@ -19,7 +19,7 @@ </tr> <tr> - <td>arxiv Link:</td> + <td>Arxiv Link:</td> <td> <a href="{{submission.arxiv_link}}" target="_blank">{{submission.arxiv_link}}</a> </td> diff --git a/submissions/templates/submissions/treated_submission_pdf_compile.html b/submissions/templates/submissions/treated_submission_pdf_compile.html new file mode 100644 index 0000000000000000000000000000000000000000..aeb5e32c2e135f10e049463427a38f2c49fb525c --- /dev/null +++ b/submissions/templates/submissions/treated_submission_pdf_compile.html @@ -0,0 +1,73 @@ +{% extends 'scipost/_personal_page_base.html' %} + +{% block pagetitle %}: Upload Submission Refereeing PDF{% endblock pagetitle %} + +{% load bootstrap %} + +{% block breadcrumb_items %} + {{block.super}} + <a href="{% url 'submissions:treated_submissions_list' %}" class="breadcrumb-item">Treated Submissions</a> + <span class="breadcrumb-item">Upload Submission Refereeing PDF</span> +{% endblock %} + +{% block content %} + + <div class="row"> + <div class="col-12"> + <h1 class="highlight">Upload Submission Refereeing PDF</h1> + {% include 'submissions/_submission_summary_short.html' with submission=submission %} + </div> + </div> + <hr> + + <div class="row"> + <div class="col-12"> + <h3>Please process this code in your Tex Compiler:</h3> + <p>Don't forget you may need to compile twice because of the Table of Content.</p> + <pre class="clickfocus" style="max-height: 200px;"><code>{% include 'submissions/_refereeing_pack_tex_template.html' with submission=submission %}</code></pre> + </div> + </div> + + + <div class="row"> + <div class="col-12"> + <form method="post" enctype="multipart/form-data"> + {% csrf_token %} + {{ form|bootstrap }} + <input class="btn btn-secondary" type="submit" value="Upload"/> + </form> + </div> + </div> + +<script> + jQuery.fn.selectText = function(){ + this.find('input').each(function() { + if($(this).prev().length == 0 || !$(this).prev().hasClass('p_copy')) { + $('<p class="p_copy" style="position: absolute; z-index: -1;"></p>').insertBefore($(this)); + } + $(this).prev().html($(this).val()); + }); + var doc = document; + var element = this[0]; + + if (doc.body.createTextRange) { + var range = document.body.createTextRange(); + range.moveToElementText(element); + range.select(); + } else if (window.getSelection) { + var selection = window.getSelection(); + var range = document.createRange(); + range.selectNodeContents(element); + selection.removeAllRanges(); + selection.addRange(range); + } + }; + + $(function() { + $('.clickfocus').on('click', function() { + $(this).find('code').selectText(); + }); + }); +</script> + +{% endblock %} diff --git a/submissions/templates/submissions/treated_submissions_list.html b/submissions/templates/submissions/treated_submissions_list.html new file mode 100644 index 0000000000000000000000000000000000000000..c9b167bd9832f074302c794376cfd497b0413f2c --- /dev/null +++ b/submissions/templates/submissions/treated_submissions_list.html @@ -0,0 +1,56 @@ +{% extends 'scipost/_personal_page_base.html' %} + +{% block breadcrumb_items %} + {{block.super}} + <span class="breadcrumb-item">Treated Submissions</span> +{% endblock %} + +{% load bootstrap %} + +{% block pagetitle %}: Treated Submissions{% endblock pagetitle %} + +{% block content %} + +<div class="row"> + <div class="col-12"> + <h1 class="highlight">Treated Submissions</h1> + </div> +</div> + +<div class="row"> + <div class="col-12"> + <table class="table"> + <thead> + <tr> + <th>Submission</th> + <th>Status</th> + <th>Accepted</th> + <th>Number of Reports</th> + <th>Has PDF</th> + <th>Action</th> + </tr> + </thead> + <tbody> + {% for submission in submissions %} + <tr{% if not submission.pdf_refereeing_pack %} class="table-danger"{% endif %}> + <td><a href="{{submission.get_absolute_url}}">{{submission.arxiv_identifier_w_vn_nr}}</a></td> + <td>{{submission.get_status_display}}</td> + <td>{{submission.acceptance_date|default_if_none:'Date unknown'}}</td> + <td>{{submission.reports.accepted.count}}</td> + <td> + {{submission.pdf_refereeing_pack|yesno:"Yes,No"}} + {% if submission.pdf_refereeing_pack %} + · <a href="{% url 'submissions:refereeing_package_pdf' submission.arxiv_identifier_w_vn_nr %}" target="_blank">Download</a> + {% endif %} + </td> + <td> + <a href="{% url 'submissions:treated_submission_pdf_compile' submission.arxiv_identifier_w_vn_nr %}">Compile/upload Refereeing Package</a> + </td> + </tr> + {% endfor %} + </tbody> + </table> + </div> +</div> + +{% endblock %} diff --git a/submissions/urls.py b/submissions/urls.py index aacc096c6577f4d1377f2e2e0f53c2cbc94ea574..c4d8d4fc656accf12e14509b8e9386d804caa865 100644 --- a/submissions/urls.py +++ b/submissions/urls.py @@ -20,6 +20,11 @@ urlpatterns = [ views.submission_detail, name='submission'), url(r'^(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})/reports/(?P<report_nr>[0-9]+)/pdf$', views.report_detail_pdf, name='report_detail_pdf'), + url(r'^(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})/reports/pdf$', + views.submission_refereeing_package_pdf, name='refereeing_package_pdf'), + url(r'^treated_submissions$', views.treated_submissions_list, name='treated_submissions_list'), + url(r'^(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})/reports/compile$', + views.treated_submission_pdf_compile, name='treated_submission_pdf_compile'), url(r'^submit_manuscript$', views.RequestSubmission.as_view(), name='submit_manuscript'), url(r'^submit_manuscript/prefill$', views.prefill_using_arxiv_identifier, name='prefill_using_identifier'), @@ -28,6 +33,7 @@ urlpatterns = [ views.submissions_by_status, name='submissions_by_status'), url(r'^add_remark/(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})$', views.add_remark, name='add_remark'), + # Assignment of Editor-in-charge url(r'^assign_submission/(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})$', views.assign_submission, name='assign_submission'), @@ -81,6 +87,7 @@ urlpatterns = [ url(r'^reports/list$', views.reports_accepted_list, name='reports_accepted_list'), url(r'^reports/(?P<report_id>[0-9]+)/compile$', views.report_pdf_compile, name='report_pdf_compile'), + # Voting url(r'^prepare_for_voting/(?P<rec_id>[0-9]+)$', views.prepare_for_voting, name='prepare_for_voting'), url(r'^vote_on_rec/(?P<rec_id>[0-9]+)$', views.vote_on_rec, name='vote_on_rec'), diff --git a/submissions/views.py b/submissions/views.py index 2d4ad353a9c38a5f8af5f3102f0e5a28a42e89e1..0b34e45700f188bb1eff9a63e48b9cd5e4926195 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -1,6 +1,9 @@ import datetime import feedparser +from PyPDF2 import PdfFileMerger, PdfFileReader + +from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import login_required, permission_required from django.contrib.auth.models import Group @@ -11,7 +14,8 @@ from django.shortcuts import get_object_or_404, render, redirect from django.template import Template, Context from django.utils import timezone from django.utils.decorators import method_decorator -from django.views.decorators.http import require_POST +from django.views.generic.edit import CreateView +from django.views.generic.list import ListView from guardian.decorators import permission_required_or_403 from guardian.shortcuts import assign_perm @@ -26,7 +30,7 @@ from .forms import SubmissionIdentifierForm, RequestSubmissionForm, SubmissionSe SetRefereeingDeadlineForm, RefereeSelectForm, RefereeRecruitmentForm,\ ConsiderRefereeInvitationForm, EditorialCommunicationForm,\ EICRecommendationForm, ReportForm, VetReportForm, VotingEligibilityForm,\ - SubmissionCycleChoiceForm, ReportPDFForm + SubmissionCycleChoiceForm, ReportPDFForm, SubmissionReportsForm from .utils import SubmissionUtils from scipost.forms import ModifyPersonalMessageForm, RemarkForm @@ -36,9 +40,6 @@ from scipost.utils import Utils from comments.forms import CommentForm from production.models import ProductionStream -from django.views.generic.edit import CreateView -from django.views.generic.list import ListView - import strings @@ -120,7 +121,7 @@ class SubmissionListView(ListView): paginate_by = 10 def get_queryset(self): - queryset = Submission.objects.public_overcomplete() + queryset = Submission.objects.public_newest() self.form = self.form(self.request.GET) if 'to_journal' in self.kwargs: queryset = queryset.filter( @@ -221,6 +222,9 @@ def submission_detail(request, arxiv_identifier_w_vn_nr): def report_detail_pdf(request, arxiv_identifier_w_vn_nr, report_nr): + """ + Download the PDF of a Report if available. + """ report = get_object_or_404(Report.objects.accepted(), submission__arxiv_identifier_w_vn_nr=arxiv_identifier_w_vn_nr, pdf_report__isnull=False, report_nr=report_nr) @@ -230,8 +234,27 @@ def report_detail_pdf(request, arxiv_identifier_w_vn_nr, report_nr): return response +def submission_refereeing_package_pdf(request, arxiv_identifier_w_vn_nr): + """ + This view let's the user download all Report PDF's in a single merged PDF. + The merging takes places every time its downloaded to make sure all available report PDF's + are included and the EdColAdmin doesn't have to compile the package every time again. + """ + submission = get_object_or_404(Submission.objects.public(), + pdf_refereeing_pack__isnull=False, + arxiv_identifier_w_vn_nr=arxiv_identifier_w_vn_nr) + response = HttpResponse(submission.pdf_refereeing_pack.read(), content_type='application/pdf') + filename = '%s-refereeing-package.pdf' % submission.arxiv_identifier_w_vn_nr + response['Content-Disposition'] = ('filename=' + filename) + return response + + @permission_required('scipost.can_manage_reports', raise_exception=True) def reports_accepted_list(request): + """ + This view lists all accepted Reports. This shows if Report needs a PDF update/compile + in a convenient way. + """ reports = (Report.objects.accepted() .order_by('pdf_report', 'submission').prefetch_related('submission')) context = { @@ -255,6 +278,35 @@ def report_pdf_compile(request, report_id): return render(request, 'submissions/reports_pdf_compile.html', context) +@permission_required('scipost.can_manage_reports', raise_exception=True) +def treated_submissions_list(request): + """ + This view lists all accepted Reports. This shows if Report needs a PDF update/compile + in a convenient way. + """ + submissions = Submission.objects.treated().order_by('pdf_refereeing_pack', '-acceptance_date') + context = { + 'submissions': submissions + } + return render(request, 'submissions/treated_submissions_list.html', context) + + +@permission_required('scipost.can_manage_reports', raise_exception=True) +def treated_submission_pdf_compile(request, arxiv_identifier_w_vn_nr): + submission = get_object_or_404(Submission.objects.treated(), + arxiv_identifier_w_vn_nr=arxiv_identifier_w_vn_nr) + form = SubmissionReportsForm(request.POST or None, request.FILES or None, instance=submission) + if form.is_valid(): + form.save() + messages.success(request, 'Upload complete.') + return redirect(reverse('submissions:treated_submissions_list')) + context = { + 'submission': submission, + 'form': form + } + return render(request, 'submissions/treated_submission_pdf_compile.html', context) + + ###################### # Editorial workflow # ######################