diff --git a/tailbone/templates/reports/choose.mako b/tailbone/templates/reports/choose.mako index f3caf20c..58c9ee22 100644 --- a/tailbone/templates/reports/choose.mako +++ b/tailbone/templates/reports/choose.mako @@ -97,7 +97,8 @@

Please select the type of report you wish to generate.

- % for key, report in reports.items(): + % for key in sorted_reports: + <% report = reports[key] %>

${h.link_to(report.name, url('generate_specific_report', type_key=key))}

${report.__doc__}

% endfor diff --git a/tailbone/views/reports.py b/tailbone/views/reports.py index ace0a7aa..6f6b1660 100644 --- a/tailbone/views/reports.py +++ b/tailbone/views/reports.py @@ -38,7 +38,7 @@ from rattail.files import resource_path from rattail.time import localtime from rattail.reporting import get_report_handler from rattail.threads import Thread -from rattail.util import simple_error +from rattail.util import simple_error, OrderedDict import colander from deform import widget as dfwidget @@ -297,9 +297,13 @@ class GenerateReport(View): # handler is responsible for determining which report types are valid reports = self.handler.get_reports() + if isinstance(reports, OrderedDict): + sorted_reports = list(reports) + else: + sorted_reports = sorted(reports, key=lambda k: reports[k].name) # make form to accept user choice of report type - schema = NewReport().bind(valid_report_types=list(reports)) + schema = NewReport().bind(valid_report_types=sorted_reports) form = forms.Form(schema=schema, request=self.request, use_buefy=use_buefy) form.submit_label = "Continue" form.cancel_url = self.request.route_url('report_output') @@ -325,6 +329,7 @@ class GenerateReport(View): 'form': form, 'dform': form.make_deform_form(), 'reports': reports, + 'sorted_reports': sorted_reports, 'report_descriptions': dict([(r.type_key, r.__doc__) for r in reports.values()]), 'use_form': self.rattail_config.getbool('tailbone', 'reporting.choosing_uses_form', @@ -346,6 +351,7 @@ class GenerateReport(View): NODE_TYPES = { bool: colander.Boolean, datetime.date: colander.Date, + 'decimal': colander.Decimal, } schema = colander.Schema()