Skip to content
Snippets Groups Projects
Commit 9812817b authored by Eirik Martin Danielsen's avatar Eirik Martin Danielsen :speech_balloon:
Browse files

edit location done

parent 392e149d
No related branches found
No related tags found
1 merge request!38Resolve "remove dead code and cleanup"
......@@ -8,6 +8,8 @@ import os
from api import limiter
from image_encoder.image_encoder import *
from path_constants import image_type, abs_path_imageai_model, abs_path_imageai_config
import mimetypes
ALLOWED_EXTENSIONS = ['jpg', 'png', 'jpeg']
......@@ -51,6 +53,7 @@ class FindSalamanderInfo(Resource):
def allowed_image(filename):
# return mimetypes.guess_extension(filename).lower() in ALLOWED_EXTENSIONS
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
......
......@@ -79,7 +79,16 @@ class LocationEndpoint(Resource):
location = db.session.query(Location).filter_by(id=data['id']).first()
if location:
if "new_name" in data:
location.name = data['new_radius'].lower()
folder_path = os.path.join("/images", location.name)
if os.path.isdir(folder_path):
new_path = os.rename(folder_path,os.path.join("/images", data['new_name'].lower()))
if not os.path.isdir(folder_path):
os.rename(folder_path,new_path)
location.name = data['new_name'].lower()
else:
return jsonify({"message": "location folder already exists", "status": 400})
else:
return jsonify({"message": "location folder was not found", "status": 400})
if "new_radius" in data:
location.radius = sanitize_int_str(str(data['new_radius']))
if "new_latitude" in data:
......@@ -92,7 +101,8 @@ class LocationEndpoint(Resource):
return jsonify({"message": "location doesn't exist", "status": 400})
else:
return jsonify({"message": "wrong data", "status": 400})
else: return jsonify({"message": "user not admin", "status": 400})
else:
return jsonify({"message": "user not admin", "status": 400})
def create_directory_folders(location):
dir_smooth_male = "images/" + location + "/smooth_newt/" + "male/"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment