Added utils path to pep8 checks

This commit is contained in:
2024-01-25 00:08:25 +00:00
parent 0358670071
commit b9dc10c99b
3 changed files with 7 additions and 3 deletions

View File

@ -13,6 +13,7 @@ def allowed_file(filename) -> bool:
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
def save_image(file) -> str | None:
""" Saves a given file to disk with a random UUID4 generated
filename. Returns the filename as a string.
@ -28,6 +29,7 @@ def save_image(file) -> str | None:
file.save(os.path.join(path, filename))
return filename
def create_directory(dir: str):
""" Creates the given directory string is not alreay made """
try:
@ -35,6 +37,7 @@ def create_directory(dir: str):
except FileExistsError:
pass
def remove_file(dir: str):
""" Removes a given file if it is present at the given dir """
try:

View File

@ -2,12 +2,13 @@ from flask import session
from models.users.user import User
from controllers.database.user import UserController
def is_logged_in() -> User | None:
""" Returns the user object if the user is logged in
Otherwise returns a None type
"""
user_id = session.get('user_id')
if user_id is not None:
db = UserController()
return db.read_id(user_id)
@ -22,4 +23,4 @@ def is_role(role: str) -> bool:
return user.role == role
# User isn't logged in
return False
return False