From 22e0531eb546770ef0c7c2ce15ef57ca377a677e Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Wed, 1 Nov 2023 16:59:32 +0100 Subject: [PATCH] add edadmin anonymize button to reports --- .../_report_public_without_comments.html | 12 ++++++++--- scipost_django/submissions/urls/__init__.py | 6 +++--- scipost_django/submissions/views/__init__.py | 20 +++++++++++++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/scipost_django/submissions/templates/submissions/_report_public_without_comments.html b/scipost_django/submissions/templates/submissions/_report_public_without_comments.html index bea9c166c..69a9d1705 100644 --- a/scipost_django/submissions/templates/submissions/_report_public_without_comments.html +++ b/scipost_django/submissions/templates/submissions/_report_public_without_comments.html @@ -1,9 +1,9 @@ {% load scipost_extras %} {% load submissions_extras %} -<div class="row mb-5"> - <div class="col-12"> - <div class="report" id="report_{{ report.report_nr }}"> +<div class="report" id="report_{{ report.report_nr }}"> + <div class="row mb-5"> + <div class="col-12"> <div class="reportid"> <h3> {% if report.anonymous %} @@ -52,6 +52,12 @@ </div> </div> {% endif %} + {% else %} + {% if user|is_in_group:'Editorial Administrators' and not user|is_possible_author_of_submission:submission %} + <button class="btn btn-sm btn-danger text-white my-2" hx-get="{% url "submissions:_hx_anonymize_report" report_id=report.id %}" hx-target="#report_{{report.report_nr}}" hx-swap="outerHTML"> + Anonymize this report + </button> + {% endif %} {% endif %} {% if report.doi_string or report.pdf_report %} <ul class="clickables"> diff --git a/scipost_django/submissions/urls/__init__.py b/scipost_django/submissions/urls/__init__.py index d067583b2..eda9b3a8e 100644 --- a/scipost_django/submissions/urls/__init__.py +++ b/scipost_django/submissions/urls/__init__.py @@ -226,9 +226,9 @@ urlpatterns = [ name="report_pdf_compile", ), path( - "admin/reports/<int:report_id>/compile", - views.report_pdf_compile, - name="report_pdf_compile", + "admin/reports/<int:report_id>/_hx_anonymize_report", + views._hx_anonymize_report, + name="_hx_anonymize_report", ), # Submission, resubmission, withdrawal path( # Start a new submission process; choose resub or new sub (with field choice) diff --git a/scipost_django/submissions/views/__init__.py b/scipost_django/submissions/views/__init__.py index 2bac3b901..c3bd354ce 100644 --- a/scipost_django/submissions/views/__init__.py +++ b/scipost_django/submissions/views/__init__.py @@ -99,6 +99,7 @@ from colleges.models import PotentialFellowship, Fellowship from colleges.permissions import ( fellowship_required, fellowship_or_admin_required, + is_edadmin, is_edadmin_or_senior_fellow, ) from comments.forms import CommentForm @@ -859,6 +860,25 @@ def report_pdf_compile(request, report_id): return render(request, "submissions/admin/report_compile_form.html", context) +@login_required +@user_passes_test(is_edadmin) +def _hx_anonymize_report(request, report_id): + report = get_object_or_404(Report, id=report_id) + report.anonymous = True + report.save() + report.submission.add_event_for_eic( + f"{request.user.get_full_name()} anonymized " + f"referee report #{report.report_nr} " + f"(by {report.author.profile.full_name})" + ) + + return render( + request, + "submissions/_report_public.html", + {"report": report, "submission": report.submission}, + ) + + @permission_required("scipost.can_manage_reports", raise_exception=True) def treated_submissions_list(request): """List all treated Submissions. -- GitLab