diff --git a/apis_core/apis_entities/templatetags/apis_templatetags.py b/apis_core/apis_entities/templatetags/apis_templatetags.py index a75709c18..57d26d4b1 100644 --- a/apis_core/apis_entities/templatetags/apis_templatetags.py +++ b/apis_core/apis_entities/templatetags/apis_templatetags.py @@ -32,3 +32,8 @@ def entities_list_links(): entities_links.sort(key=itemgetter(1)) return entities_links + + +@register.simple_tag +def entities(): + return caching.get_all_entity_classes() or [] diff --git a/apis_core/core/templates/base.html b/apis_core/core/templates/base.html index 0c2cedcef..296015ff1 100644 --- a/apis_core/core/templates/base.html +++ b/apis_core/core/templates/base.html @@ -192,7 +192,9 @@ {% endif %} - {% block content %}{% endblock %} + {% block content %} + {% include "partials/overview_cards.html" %} + {% endblock %} diff --git a/apis_core/core/templates/partials/overview_cards.html b/apis_core/core/templates/partials/overview_cards.html new file mode 100644 index 000000000..e72f77361 --- /dev/null +++ b/apis_core/core/templates/partials/overview_cards.html @@ -0,0 +1,24 @@ +{% load apis_templatetags %} +{% load apiscore %} +{% entities as entities %} +
+
+ {% for entity in entities %} + + {% if forloop.counter|divisibleby:"3" %} +
+
+ {% else %} + + {% endif %} + + {% endfor %} +
+
diff --git a/apis_core/core/templatetags/apiscore.py b/apis_core/core/templatetags/apiscore.py index e001c1a30..b12073018 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,13 @@ 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) + + +@register.filter +def count(model): + return model.__class__.objects.count()