mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Add an endpoint to download a contact list
In case you need to download it, modify it, and re-upload it when you don’t have access to the existing list.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from os import path
|
||||
|
||||
from flask import abort, current_app
|
||||
from notifications_utils.formatters import strip_whitespace
|
||||
from notifications_utils.recipients import RecipientCSV
|
||||
@@ -103,15 +105,24 @@ class ContactList(JSONModel):
|
||||
template_type=metadata['template_type'],
|
||||
))
|
||||
|
||||
@property
|
||||
def contents(self):
|
||||
return self.download(self.service_id, self.id)
|
||||
|
||||
@cached_property
|
||||
def recipients(self):
|
||||
return RecipientCSV(
|
||||
self.download(self.service_id, self.id),
|
||||
self.contents,
|
||||
template_type=self.template_type,
|
||||
international_sms=True,
|
||||
max_initial_rows_shown=50,
|
||||
)
|
||||
|
||||
@property
|
||||
def saved_file_name(self):
|
||||
file_name, extention = path.splitext(self.original_file_name)
|
||||
return f'{file_name}.csv'
|
||||
|
||||
|
||||
class ContactLists(ModelList):
|
||||
client_method = contact_list_api_client.get_contact_lists
|
||||
|
||||
Reference in New Issue
Block a user