diff --git a/common/models/document.py b/common/models/document.py index 3acf3cd..81fa2e0 100644 --- a/common/models/document.py +++ b/common/models/document.py @@ -8,7 +8,7 @@ import sqlalchemy as sa class Catalog(db.Model): id = db.Column(db.Integer, primary_key=True) - name = db.Column(db.String(50), nullable=False) + name = db.Column(db.String(50), nullable=False, unique=True) description = db.Column(db.Text, nullable=True) type = db.Column(db.String(50), nullable=False, default="STANDARD_CATALOG") diff --git a/eveai_app/templates/document/document_versions.html b/eveai_app/templates/document/document_versions.html index 7c6e80a..9ddc7f0 100644 --- a/eveai_app/templates/document/document_versions.html +++ b/eveai_app/templates/document/document_versions.html @@ -5,16 +5,18 @@ {% block content_title %}Document Versions{% endblock %} {% block content_description %}View Versions for {{ document }}{% endblock %} -{% block content_class %}
{% endblock %} +{% block content_class %}
{% endblock %} {% block content %}
-
+ {{ render_selectable_table(headers=["ID", "URL", "Object Name", "File Type", "Process.", "Proces. Start", "Proces. Finish", "Proces. Error"], rows=rows, selectable=True, id="versionsTable") }} -
- - - +
+
+ + + +
diff --git a/eveai_app/templates/document/document_versions_list_view.html b/eveai_app/templates/document/document_versions_list_view.html index 2a759be..c934068 100644 --- a/eveai_app/templates/document/document_versions_list_view.html +++ b/eveai_app/templates/document/document_versions_list_view.html @@ -37,7 +37,7 @@
- +
diff --git a/eveai_app/templates/user/tenant_overview.html b/eveai_app/templates/user/tenant_overview.html index 11aaa75..dc66a53 100644 --- a/eveai_app/templates/user/tenant_overview.html +++ b/eveai_app/templates/user/tenant_overview.html @@ -1,5 +1,5 @@ {% extends 'base.html' %} -{% from "macros.html" import render_field, render_included_field %} +{% from "macros.html" import render_field, render_included_field, debug_to_console %} {% block title %}Tenant Overview{% endblock %} @@ -9,162 +9,23 @@ {% block content %}
{{ form.hidden_tag() }} - - {% set main_fields = ['name', 'code', 'website', 'default_language', 'allowed_languages', 'type'] %} + {% set disabled_fields = [] %} {% for field in form %} - {{ render_included_field(field, disabled_fields=main_fields, include_fields=main_fields) }} + {{ debug_to_console('field to disable', field.name) }} + {{ debug_to_console('field type to disable', field.type) }} + {% if field.name != 'csrf_token' and field.type != 'HiddenField' %} + {% set disabled_fields = disabled_fields + [field.name] %} + {{ debug_to_console('disable', '!') }} + {% endif %} + {% endfor %} + {{ debug_to_console('disabled_fields', disabled_fields) }} + {% set exclude_fields = [] %} + {% for field in form %} + {{ render_field(field, disabled_fields, exclude_fields) }} {% endfor %} - - -
-
- -
- -
- {% set license_fields = ['currency', 'usage_email', ] %} - {% for field in form %} - {{ render_included_field(field, disabled_fields=license_fields, include_fields=license_fields) }} - {% endfor %} - - - - - - -
-
-
-
{% endblock %} - {% block content_footer %} {% endblock %} - -{% block scripts %} - - -{% endblock %} \ No newline at end of file diff --git a/eveai_app/views/document_forms.py b/eveai_app/views/document_forms.py index a989e3e..ec2fa91 100644 --- a/eveai_app/views/document_forms.py +++ b/eveai_app/views/document_forms.py @@ -17,8 +17,15 @@ from config.type_defs.processor_types import PROCESSOR_TYPES from .dynamic_form_base import DynamicFormBase +def validate_catalog_name(form, field): + # Controleer of een catalog met deze naam al bestaat + existing_catalog = Catalog.query.filter_by(name=field.data).first() + if existing_catalog: + raise ValidationError(f'A Catalog with name "{field.data}" already exists. Choose another name.') + + class CatalogForm(FlaskForm): - name = StringField('Name', validators=[DataRequired(), Length(max=50)]) + name = StringField('Name', validators=[DataRequired(), Length(max=50), validate_catalog_name]) description = TextAreaField('Description', validators=[Optional()]) # Select Field for Catalog Type (Uses the CATALOG_TYPES defined in config) @@ -41,7 +48,7 @@ class CatalogForm(FlaskForm): class EditCatalogForm(DynamicFormBase): - name = StringField('Name', validators=[DataRequired(), Length(max=50)]) + name = StringField('Name', validators=[DataRequired(), Length(max=50), validate_catalog_name]) description = TextAreaField('Description', validators=[Optional()]) # Select Field for Catalog Type (Uses the CATALOG_TYPES defined in config) diff --git a/migrations/tenant/versions/c71facc0ce7e_make_catalog_name_unique.py b/migrations/tenant/versions/c71facc0ce7e_make_catalog_name_unique.py new file mode 100644 index 0000000..ec288f1 --- /dev/null +++ b/migrations/tenant/versions/c71facc0ce7e_make_catalog_name_unique.py @@ -0,0 +1,29 @@ +"""Make Catalog Name Unique + +Revision ID: c71facc0ce7e +Revises: d69520ec540d +Create Date: 2025-06-07 08:38:23.759681 + +""" +from alembic import op +import sqlalchemy as sa +import pgvector +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = 'c71facc0ce7e' +down_revision = 'd69520ec540d' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_unique_constraint(None, 'catalog', ['name']) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ###