#20048 action_url template tag
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (push) Waiting to run

This commit is contained in:
Arthur 2025-08-07 17:22:20 -07:00
parent d3ef9bdf8d
commit 581f7e88a3
9 changed files with 42 additions and 57 deletions

View File

@ -10,11 +10,9 @@
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="{% url 'core:job_list' %}?object_type={{ object.object_type_id }}">{{ object.object|meta:"verbose_name_plural"|bettertitle }}</a> <a href="{% url 'core:job_list' %}?object_type={{ object.object_type_id }}">{{ object.object|meta:"verbose_name_plural"|bettertitle }}</a>
</li> </li>
{% with parent_jobs_viewname=object.object|viewname:"jobs" %} <li class="breadcrumb-item">
<li class="breadcrumb-item"> <a href="{% action_url object.object 'jobs' pk=object.object.pk %}">{{ object.object }}</a>
<a href="{% url parent_jobs_viewname pk=object.object.pk %}">{{ object.object }}</a> </li>
</li>
{% endwith %}
{% else %} {% else %}
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="{% url 'core:job_list' %}?name={{ object.name|urlencode }}">{{ object.name }}</a> <a href="{% url 'core:job_list' %}?name={{ object.name|urlencode }}">{{ object.name }}</a>

View File

@ -23,11 +23,9 @@
{{ term.device|linkify }} {{ term.device|linkify }}
<i class="mdi mdi-chevron-right" aria-hidden="true"></i> <i class="mdi mdi-chevron-right" aria-hidden="true"></i>
{{ term|linkify }} {{ term|linkify }}
{% with trace_url=term|viewname:"trace" %} <a href="{% action_url term 'trace' pk=term.pk %}" class="btn btn-primary lh-1" title="{% trans "Trace" %}">
<a href="{% url trace_url pk=term.pk %}" class="btn btn-primary lh-1" title="{% trans "Trace" %}"> <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
<i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i> </a>
</a>
{% endwith %}
{% if not forloop.last %}<br/>{% endif %} {% if not forloop.last %}<br/>{% endif %}
{% endfor %} {% endfor %}
</td> </td>
@ -47,11 +45,9 @@
<td> <td>
{% for term in terminations %} {% for term in terminations %}
{{ term|linkify }} {{ term|linkify }}
{% with trace_url=term|viewname:"trace" %} <a href="{% action_url term 'trace' pk=term.pk %}" class="btn btn-primary lh-1" title="{% trans "Trace" %}">
<a href="{% url trace_url pk=term.pk %}" class="btn btn-primary lh-1" title="{% trans "Trace" %}"> <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
<i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i> </a>
</a>
{% endwith %}
{% if not forloop.last %}<br/>{% endif %} {% if not forloop.last %}<br/>{% endif %}
{% endfor %} {% endfor %}
</td> </td>
@ -67,11 +63,9 @@
<td> <td>
{% for term in terminations %} {% for term in terminations %}
{{ term.circuit|linkify }} ({{ term }}) {{ term.circuit|linkify }} ({{ term }})
{% with trace_url=term|viewname:"trace" %} <a href="{% action_url term 'trace' pk=term.pk %}" class="btn btn-primary lh-1" title="{% trans "Trace" %}">
<a href="{% url trace_url pk=term.pk %}" class="btn btn-primary lh-1" title="{% trans "Trace" %}"> <i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i>
<i class="mdi mdi-transit-connection-variant" aria-hidden="true"></i> </a>
</a>
{% endwith %}
{% if not forloop.last %}<br/>{% endif %} {% if not forloop.last %}<br/>{% endif %}
{% endfor %} {% endfor %}
</td> </td>

View File

@ -6,11 +6,9 @@
{% block extra_controls %} {% block extra_controls %}
{% if perms.extras.add_imageattachment %} {% if perms.extras.add_imageattachment %}
{% with viewname=object|viewname:"image-attachments" %} <a href="{% url 'extras:imageattachment_add' %}?object_type={{ object|content_type_id }}&object_id={{ object.pk }}&return_url={% action_url object 'image-attachments' pk=object.pk %}" class="btn btn-primary">
<a href="{% url 'extras:imageattachment_add' %}?object_type={{ object|content_type_id }}&object_id={{ object.pk }}&return_url={% url viewname pk=object.pk %}" class="btn btn-primary"> <span class="mdi mdi-plus-thick" aria-hidden="true"></span> {% trans "Attach an Image" %}
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> {% trans "Attach an Image" %} </a>
</a>
{% endwith %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}

View File

