mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Refactor template list logic into one place
The Jinja template for the ‘choose templates’ page is now pulling in data from a lot of diparate places in order to work out what to show. As we add more logic about what to show (in order to make the live search work) it’s going to get harder to have all this logic in the Jinja template. This commit refactors it back into Python where we have more language features for managing complex logic. It’s a bit weird to call this file a model, in that it’s dealing with some presentational logic, rather than just data. Conceptually it’s more like a view model[1]. 1. https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel
This commit is contained in:
@@ -55,26 +55,3 @@
|
||||
{%- endif -%}
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
{% macro folder_contents_count(number_of_folders, number_of_templates) %}
|
||||
|
||||
{% if number_of_folders == number_of_templates == 0 %}
|
||||
Empty
|
||||
{% endif %}
|
||||
|
||||
{% if number_of_templates == 1 %}
|
||||
{{ number_of_templates }} template
|
||||
{%- elif number_of_templates > 1 -%}
|
||||
{{ number_of_templates }} templates
|
||||
{%- endif -%}
|
||||
|
||||
{%- if number_of_folders and number_of_templates %}, {% endif -%}
|
||||
|
||||
{%- if number_of_folders == 1 -%}
|
||||
{{ number_of_folders }} folder
|
||||
{%- elif number_of_folders > 1 -%}
|
||||
{{ number_of_folders }} folders
|
||||
{% endif %}
|
||||
|
||||
{%- endmacro %}
|
||||
|
||||
Reference in New Issue
Block a user