mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-18 13:39:57 -04:00
Download CSV option now available.
This commit is contained in:
22
app/utils.py
22
app/utils.py
@@ -1,5 +1,6 @@
|
||||
import re
|
||||
|
||||
import csv
|
||||
from io import StringIO
|
||||
from functools import wraps
|
||||
from flask import (abort, session, request, url_for)
|
||||
|
||||
@@ -85,6 +86,25 @@ def get_errors_for_csv(recipients, template_type):
|
||||
return errors
|
||||
|
||||
|
||||
def generate_notifications_csv(json_list):
|
||||
from app import format_datetime
|
||||
content = StringIO()
|
||||
retval = None
|
||||
with content as csvfile:
|
||||
csvwriter = csv.writer(csvfile)
|
||||
csvwriter.writerow(['Recipient', 'Template', 'Type', 'Job', 'Status', 'Time'])
|
||||
for x in json_list:
|
||||
csvwriter.writerow([
|
||||
x['to'],
|
||||
x['template']['name'],
|
||||
x['template']['template_type'],
|
||||
x['job']['original_file_name'],
|
||||
x['status'],
|
||||
format_datetime(x['created_at'])])
|
||||
retval = content.getvalue()
|
||||
return retval
|
||||
|
||||
|
||||
def get_page_from_request():
|
||||
if 'page' in request.args:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user