- Changed label for specialist_name to chatbot name ==> more logical
- Bug in unique name for catalogs
This commit is contained in:
@@ -11,9 +11,9 @@ arguments:
|
|||||||
type: "str"
|
type: "str"
|
||||||
required: true
|
required: true
|
||||||
specialist_name:
|
specialist_name:
|
||||||
name: "Specialist Name"
|
name: "Chatbot Name"
|
||||||
description: "The name the specialist will be called upon"
|
description: "The name of the chatbot."
|
||||||
type: str
|
type: "str"
|
||||||
required: true
|
required: true
|
||||||
role_reference:
|
role_reference:
|
||||||
name: "Role Reference"
|
name: "Role Reference"
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ arguments:
|
|||||||
type: "str"
|
type: "str"
|
||||||
required: true
|
required: true
|
||||||
specialist_name:
|
specialist_name:
|
||||||
name: "Specialist Name"
|
name: "Chatbot Name"
|
||||||
description: "The name the specialist will be called upon"
|
description: "The name of the chatbot."
|
||||||
type: "str"
|
type: "str"
|
||||||
required: true
|
required: true
|
||||||
make:
|
make:
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from wtforms.validators import DataRequired, Length, Optional, URL, ValidationEr
|
|||||||
from flask_wtf.file import FileField, FileRequired
|
from flask_wtf.file import FileField, FileRequired
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from wtforms.widgets.core import HiddenInput
|
||||||
from wtforms_sqlalchemy.fields import QuerySelectField
|
from wtforms_sqlalchemy.fields import QuerySelectField
|
||||||
|
|
||||||
from common.extensions import cache_manager
|
from common.extensions import cache_manager
|
||||||
@@ -20,11 +21,12 @@ from .dynamic_form_base import DynamicFormBase
|
|||||||
def validate_catalog_name(form, field):
|
def validate_catalog_name(form, field):
|
||||||
# Controleer of een catalog met deze naam al bestaat
|
# Controleer of een catalog met deze naam al bestaat
|
||||||
existing_catalog = Catalog.query.filter_by(name=field.data).first()
|
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.')
|
raise ValidationError(f'A Catalog with name "{field.data}" already exists. Choose another name.')
|
||||||
|
|
||||||
|
|
||||||
class CatalogForm(FlaskForm):
|
class CatalogForm(FlaskForm):
|
||||||
|
id = IntegerField('ID', widget=HiddenInput())
|
||||||
name = StringField('Name', validators=[DataRequired(), Length(max=50), validate_catalog_name])
|
name = StringField('Name', validators=[DataRequired(), Length(max=50), validate_catalog_name])
|
||||||
description = TextAreaField('Description', validators=[Optional()])
|
description = TextAreaField('Description', validators=[Optional()])
|
||||||
|
|
||||||
@@ -48,6 +50,7 @@ class CatalogForm(FlaskForm):
|
|||||||
|
|
||||||
|
|
||||||
class EditCatalogForm(DynamicFormBase):
|
class EditCatalogForm(DynamicFormBase):
|
||||||
|
id = IntegerField('ID', widget=HiddenInput())
|
||||||
name = StringField('Name', validators=[DataRequired(), Length(max=50), validate_catalog_name])
|
name = StringField('Name', validators=[DataRequired(), Length(max=50), validate_catalog_name])
|
||||||
description = TextAreaField('Description', validators=[Optional()])
|
description = TextAreaField('Description', validators=[Optional()])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user