Skip to content

Commit

Permalink
feat: landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Dec 19, 2023
1 parent 59ed073 commit ecba985
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
5 changes: 5 additions & 0 deletions apis_core/apis_entities/templatetags/apis_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
4 changes: 3 additions & 1 deletion apis_core/core/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@
</div>
{% endif %}

{% block content %}{% endblock %}
{% block content %}
{% include "partials/overview_cards.html" %}
{% endblock %}

</div>
<!-- End main content block -->
Expand Down
23 changes: 23 additions & 0 deletions apis_core/core/templates/partials/overview_cards.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% load apis_templatetags %}
{% load apiscore %}

{% entities as entities %}

<div class="container">
<div class="row">
{% for entity in entities %}
{% if forloop.counter|divisibleby:"3" %}
</div><div class="row">
{% else %}
<div class="col">
<a href="{{ entity.get_listview_url }}" class="text-body">
<div class="card mb-2">
<div class="card-header">{{ entity | contenttype }}</div>
<div class="card-body">{{ entity | count }}</div>
</div>
</a>
</div>
{% endif %}
{% endfor %}
</div>
</div>
11 changes: 11 additions & 0 deletions apis_core/core/templatetags/apiscore.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django import template
from django.conf import settings
from django.contrib.contenttypes.models import ContentType


register = template.Library()
Expand All @@ -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()

0 comments on commit ecba985

Please sign in to comment.