asset_submissions: respect hat case-sensitivity.

Unlike Marsey names and tags, we display hat names & descriptions
with respect for capitalization. The filesystem and database treat
hat names as case-sensitive too, so there's no risk of conflict.
master
Snakes 2022-09-10 03:42:09 -04:00
parent 0950dc81b8
commit 7586dfdbc8
Signed by: Snakes
GPG Key ID: E745A82778055C7E
1 changed files with 6 additions and 6 deletions

View File

@ -190,7 +190,7 @@ def submit_hat(v):
if not file or not file.content_type.startswith('image/'): if not file or not file.content_type.startswith('image/'):
return error("You need to submit an image!") return error("You need to submit an image!")
name = request.values.get('name').lower().strip() name = request.values.get('name').strip()
if not hat_regex.fullmatch(name): if not hat_regex.fullmatch(name):
return error("Invalid name!") return error("Invalid name!")
@ -198,7 +198,7 @@ def submit_hat(v):
if existing: if existing:
return error("A hat with this name already exists!") return error("A hat with this name already exists!")
description = request.values.get('description').lower().strip() description = request.values.get('description').strip()
if not description_regex.fullmatch(description): if not description_regex.fullmatch(description):
return error("Invalid description!") return error("Invalid description!")
@ -232,17 +232,17 @@ def approve_hat(v, name):
if CARP_ID and v.id != CARP_ID: if CARP_ID and v.id != CARP_ID:
return {"error": "Only Carp can approve hats!"}, 403 return {"error": "Only Carp can approve hats!"}, 403
name = name.lower().strip() name = name.strip()
hat = g.db.query(HatDef).filter_by(name=name).one_or_none() hat = g.db.query(HatDef).filter_by(name=name).one_or_none()
if not hat: if not hat:
return {"error": f"This hat '{name}' doesn't exist!"}, 404 return {"error": f"This hat '{name}' doesn't exist!"}, 404
description = request.values.get('description').lower().strip() description = request.values.get('description').strip()
if not description: if not description:
return {"error": "You need to include description!"}, 400 return {"error": "You need to include description!"}, 400
new_name = request.values.get('name').lower().strip() new_name = request.values.get('name').strip()
if not new_name: if not new_name:
return {"error": "You need to include name!"}, 400 return {"error": "You need to include name!"}, 400
@ -295,7 +295,7 @@ def reject_hat(v, name):
if CARP_ID and v.id != CARP_ID: if CARP_ID and v.id != CARP_ID:
return {"error": "Only Carp can reject hats!"}, 403 return {"error": "Only Carp can reject hats!"}, 403
name = name.lower().strip() name = name.strip()
hat = g.db.query(HatDef).filter_by(name=name).one_or_none() hat = g.db.query(HatDef).filter_by(name=name).one_or_none()
if not hat: if not hat: