mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 16:38:59 -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:
@@ -29,6 +29,7 @@ from app.main.forms import (
|
||||
)
|
||||
from app.main.views.send import get_example_csv_rows, get_sender_details
|
||||
from app.models.service import Service
|
||||
from app.models.template_list import TemplateList
|
||||
from app.template_previews import TemplatePreview, get_page_count_for_letter
|
||||
from app.utils import (
|
||||
email_or_sms_not_enabled,
|
||||
@@ -126,9 +127,7 @@ def choose_template(service_id, template_type='all', template_folder_id=None):
|
||||
current_template_folder_id=template_folder_id,
|
||||
can_manage_folders=can_manage_folders(),
|
||||
template_folder_path=current_service.get_template_folder_path(template_folder_id),
|
||||
template_folder_has_contents=current_service.get_template_folders_and_templates('all', template_folder_id),
|
||||
template_folders=current_service.get_template_folders(template_type, template_folder_id),
|
||||
templates=current_service.get_templates(template_type, template_folder_id),
|
||||
template_list=TemplateList(current_service, template_type, template_folder_id),
|
||||
show_search_box=current_service.count_of_templates_and_folders > 7,
|
||||
show_template_nav=(
|
||||
current_service.has_multiple_template_types
|
||||
|
||||
Reference in New Issue
Block a user