Added utils path to pep8 checks
This commit is contained in:
parent
0358670071
commit
b9dc10c99b
@ -6,6 +6,6 @@ import pycodestyle
|
|||||||
def test_pep8_conformance():
|
def test_pep8_conformance():
|
||||||
"""Test that we conform to PEP8."""
|
"""Test that we conform to PEP8."""
|
||||||
pep8style = pycodestyle.StyleGuide()
|
pep8style = pycodestyle.StyleGuide()
|
||||||
dirs = ["./controllers", "./models", "./scripts", "./tests"]
|
dirs = ["./controllers", "./models", "./scripts", "./tests", "./utils"]
|
||||||
result = pep8style.check_files(dirs)
|
result = pep8style.check_files(dirs)
|
||||||
assert result.total_errors == 0
|
assert result.total_errors == 0
|
||||||
|
@ -13,6 +13,7 @@ def allowed_file(filename) -> bool:
|
|||||||
return '.' in filename and \
|
return '.' in filename and \
|
||||||
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||||
|
|
||||||
|
|
||||||
def save_image(file) -> str | None:
|
def save_image(file) -> str | None:
|
||||||
""" Saves a given file to disk with a random UUID4 generated
|
""" Saves a given file to disk with a random UUID4 generated
|
||||||
filename. Returns the filename as a string.
|
filename. Returns the filename as a string.
|
||||||
@ -28,6 +29,7 @@ def save_image(file) -> str | None:
|
|||||||
file.save(os.path.join(path, filename))
|
file.save(os.path.join(path, filename))
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|
||||||
def create_directory(dir: str):
|
def create_directory(dir: str):
|
||||||
""" Creates the given directory string is not alreay made """
|
""" Creates the given directory string is not alreay made """
|
||||||
try:
|
try:
|
||||||
@ -35,6 +37,7 @@ def create_directory(dir: str):
|
|||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def remove_file(dir: str):
|
def remove_file(dir: str):
|
||||||
""" Removes a given file if it is present at the given dir """
|
""" Removes a given file if it is present at the given dir """
|
||||||
try:
|
try:
|
||||||
|
@ -2,12 +2,13 @@ from flask import session
|
|||||||
from models.users.user import User
|
from models.users.user import User
|
||||||
from controllers.database.user import UserController
|
from controllers.database.user import UserController
|
||||||
|
|
||||||
|
|
||||||
def is_logged_in() -> User | None:
|
def is_logged_in() -> User | None:
|
||||||
""" Returns the user object if the user is logged in
|
""" Returns the user object if the user is logged in
|
||||||
Otherwise returns a None type
|
Otherwise returns a None type
|
||||||
"""
|
"""
|
||||||
user_id = session.get('user_id')
|
user_id = session.get('user_id')
|
||||||
|
|
||||||
if user_id is not None:
|
if user_id is not None:
|
||||||
db = UserController()
|
db = UserController()
|
||||||
return db.read_id(user_id)
|
return db.read_id(user_id)
|
||||||
@ -22,4 +23,4 @@ def is_role(role: str) -> bool:
|
|||||||
return user.role == role
|
return user.role == role
|
||||||
|
|
||||||
# User isn't logged in
|
# User isn't logged in
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user