From 66ed32c0e8f14abebd12c31327552ddcd8de4044 Mon Sep 17 00:00:00 2001 From: Jorran de Wit <jorrandewit@outlook.com> Date: Sun, 25 Jun 2017 14:38:06 +0200 Subject: [PATCH] Add Report overview page for Admin --- .../commands/add_groups_and_permissions.py | 7 +++ scipost/templates/scipost/personal_page.html | 7 +++ scipost/views.py | 5 ++ .../submissions/reports_accepted_list.html | 60 +++++++++++++++++++ submissions/urls.py | 5 +- submissions/views.py | 10 ++++ 6 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 submissions/templates/submissions/reports_accepted_list.html diff --git a/scipost/management/commands/add_groups_and_permissions.py b/scipost/management/commands/add_groups_and_permissions.py index ef95e885d..a2459c66f 100644 --- a/scipost/management/commands/add_groups_and_permissions.py +++ b/scipost/management/commands/add_groups_and_permissions.py @@ -156,6 +156,12 @@ class Command(BaseCommand): name='Can oversee refereeing', content_type=content_type) + # Reports + can_manage_reports, created = Permission.objects.get_or_create( + codename='can_manage_reports', + name='Can manage Reports', + content_type=content_type) + # Voting can_prepare_recommendations_for_voting, created = Permission.objects.get_or_create( codename='can_prepare_recommendations_for_voting', @@ -206,6 +212,7 @@ class Command(BaseCommand): can_view_production, can_attend_VGMs, can_manage_mailchimp, + can_manage_reports, ]) AdvisoryBoard.permissions.set([ can_manage_registration_invitations, diff --git a/scipost/templates/scipost/personal_page.html b/scipost/templates/scipost/personal_page.html index 32fcb4a45..1447f9218 100644 --- a/scipost/templates/scipost/personal_page.html +++ b/scipost/templates/scipost/personal_page.html @@ -260,6 +260,13 @@ {% endif %} </ul> + {% if perms.scipost.can_manage_reports %} + <h3>Reports</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> + </ul> + {% endif %} + {% if perms.scipost.can_attend_VGMs %} <h3>Virtual General Meetings</h3> <ul> diff --git a/scipost/views.py b/scipost/views.py index 229123403..629438ab2 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -893,6 +893,11 @@ def personal_page(request): '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()) + return render(request, 'scipost/personal_page.html', context) diff --git a/submissions/templates/submissions/reports_accepted_list.html b/submissions/templates/submissions/reports_accepted_list.html new file mode 100644 index 000000000..822c2f811 --- /dev/null +++ b/submissions/templates/submissions/reports_accepted_list.html @@ -0,0 +1,60 @@ +{% extends 'scipost/_personal_page_base.html' %} + +{% block breadcrumb_items %} + {{block.super}} + <span class="breadcrumb-item">Accepted Reports</span> +{% endblock %} + +{% load bootstrap %} + +{% block pagetitle %}: Accepted Reports{% endblock pagetitle %} + +{% block content %} + +<div class="row"> + <div class="col-12"> + <h1 class="highlight">Accepted Reports</h1> + </div> +</div> + +<div class="row"> + <div class="col-12"> + <table class="table"> + <thead> + <tr> + <th>Report nr. of Submission</th> + <th>Submission</th> + <th>Report author</th> + <th>Has PDF</th> + </tr> + </thead> + <tbody> + {% for report in reports %} + <tr{% if not report.pdf_report %} class="table-danger"{% endif %}> + <td>{{report.report_nr}}</td> + <td><a href="{{report.submission.get_absolute_url}}">{{report.submission.arxiv_identifier_w_vn_nr}}</a></td> + <td>{% if report.anonymous %}<em>Anonymous</em>{% else %}{{report.author}}{% endif %}</td> + <td>{{report.pdf_report|yesno:"Yes,No"}}</td> + </tr> + {% endfor %} + </tbody> + </table> + </div> +</div> + +{% comment %} +<div class="row"> + <div class="col-12"> + <form method="post"> + {% csrf_token %} + {{ form|bootstrap }} + <input class="btn btn-primary" type="submit" value="Submit"/> + <div class="my-4"> + <em>By clicking on Submit, you state that you abide by the <a href="{% url 'journals:journals_terms_and_conditions' %}#referee_code_of_conduct">referee code of conduct</a>.</em> + </div> + </form> + </div> +</div> +{% endcomment %} + +{% endblock %} diff --git a/submissions/urls.py b/submissions/urls.py index 2b9375939..d83b666b0 100644 --- a/submissions/urls.py +++ b/submissions/urls.py @@ -75,9 +75,10 @@ urlpatterns = [ url(r'^cycle/(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})/submit$', views.cycle_form_submit, name='cycle_confirmation'), # Reports - url(r'^submit_report/(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})$', + url(r'^(?P<arxiv_identifier_w_vn_nr>[0-9]{4,}.[0-9]{5,}v[0-9]{1,2})/reports/submit$', views.submit_report, name='submit_report'), - url(r'^vet_submitted_reports$', views.vet_submitted_reports, name='vet_submitted_reports'), + url(r'^reports/vet_submitted$', views.vet_submitted_reports, name='vet_submitted_reports'), + url(r'^reports/list$', views.reports_accepted_list, name='reports_accepted_list'), # 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 5a84f528b..1be45d016 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -229,6 +229,16 @@ def report_detail_pdf(request, arxiv_identifier_w_vn_nr, report_nr): return response +@permission_required('scipost.can_manage_reports', raise_exception=True) +def reports_accepted_list(request): + reports = (Report.objects.accepted() + .order_by('pdf_report', 'submission').prefetch_related('submission')) + context = { + 'reports': reports + } + return render(request, 'submissions/reports_accepted_list.html', context) + + ###################### # Editorial workflow # ###################### -- GitLab