This commit is contained in:
Michał 2023-04-21 17:49:08 +00:00
parent e69ac64855
commit e3c25a5241
3 changed files with 3 additions and 6 deletions

View file

@ -1,7 +1,6 @@
""" """
Onlylegs - API endpoints Onlylegs - API endpoints
""" """
from uuid import uuid4
import os import os
import pathlib import pathlib
import re import re
@ -31,7 +30,7 @@ def account_picture(user_id):
# If no image is uploaded, return 404 error # If no image is uploaded, return 404 error
if not file: if not file:
return jsonify({"error": "No file uploaded"}), 400 return jsonify({"error": "No file uploaded"}), 400
elif user.id != current_user.id: if user.id != current_user.id:
return jsonify({"error": "You are not allowed to do this, go away"}), 403 return jsonify({"error": "You are not allowed to do this, go away"}), 403
# Get file extension, generate random name and set file path # Get file extension, generate random name and set file path
@ -84,7 +83,7 @@ def account_username(user_id):
# Validate the form # Validate the form
if not new_name or not username_regex.match(new_name): if not new_name or not username_regex.match(new_name):
return jsonify({"error": "Username is invalid"}), 400 return jsonify({"error": "Username is invalid"}), 400
elif user.id != current_user.id: if user.id != current_user.id:
return jsonify({"error": "You are not allowed to do this, go away"}), 403 return jsonify({"error": "You are not allowed to do this, go away"}), 403
# Save to database # Save to database

View file

@ -2,7 +2,6 @@
Onlylegs - API endpoints Onlylegs - API endpoints
Media upload and retrieval Media upload and retrieval
""" """
import os
from uuid import uuid4 from uuid import uuid4
import os import os
import pathlib import pathlib

View file

@ -1,11 +1,10 @@
""" """
Tools for generating images and thumbnails Tools for generating images and thumbnails
""" """
import os import os
from PIL import Image, ImageOps from PIL import Image, ImageOps
from onlylegs.config import MEDIA_FOLDER, CACHE_FOLDER
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
from onlylegs.config import MEDIA_FOLDER, CACHE_FOLDER
def generate_thumbnail(file_path, resolution, ext=None): def generate_thumbnail(file_path, resolution, ext=None):