- Bugfixing

This commit is contained in:
Josako
2024-09-05 14:31:54 +02:00
parent 1fa33c029b
commit 341ba47d1c
6 changed files with 38 additions and 7 deletions

2
common/models/README.txt Normal file
View File

@@ -0,0 +1,2 @@
If models are added to the public schema (i.e. in the user domain), ensure to add their corresponding tables to the
env.py, get_public_table_names, for tenant migrations!

View File

@@ -5,6 +5,7 @@ from common.models.document import Document, DocumentVersion
from common.extensions import db, minio_client
from common.utils.celery_utils import current_celery
from flask import current_app
from flask_security import current_user
import requests
from urllib.parse import urlparse, unquote
import os
@@ -109,10 +110,30 @@ def set_logging_information(obj, timestamp):
obj.created_at = timestamp
obj.updated_at = timestamp
user_id = get_current_user_id()
if user_id:
obj.created_by = user_id
obj.updated_by = user_id
def update_logging_information(obj, timestamp):
obj.updated_at = timestamp
user_id = get_current_user_id()
if user_id:
obj.updated_by = user_id
def get_current_user_id():
try:
if current_user and current_user.is_authenticated:
return current_user.id
else:
return None
except Exception:
# This will catch any errors if current_user is not available (e.g., in API context)
return None
def get_extension_from_content_type(content_type):
content_type_map = {