Refactor Photo model constructor to remove timestamp parameter; update helper function to use getattr for safer attribute access.
This commit is contained in:
parent
e1cb99f2d1
commit
3e0faae851
3 changed files with 4 additions and 3 deletions
|
|
@ -82,6 +82,6 @@ def generate_hashed_filename(file_storage, model_name: str) -> str:
|
|||
|
||||
def get_photo_attachable_class_by_name(name: str):
|
||||
for cls in PhotoAttachable.__subclasses__():
|
||||
if cls.__tablename__ == name:
|
||||
if getattr(cls, '__tablename__', None) == name:
|
||||
return cls
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ def save_photo(file, model: str) -> str:
|
|||
rel_path = generate_hashed_filename(file, model)
|
||||
|
||||
# Absolute path to save
|
||||
assert current_app.static_folder
|
||||
|
||||
abs_path = os.path.join(current_app.static_folder, rel_path)
|
||||
os.makedirs(os.path.dirname(abs_path), exist_ok=True)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue