mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-26 01:04:00 -04:00
Better bucket name pending possible change to uuid for service primary
key. Also small bugfix around file name and original file name
This commit is contained in:
@@ -6,7 +6,7 @@ from boto3 import resource
|
||||
def s3upload(service_id, filedata):
|
||||
upload_id = str(uuid.uuid4())
|
||||
s3 = resource('s3')
|
||||
bucket_name = 'service-{}-notify'.format(service_id)
|
||||
bucket_name = 'service-{}-{}-notify'.format(service_id, upload_id)
|
||||
s3.create_bucket(Bucket=bucket_name)
|
||||
contents = '\n'.join(filedata['data'])
|
||||
key = s3.Object(bucket_name, upload_id)
|
||||
@@ -16,7 +16,7 @@ def s3upload(service_id, filedata):
|
||||
|
||||
def s3download(service_id, upload_id):
|
||||
s3 = resource('s3')
|
||||
bucket_name = 'service-{}-notify'.format(service_id)
|
||||
bucket_name = 'service-{}-{}-notify'.format(service_id, upload_id)
|
||||
key = s3.Object(bucket_name, upload_id)
|
||||
contents = key.get()['Body'].read().decode('utf-8')
|
||||
return contents
|
||||
|
||||
@@ -64,6 +64,7 @@ def send_sms(service_id):
|
||||
methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def check_sms(service_id, upload_id):
|
||||
|
||||
if request.method == 'GET':
|
||||
contents = s3download(service_id, upload_id)
|
||||
upload_result = _get_numbers(contents)
|
||||
@@ -78,9 +79,10 @@ def check_sms(service_id, upload_id):
|
||||
service_id=service_id
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
file_name = request.form['original_file_name']
|
||||
|
||||
# TODO need a real template id picked from form
|
||||
file_name = request.form['file_name']
|
||||
# TODO - template id should come from form but is not wired in yet.
|
||||
# that will be done in another story
|
||||
template_id = 1
|
||||
|
||||
job_api_client.create_job(service_id, template_id, file_name)
|
||||
|
||||
@@ -21,7 +21,7 @@ class JobApiClient(BaseAPIClient):
|
||||
"service": service_id,
|
||||
"template": template_id,
|
||||
"original_file_name": file_name,
|
||||
"bucket_name": "service-{}-notify".format(service_id),
|
||||
"bucket_name": "service-{}-{}-notify".format(service_id, job_id),
|
||||
"file_name": "{}.csv".format(job_id)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user