mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-24 09:58:43 -04:00
Refactored to use kwarg
This commit is contained in:
@@ -5,8 +5,8 @@ from flask import current_app
|
||||
from notifications_utils.s3 import s3upload as utils_s3upload
|
||||
|
||||
FILE_LOCATION_STRUCTURE = 'service-{}-notify/{}.csv'
|
||||
TEMP_TAG = 'temp-{}_'
|
||||
LOGO_LOCATION_STRUCTURE = '{}{}-{}'
|
||||
TEMP_TAG = 'temp-{user_id}_'
|
||||
LOGO_LOCATION_STRUCTURE = '{temp}{unique_id}-{filename}'
|
||||
|
||||
|
||||
def s3upload(service_id, filedata, region):
|
||||
@@ -35,8 +35,11 @@ def s3download(service_id, upload_id):
|
||||
|
||||
|
||||
def upload_logo(filename, filedata, region, user_id):
|
||||
upload_id = str(uuid.uuid4())
|
||||
upload_file_name = LOGO_LOCATION_STRUCTURE.format(TEMP_TAG.format(user_id), upload_id, filename)
|
||||
upload_file_name = LOGO_LOCATION_STRUCTURE.format(
|
||||
temp=TEMP_TAG.format(user_id=user_id),
|
||||
unique_id=str(uuid.uuid4()),
|
||||
filename=filename
|
||||
)
|
||||
utils_s3upload(filedata=filedata,
|
||||
region=region,
|
||||
bucket_name=current_app.config['LOGO_UPLOAD_BUCKET_NAME'],
|
||||
@@ -47,7 +50,7 @@ def upload_logo(filename, filedata, region, user_id):
|
||||
|
||||
def persist_logo(filename, user_id):
|
||||
try:
|
||||
if filename.startswith(TEMP_TAG.format(user_id)):
|
||||
if filename.startswith(TEMP_TAG.format(user_id=user_id)):
|
||||
persisted_filename = filename[len(TEMP_TAG.format(user_id)):]
|
||||
else:
|
||||
return filename
|
||||
|
||||
@@ -65,7 +65,7 @@ def manage_org(logo=None):
|
||||
user_id=session["user_id"]
|
||||
)
|
||||
|
||||
if logo and logo.startswith(TEMP_TAG.format(session['user_id'])):
|
||||
if logo and logo.startswith(TEMP_TAG.format(user_id=session['user_id'])):
|
||||
delete_temp_file(logo)
|
||||
|
||||
return redirect(
|
||||
@@ -84,7 +84,6 @@ def manage_org(logo=None):
|
||||
org_id = resp['data']['id']
|
||||
|
||||
return redirect(url_for('.organisations', organisation_id=org_id))
|
||||
|
||||
if org:
|
||||
form.name.data = org['name']
|
||||
form.colour.data = org['colour']
|
||||
|
||||
@@ -26,7 +26,7 @@ class OrganisationsClient(NotifyAdminAPIClient):
|
||||
"name": name,
|
||||
"colour": colour
|
||||
}
|
||||
return self.post("/organisation", data)
|
||||
return self.post(url="/organisation", data=data)
|
||||
|
||||
def update_organisation(self, org_id, logo, name, colour):
|
||||
data = {
|
||||
@@ -34,4 +34,4 @@ class OrganisationsClient(NotifyAdminAPIClient):
|
||||
"name": name,
|
||||
"colour": colour
|
||||
}
|
||||
return self.post("/organisation/{}".format(org_id), data)
|
||||
return self.post(url="/organisation/{}".format(org_id), data=data)
|
||||
|
||||
Reference in New Issue
Block a user