Skip to content
Snippets Groups Projects
Commit 97b46ece authored by Herman Andersen Dyrkorn's avatar Herman Andersen Dyrkorn
Browse files

Merge branch '38-fix-temp-image-bug' into 'master'

Resolve "fix temp image bug"

Closes #38

See merge request !41
parents c6d92dd2 d1541ac2
Branches
No related tags found
1 merge request!41Resolve "fix temp image bug"
......@@ -7,6 +7,7 @@ import os
from api import limiter
from image_encoder.image_encoder import *
from path_constants import image_type
import glob
# import mimetypes
ALLOWED_EXTENSIONS = ['jpg', 'png', 'jpeg']
......@@ -25,6 +26,9 @@ class FindSalamanderInfo(Resource):
if image.filename != '':
if image and allowed_image(image.filename):
temp_img_path = os.path.abspath("./temp_images/")
list_of_temp_images = glob.glob(os.path.join(temp_img_path, str(user_id) + '*.*'))
for temp_image in list_of_temp_images:
os.remove(temp_image)
image.filename = str(user_id) + "." + extension(image.filename)
image.save(os.path.join(temp_img_path, image.filename))
......
......@@ -8,6 +8,7 @@ import re
import os
from api.endpoints.matchsalamander import sanitize_int_str
from path_constants import _ACCESS_DATABASE
LATITUDE_REGEX = "^(\\+|-)?(?:90(?:(?:\\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\\.[0-9]{1,6})?))$"
LONGITUDE_REGEX = "^(\\+|-)?(?:180(?:(?:\\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\\.[0-9]{1,6})?))$"
......@@ -76,7 +77,8 @@ class LocationEndpoint(Resource):
else:
return jsonify({"message": "location doesn't exist", "status": 400})
else:
return jsonify({"message": "location needs to be empty." + " There are " + str(len(salamanders))
return jsonify(
{"message": "location needs to be empty." + " There are " + str(len(salamanders))
+ " salamanders in this location.", "status": 400})
else:
return jsonify({"message": "query failed", "status": 400})
......
......@@ -8,10 +8,10 @@ from api import db, limiter
from api.models.dbmodels import Salamander, SalamanderGrowth, Location
from algorithm.brute_force_matching import match_file_structure
from path_constants import _ACCESS_DATABASE
import glob
APPROVED_SEX = ["male", "female", "juvenile"]
APPROVED_SPECIES = ["smooth_newt", "northern_crested_newt"]
import glob
# matchSalamander endpoint
......
......@@ -8,6 +8,7 @@ import glob
from image_encoder.image_encoder import *
from path_constants import _ACCESS_DATABASE
# get all images on a specific salamander based on id
class SalamanderEndpoint(Resource):
decorators = [limiter.limit("60/minute")]
......
......@@ -10,6 +10,7 @@ import glob
from shutil import move
from path_constants import _ACCESS_DATABASE
class SalamanderClass(Resource):
decorators = [limiter.limit("60/minute")]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment