mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 22:40:31 -04:00
Show all pages of a letter everywhere
Right now showing all the pages in full is the only way we have of showing a letter that makes sense to our users. Maybe in the future we show some kind of truncated version, but the end of the first page is not a good place to truncate the letter. This commit just extracts the code for showing multiple pages from the template view, refactors it for reuse, and includes it in the send views.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from flask import current_app
|
||||
from flask import current_app, json
|
||||
import requests
|
||||
|
||||
from app import current_service
|
||||
@@ -32,3 +32,14 @@ class TemplatePreview:
|
||||
template.values,
|
||||
page=page,
|
||||
)
|
||||
|
||||
|
||||
def get_page_count_for_letter(template, values=None):
|
||||
|
||||
if template['template_type'] != 'letter':
|
||||
return None
|
||||
|
||||
page_count, _, _ = TemplatePreview.from_database_object(template, values, filetype='json')
|
||||
page_count = json.loads(page_count.decode('utf-8'))['count']
|
||||
|
||||
return page_count
|
||||
|
||||
Reference in New Issue
Block a user