Improve registration report formatting

Show title in list instead of method name.
Add page title and head title to reports.
This commit is contained in:
Joel Addison 2019-10-13 22:22:15 +10:00
parent de9066a4cb
commit 6fb6809316
4 changed files with 12 additions and 4 deletions

View file

@ -2,6 +2,9 @@
{% load bootstrap %} {% load bootstrap %}
{% load registrasion_tags %} {% load registrasion_tags %}
{% block page_title %}Registration report{% endblock %}
{% block head_title %}Registration report - {{ title }}{% endblock %}
{% block content %} {% block content %}
<h2>{{ title }}</h2> <h2>{{ title }}</h2>

View file

@ -1,14 +1,15 @@
{% extends "site_base.html" %} {% extends "site_base.html" %}
{% load registrasion_tags %} {% load registrasion_tags %}
{% block page_title %}Registration reports{% endblock %}
{% block head_title %}Registration reports{% endblock %}
{% block content %} {% block content %}
<h2>Registration reports</h2>
<table class="table table-striped"> <table class="table table-striped">
{% for report in reports %} {% for report in reports %}
<tr> <tr>
<td> <td>
<a href="{{ report.url }}">{{ report.name }}</a> <a href="{{ report.url }}">{{ report.title }}</a>
</td> </td>
<td> <td>
{{ report.description }} {{ report.description }}

View file

@ -78,6 +78,7 @@ class _ReportTemplateWrapper(object):
def count(self): def count(self):
return self.report.count() return self.report.count()
class BasicReport(Report): class BasicReport(Report):
def __init__(self, title, headings, link_view=None): def __init__(self, title, headings, link_view=None):
@ -166,6 +167,7 @@ class QuerysetReport(BasicReport):
def count(self): def count(self):
return self._queryset.count() return self._queryset.count()
class Links(Report): class Links(Report):
def __init__(self, title, links): def __init__(self, title, links):
@ -193,6 +195,7 @@ class Links(Report):
def count(self): def count(self):
return len(self._links) return len(self._links)
def report_view(title, form_type=None): def report_view(title, form_type=None):
''' Decorator that converts a report view function into something that ''' Decorator that converts a report view function into something that
displays a Report. displays a Report.

View file

@ -51,6 +51,7 @@ def reports_list(request):
for report in get_all_reports(): for report in get_all_reports():
reports.append({ reports.append({
"name": report.__name__, "name": report.__name__,
"title": report.title,
"url": reverse(report), "url": reverse(report),
"description": report.__doc__, "description": report.__doc__,
}) })