Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: landing page #513

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
24 changes: 24 additions & 0 deletions apis_core/core/templates/partials/overview_cards.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% 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()
Loading