mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-22 08:58:46 -04:00
Refactor to move preview logic to API
* Moved the notifications code to go to admin to get the the template preview document rather than go to template preview. This will remove the logic from admin and place it in api so it is easier to expand on later when there are precompiled PDFs * Added some error handling if API returns an API error. Caught the error and displayed an error PNG so it is obvious something failed. Currently it displayed a thumbnail of a png over the top of the loading page, and therefore it wasn't obvious of the state.
This commit is contained in:
@@ -73,3 +73,14 @@ class NotificationApiClient(NotifyAdminAPIClient):
|
||||
if notification['notification_type'] == 'letter' and notification['status'] in ('created', 'sending'):
|
||||
notification['status'] = 'accepted'
|
||||
return notifications
|
||||
|
||||
def get_notification_letter_preview(self, service_id, notification_id, file_type, page=None):
|
||||
|
||||
get_url = '/service/{}/template/preview/{}/{}{}'.format(
|
||||
service_id,
|
||||
notification_id,
|
||||
file_type,
|
||||
'?page={}'.format(page) if page else ''
|
||||
)
|
||||
|
||||
return self.get(url=get_url)
|
||||
|
||||
Reference in New Issue
Block a user