diff --git a/apis_core/core/templatetags/apiscore.py b/apis_core/core/templatetags/apiscore.py index e001c1a30..3663ee880 100644 --- a/apis_core/core/templatetags/apiscore.py +++ b/apis_core/core/templatetags/apiscore.py @@ -1,5 +1,6 @@ from django import template from django.conf import settings +from django.contrib.contenttypes.models import ContentType register = template.Library() @@ -13,3 +14,8 @@ def shared_url(): @register.simple_tag def page_range(paginator, number): return paginator.get_elided_page_range(number=number) + + +@register.filter +def contenttype(model): + return ContentType.objects.get_for_model(model) diff --git a/apis_core/generic/tables.py b/apis_core/generic/tables.py new file mode 100644 index 000000000..3a2ebf625 --- /dev/null +++ b/apis_core/generic/tables.py @@ -0,0 +1,13 @@ +import django_tables2 as tables +from django.urls import reverse +from django.contrib.contenttypes.models import ContentType + + +class GenericTable(tables.Table): + desc = tables.Column(empty_values=(), linkify=lambda record: reverse("apis_core:generic:genericdetail", args=[ContentType.objects.get_for_model(record), record.pk])) + + class Meta: + fields = ['id', 'desc'] + + def render_desc(self, record): + return str(record) diff --git a/apis_core/generic/templates/generic/generic_confirm_delete.html b/apis_core/generic/templates/generic/generic_confirm_delete.html new file mode 100644 index 000000000..6cf5240c5 --- /dev/null +++ b/apis_core/generic/templates/generic/generic_confirm_delete.html @@ -0,0 +1,32 @@ +{% extends basetemplate|default:"base.html" %} + +{% block content %} +