@ -61,19 +61,18 @@
<h2 class="card-header">{% trans "Tagged Item Types" %}</h2> <h2 class="card-header">{% trans "Tagged Item Types" %}</h2>
<ul class="list-group list-group-flush" role="presentation"> <ul class="list-group list-group-flush" role="presentation">
{% for object_type in object_types %} {% for object_type in object_types %}
{% with viewname=object_type.content_type.model_class|validated_viewname:"list" %} {% action_url object_type.content_type.model_class 'list' as list_url %}
{% if viewname %} {% if list_url %}
<a href="{% url viewname %}?tag={{ object.slug }}" class="list-group-item list-group-item-action d-flex justify-content-between"> <a href="{{ list_url }}?tag={{ object.slug }}" class="list-group-item list-group-item-action d-flex justify-content-between">
{{ object_type.content_type.name|bettertitle }} {{ object_type.content_type.name|bettertitle }}
<span class="badge text-bg-primary rounded-pill">{{ object_type.item_count }}</span> <span class="badge text-bg-primary rounded-pill">{{ object_type.item_count }}</span>
</a> </a>
{% else %} {% else %}
<li class="list-group-item list-group-item-action d-flex justify-content-between"> <li class="list-group-item list-group-item-action d-flex justify-content-between">
{{ object_type.content_type.name|bettertitle }} {{ object_type.content_type.name|bettertitle }}
<span class="badge text-bg-primary rounded-pill">{{ object_type.item_count }}</span> <span class="badge text-bg-primary rounded-pill">{{ object_type.item_count }}</span>
</li> </li>
{% endif %} {% endif %}
{% endwith %}
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>

View File

@ -33,7 +33,7 @@ Context:
<ol class="breadcrumb" aria-label="breadcrumbs"> <ol class="breadcrumb" aria-label="breadcrumbs">
{% block breadcrumbs %} {% block breadcrumbs %}
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a href="{% url object|viewname:'list' %}">{{ object|meta:'verbose_name_plural'|bettertitle }}</a> <a href="{% action_url object 'list' %}">{{ object|meta:'verbose_name_plural'|bettertitle }}</a>
</li> </li>
{% endblock breadcrumbs %} {% endblock breadcrumbs %}
</ol> </ol>

View File

@ -10,7 +10,7 @@
</div> </div>
<div class="modal-body row"> <div class="modal-body row">
<form <form
hx-post="{% url model|viewname:"add" %}?_quickadd=True&target={{ request.GET.target }}" hx-post="{% action_url model 'add' %}?_quickadd=True&target={{ request.GET.target }}"
hx-target="#htmx-modal-content" hx-target="#htmx-modal-content"
enctype="multipart/form-data" enctype="multipart/form-data"
> >

View File

@ -5,9 +5,9 @@
<h2 class="card-header">{% trans "Related Objects" %}</h2> <h2 class="card-header">{% trans "Related Objects" %}</h2>
<ul class="list-group list-group-flush" role="presentation"> <ul class="list-group list-group-flush" role="presentation">
{% for qs, filter_param in related_models %} {% for qs, filter_param in related_models %}
{% with viewname=qs.model|validated_viewname:"list" %} {% action_url qs.model 'list' as list_url %}
{% if viewname is not None %} {% if list_url %}
<a href="{% url viewname %}?{{ filter_param }}={{ object.pk }}" class="list-group-item list-group-item-action d-flex justify-content-between"> <a href="{{ list_url }}?{{ filter_param }}={{ object.pk }}" class="list-group-item list-group-item-action d-flex justify-content-between">
{{ qs.model|meta:"verbose_name_plural"|bettertitle }} {{ qs.model|meta:"verbose_name_plural"|bettertitle }}
{% with count=qs.count %} {% with count=qs.count %}
{% if count %} {% if count %}
@ -17,8 +17,7 @@
{% endif %} {% endif %}
{% endwith %} {% endwith %}
</a> </a>
{% endif %} {% endif %}
{% endwith %}
{% empty %} {% empty %}
<span class="list-group-item text-muted">{% trans "None" %}</span> <span class="list-group-item text-muted">{% trans "None" %}</span>
{% endfor %} {% endfor %}

View File

@ -4,12 +4,11 @@
<div class="card"> <div class="card">
<h2 class="card-header">{% trans "Tags" %}</h2> <h2 class="card-header">{% trans "Tags" %}</h2>
<div class="card-body"> <div class="card-body">
{% with url=object|validated_viewname:"list" %} {% action_url object 'list' as url %}
{% for tag in object.tags.all %} {% for tag in object.tags.all %}
{% tag tag url %} {% tag tag url %}
{% empty %} {% empty %}
<span class="text-muted">{% trans "No tags assigned" %}</span> <span class="text-muted">{% trans "No tags assigned" %}</span>
{% endfor %} {% endfor %}
{% endwith %}
</div> </div>
</div> </div>

View File

@ -4,10 +4,8 @@
{% block extra_controls %} {% block extra_controls %}
{% if perms.tenancy.add_contactassignment %} {% if perms.tenancy.add_contactassignment %}
{% with viewname=object|viewname:"contacts" %} <a href="{% url 'tenancy:contactassignment_add' %}?object_type={{ object|content_type_id }}&object_id={{ object.pk }}&return_url={% action_url object 'contacts' pk=object.pk %}" class="btn btn-primary">
<a href="{% url 'tenancy:contactassignment_add' %}?object_type={{ object|content_type_id }}&object_id={{ object.pk }}&return_url={% url viewname pk=object.pk %}" class="btn btn-primary"> <i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add a contact" %}
<i class="mdi mdi-plus-thick" aria-hidden="true"></i> {% trans "Add a contact" %} </a>
</a>
{% endwith %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}