Skip to content

Commit

Permalink
refactor(apis_entities,generic): use model getters for retrieving urls
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed May 14, 2024
1 parent 4587783 commit 4fe8444
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
9 changes: 3 additions & 6 deletions apis_core/apis_entities/templates/columns/duplicate.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{% load apiscore %}
{% with record|opts as opts %}
<a title="duplicate"
href="{% url 'apis_core:apis_entities:generic_entities_duplicate_view' opts.verbose_name record.id %}"
style="color: blueviolet"><span class="material-symbols-outlined">content_copy</span></a>
{% endwith %}
<a title="duplicate"
href="{{ record.get_duplicate_url }}"
style="color: blueviolet"><span class="material-symbols-outlined">content_copy</span></a>
13 changes: 3 additions & 10 deletions apis_core/generic/templates/generic/generic_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,9 @@
<div class="row">
<div class="col">{{ object_list.model|contenttype }}</div>
<div class="col">
{% with object_list.model|opts as opts %}
{% with opts.app_label|add:"."|add:opts.verbose_name|add:"_create" as object_create_perm %}

{% if object_create_perm in perms %}
<a class="btn btn-outline-success float-right btn-sm"
href="{% url 'apis_core:generic:create' object_list.model|contenttype %}">Create</a>
{% endif %}

{% endwith %}
{% endwith %}
{% if object_list.model.get_add_permission in perms %}
<a class="btn btn-outline-success float-right btn-sm" href="{{ object_list.model.get_createview_url }}">Create</a>
{% endif %}
</div>
</div>
</div>
Expand Down

0 comments on commit 4fe8444

Please sign in to comment.