- Changed label for specialist_name to chatbot name ==> more logical
- Bug in unique name for catalogs
This commit is contained in:
@@ -6,6 +6,7 @@ from wtforms.validators import DataRequired, Length, Optional, URL, ValidationEr
|
||||
from flask_wtf.file import FileField, FileRequired
|
||||
import json
|
||||
|
||||
from wtforms.widgets.core import HiddenInput
|
||||
from wtforms_sqlalchemy.fields import QuerySelectField
|
||||
|
||||
from common.extensions import cache_manager
|
||||
@@ -20,11 +21,12 @@ 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:
|
||||
if existing_catalog and (not hasattr(form, 'id') or form.id.data != existing_catalog.id):
|
||||
raise ValidationError(f'A Catalog with name "{field.data}" already exists. Choose another name.')
|
||||
|
||||
|
||||
class CatalogForm(FlaskForm):
|
||||
id = IntegerField('ID', widget=HiddenInput())
|
||||
name = StringField('Name', validators=[DataRequired(), Length(max=50), validate_catalog_name])
|
||||
description = TextAreaField('Description', validators=[Optional()])
|
||||
|
||||
@@ -48,6 +50,7 @@ class CatalogForm(FlaskForm):
|
||||
|
||||
|
||||
class EditCatalogForm(DynamicFormBase):
|
||||
id = IntegerField('ID', widget=HiddenInput())
|
||||
name = StringField('Name', validators=[DataRequired(), Length(max=50), validate_catalog_name])
|
||||
description = TextAreaField('Description', validators=[Optional()])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user