Skip to content

Commit

Permalink
feat(generic): add an import button to the list views
Browse files Browse the repository at this point in the history
resolves #1171
  • Loading branch information
sennierer authored and b1rger committed Sep 25, 2024
1 parent ba68493 commit 7c0c5f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apis_core/generic/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ def get_createview_url(cls):
ct = ContentType.objects.get_for_model(cls)
return reverse("apis_core:generic:create", args=[ct])

@classmethod
def get_importview_url(cls):
ct = ContentType.objects.get_for_model(cls)
return reverse("apis_core:generic:import", args=[ct])

def get_edit_url(self):
ct = ContentType.objects.get_for_model(self)
return reverse("apis_core:generic:update", args=[ct, self.id])
Expand Down
2 changes: 2 additions & 0 deletions apis_core/generic/templates/generic/generic_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
{% 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>
<a class="btn btn-outline-success float-right btn-sm mr-1"
href="{{ object_list.model.get_importview_url }}">Import</a>
{% endif %}
</div>
</div>
Expand Down

0 comments on commit 7c0c5f4

Please sign in to comment.