diff --git a/CHANGELOG.md b/CHANGELOG.md index e5f3f48..e452b5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,10 +20,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - For now removed features. ### Fixed -- For any bug fixes. +- Set default language when registering Documents or URLs. ### Security - In case of vulnerabilities. +- +## [1.0.6-alfa] - 2024-09-03 + +### Fixed +- Problems with tenant scheme migrations - may have to be revisited +- Correction of default language settings when uploading docs or URLs +- Addition of a CHANGELOG.md file ## [1.0.5-alfa] - 2024-09-02 diff --git a/common/models/README.txt b/common/models/README.txt new file mode 100644 index 0000000..14254a2 --- /dev/null +++ b/common/models/README.txt @@ -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! diff --git a/common/utils/document_utils.py b/common/utils/document_utils.py index 7a11fdb..9fcd661 100644 --- a/common/utils/document_utils.py +++ b/common/utils/document_utils.py @@ -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 = { diff --git a/eveai_app/templates/user/tenant_overview.html b/eveai_app/templates/user/tenant_overview.html index 2a63ca5..da08a38 100644 --- a/eveai_app/templates/user/tenant_overview.html +++ b/eveai_app/templates/user/tenant_overview.html @@ -80,7 +80,7 @@
- {% set html_fields = ['html_tags', 'html_end_tags', 'html_included_elements', 'html_excluded_elements', 'min_chunk_size', 'max_chunk_size'] %} + {% set html_fields = ['html_tags', 'html_end_tags', 'html_included_elements', 'html_excluded_elements', 'html_excluded_classes', 'min_chunk_size', 'max_chunk_size'] %} {% for field in form %} {{ render_included_field(field, disabled_fields=html_fields, include_fields=html_fields) }} {% endfor %} diff --git a/eveai_app/views/document_views.py b/eveai_app/views/document_views.py index 45be4e9..b9a3a46 100644 --- a/eveai_app/views/document_views.py +++ b/eveai_app/views/document_views.py @@ -265,8 +265,8 @@ def edit_document_version(document_version_id): @document_bp.route('/document_versions/', methods=['GET', 'POST']) @roles_accepted('Super User', 'Tenant Admin') def document_versions(document_id): - doc_vers = DocumentVersion.query.get_or_404(document_id) - doc_desc = f'Document {doc_vers.document.name}, Language {doc_vers.language}' + doc = Document.query.get_or_404(document_id) + doc_desc = f'Document {doc.name}' page = request.args.get('page', 1, type=int) per_page = request.args.get('per_page', 10, type=int) diff --git a/eveai_workers/Processors/html_processor.py b/eveai_workers/Processors/html_processor.py index db866fc..22f6aef 100644 --- a/eveai_workers/Processors/html_processor.py +++ b/eveai_workers/Processors/html_processor.py @@ -115,9 +115,10 @@ class HTMLProcessor(Processor): def _parse_excluded_classes(self, excluded_classes): parsed = {} - for rule in excluded_classes: - element, cls = rule.split('.', 1) - parsed.setdefault(element, set()).add(cls) + if excluded_classes: + for rule in excluded_classes: + element, cls = rule.split('.', 1) + parsed.setdefault(element, set()).add(cls) return parsed def _should_exclude_element(self, element, excluded_classes):