diff --git a/scipost_django/comments/templates/comments/_comment_identifier.html b/scipost_django/comments/templates/comments/_comment_identifier.html index 6acae04ccff35a9118c0c6efd40c382948a8ef3f..005d32d299f4c1054c83acfe01ebb720e540d8a6 100644 --- a/scipost_django/comments/templates/comments/_comment_identifier.html +++ b/scipost_django/comments/templates/comments/_comment_identifier.html @@ -17,9 +17,7 @@ {% endif %} <small>[id {{ comment.id }}]</small> {% if user.is_authenticated %} - {% with type_id=comment|content_type_id %} - {% include 'helpdesk/_ticket_for_object_link.html' with type_id=type_id id=comment.id model="Comment" %} - {% endwith %} + {% include 'helpdesk/_ticket_for_object_link.html' with object=comment %} {% endif %} </h3> {% if comment.doi_string %} <small>{{ comment|citation }}</small>{% endif %} diff --git a/scipost_django/helpdesk/templates/helpdesk/_ticket_for_object_link.html b/scipost_django/helpdesk/templates/helpdesk/_ticket_for_object_link.html index 3b1e14ef8d2cd8720e7f303e63f50ba4eb1d5f46..a325e227f451ea3716a64e5501d2ffcd65a95b28 100644 --- a/scipost_django/helpdesk/templates/helpdesk/_ticket_for_object_link.html +++ b/scipost_django/helpdesk/templates/helpdesk/_ticket_for_object_link.html @@ -1 +1,7 @@ -<a href="{% url 'helpdesk:ticket_create' concerning_type_id=type_id concerning_object_id=id %}" target="_blank" class="float-end p-0"><span style="font-size: 90%;" data-bs-toggle="tooltip" data-bs-html="true" title="Notice something wrong?<br/>Open a support ticket on this {{ model }}">{% include 'bi/sticky-fill.html' %}</span></a> +{% load scipost_extras %} +<span class="float-end p-0"> + {% if user.is_superuser %}<a href="{{ object|get_admin_url }}" target="_blank" class="text-danger"><span style="font-size: 90%;" data-bs-toggle="tooltip" data-bs-html="true" title="Edit in admin (superusers only)">{% include 'bi/pencil-square.html' %}</span></a> {% endif %} + {% with type_id=object|content_type_id %} + <a href="{% url 'helpdesk:ticket_create' concerning_type_id=type_id concerning_object_id=object.id %}" target="_blank"><span style="font-size: 90%;" data-bs-toggle="tooltip" data-bs-html="true" title="Notice something wrong?<br/>Open a support ticket on this {{ object|object_name }}">{% include 'bi/sticky-fill.html' %}</span></a> + {% endwith %} +</span> diff --git a/scipost_django/journals/templates/journals/_publication_summary.html b/scipost_django/journals/templates/journals/_publication_summary.html index 20f62346a6dbb33136ddf66b634471f03322b8f6..3a5232f4edb2e5fe13099f4cfe3cdc1ced76a333 100644 --- a/scipost_django/journals/templates/journals/_publication_summary.html +++ b/scipost_django/journals/templates/journals/_publication_summary.html @@ -16,9 +16,7 @@ {% endfor %} {% if user.is_authenticated %} - {% with type_id=publication|content_type_id %} - {% include 'helpdesk/_ticket_for_object_link.html' with type_id=type_id id=publication.id model="Publication" %} - {% endwith %} + {% include 'helpdesk/_ticket_for_object_link.html' with object=publication %} {% endif %} </p> diff --git a/scipost_django/journals/templates/journals/publication_update_detail.html b/scipost_django/journals/templates/journals/publication_update_detail.html index c8cdbdb299f5cff523726cb01db84fe8af189b19..1822ab6dfe9b2e800fed48e309dc6a8d21262cdc 100644 --- a/scipost_django/journals/templates/journals/publication_update_detail.html +++ b/scipost_django/journals/templates/journals/publication_update_detail.html @@ -32,9 +32,7 @@ <p class="text-muted mb-0"> {{ update.citation }} · published {{ update.publication_date|date:'j F Y' }} {% if user.is_authenticated %} - {% with type_id=update|content_type_id %} - {% include 'helpdesk/_ticket_for_object_link.html' with type_id=type_id id=update.id model="PublicationUpdate" %} - {% endwith %} + {% include 'helpdesk/_ticket_for_object_link.html' with object=update %} {% endif %} </p> <ul class="publicationClickables mt-3"> diff --git a/scipost_django/scipost/templatetags/scipost_extras.py b/scipost_django/scipost/templatetags/scipost_extras.py index 2a220a0e602c348f732e8979355fa3ae3c5f7a56..289ef4adab804e7ed0482d21416356488f192fe2 100644 --- a/scipost_django/scipost/templatetags/scipost_extras.py +++ b/scipost_django/scipost/templatetags/scipost_extras.py @@ -6,6 +6,7 @@ import random from django import template from django.contrib.contenttypes.models import ContentType +from django.urls import reverse from ..models import Contributor @@ -56,6 +57,17 @@ def content_type_id(obj): return ContentType.objects.get_for_model(obj).id +@register.filter +def object_name(obj): + return obj._meta.object_name if obj else None + + +@register.filter +def get_admin_url(obj): + return reverse(f'admin:{obj._meta.app_label}_{obj._meta.model_name}_change', + args=(obj.pk,)) + + @register.filter(name='increment_dt') def increment_dt(dt): try: 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 2e863752db645c05117b2edc0392177fbb3f6a0c..1820aa24cd0e649e5d83d6f482b43cee7dae9f54 100644 --- a/scipost_django/submissions/templates/submissions/_report_public_without_comments.html +++ b/scipost_django/submissions/templates/submissions/_report_public_without_comments.html @@ -25,9 +25,7 @@ {% if user.is_authenticated %} - {% with type_id=report|content_type_id %} - {% include 'helpdesk/_ticket_for_object_link.html' with type_id=type_id id=report.id model="Report" %} - {% endwith %} + {% include 'helpdesk/_ticket_for_object_link.html' with object=report %} {% endif %} </h3> {% if report.anonymous %} @@ -68,9 +66,6 @@ {% if perms.scipost.can_manage_reports %} <h3 class="mt-2">Administration</h3> <ul> - {% if user.is_superuser %} - <li><a href="{% url 'admin:submissions_report_change' report.id %}" target="_blank">Edit in admin (superusers only)</a></li> - {% endif %} <li><a href="{% url 'submissions:report_pdf_compile' report.id %}">Update/Compile the Report pdf</a></li> <li>Mark DOI as <a href="{% url 'journals:mark_report_doi_needed' report_id=report.id needed=1 %}">needed</a> / <a href="{% url 'journals:mark_report_doi_needed' report_id=report.id needed=0 %}">not needed</a></li> <li><a href="{% url 'journals:generic_metadata_xml_deposit' type_of_object='report' object_id=report.id %}">Create the metadata and deposit it to Crossref</a></li> diff --git a/scipost_django/submissions/templates/submissions/admin/submission_prescreening.html b/scipost_django/submissions/templates/submissions/admin/submission_prescreening.html index 1762f3139071e7f4029d6fcbb383fd65b20dae64..61c0da2ac8ae7190c3c2a6d01c380e313c182411 100644 --- a/scipost_django/submissions/templates/submissions/admin/submission_prescreening.html +++ b/scipost_django/submissions/templates/submissions/admin/submission_prescreening.html @@ -16,11 +16,9 @@ <h1 class="highlight">Pre-screening of Submission</h1> <h3><a href="{{ submission.get_absolute_url }}">{{ submission.title }}</a></h3> <h4>by {{ submission.author_list }}</h4> + {% include 'helpdesk/_ticket_for_object_link.html' with object=submission %} <h3 class="mt-4">Submission summary</h3> - {% if user.is_superuser %} - <p><a href="{% url 'admin:submissions_submission_change' submission.id %}" target="_blank" class="p-1 border border-danger text-danger">Edit in admin (superusers only)</a></p> - {% endif %} {% include 'submissions/pool/_submission_info_table_extended.html' with submission=submission %} <h3 class="mt-4">Abstract</h3> diff --git a/scipost_django/submissions/templates/submissions/submission_detail.html b/scipost_django/submissions/templates/submissions/submission_detail.html index 221d2c8a8e0f2373f394ea2663cc365871a0198e..d6d993ae891a530300c88c077b38e8067fa5dc6d 100644 --- a/scipost_django/submissions/templates/submissions/submission_detail.html +++ b/scipost_django/submissions/templates/submissions/submission_detail.html @@ -66,9 +66,7 @@ <h3 class="mb-3">by {{ submission.author_list }}</h3> {% if user.is_authenticated %} - {% with type_id=submission|content_type_id %} - {% include 'helpdesk/_ticket_for_object_link.html' with type_id=type_id id=submission.id model="Submission" %} - {% endwith %} + {% include 'helpdesk/_ticket_for_object_link.html' with object=submission %} {% endif %} <div class="ps-2 mb-1"> @@ -102,9 +100,6 @@ </div> <h3 class="mt-4">Submission summary</h3> - {% if user.is_superuser %} - <p><a href="{% url 'admin:submissions_submission_change' submission.id %}" target="_blank" class="p-1 border border-danger text-danger">Edit in admin (superusers only)</a></p> - {% endif %} {% include 'submissions/_submission_summary.html' with submission=submission hide_title=1 show_abstract=1 %} {% include 'submissions/_submission_topics.html' with submission=submission %}