- Remove welcome message from tenant make customisation
- Add possibility to add allowed_languages to tenant make
This commit is contained in:
@@ -196,6 +196,14 @@ class TenantMakeForm(DynamicFormBase):
|
||||
active = BooleanField('Active', validators=[Optional()], default=True)
|
||||
website = StringField('Website', validators=[DataRequired(), Length(max=255)])
|
||||
logo_url = StringField('Logo URL', validators=[Optional(), Length(max=255)])
|
||||
allowed_languages = SelectMultipleField('Allowed Languages', choices=[], validators=[Optional()])
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(TenantMakeForm, self).__init__(*args, **kwargs)
|
||||
# Initialiseer de taalopties met taalcodes en vlaggen
|
||||
lang_details = current_app.config['SUPPORTED_LANGUAGE_DETAILS']
|
||||
self.allowed_languages.choices = [(details['iso 639-1'], f"{details['flag']} {details['iso 639-1']}")
|
||||
for name, details in lang_details.items()]
|
||||
|
||||
class EditTenantMakeForm(DynamicFormBase):
|
||||
id = IntegerField('ID', widget=HiddenInput())
|
||||
@@ -204,6 +212,14 @@ class EditTenantMakeForm(DynamicFormBase):
|
||||
active = BooleanField('Active', validators=[Optional()], default=True)
|
||||
website = StringField('Website', validators=[DataRequired(), Length(max=255)])
|
||||
logo_url = StringField('Logo URL', validators=[Optional(), Length(max=255)])
|
||||
allowed_languages = SelectMultipleField('Allowed Languages', choices=[], validators=[Optional()])
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditTenantMakeForm, self).__init__(*args, **kwargs)
|
||||
# Initialiseer de taalopties met taalcodes en vlaggen
|
||||
lang_details = current_app.config['SUPPORTED_LANGUAGE_DETAILS']
|
||||
self.allowed_languages.choices = [(details['iso 639-1'], f"{details['flag']} {details['iso 639-1']}")
|
||||
for name, details in lang_details.items()]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -655,6 +655,8 @@ def tenant_make():
|
||||
new_tenant_make.tenant_id = tenant_id
|
||||
customisation_options = form.get_dynamic_data("configuration")
|
||||
new_tenant_make.chat_customisation_options = json.dumps(customisation_options)
|
||||
# Verwerk allowed_languages als array
|
||||
new_tenant_make.allowed_languages = form.allowed_languages.data if form.allowed_languages.data else None
|
||||
set_logging_information(new_tenant_make, dt.now(tz.utc))
|
||||
|
||||
try:
|
||||
@@ -703,6 +705,10 @@ def edit_tenant_make(tenant_make_id):
|
||||
# Create form instance with the tenant make
|
||||
form = EditTenantMakeForm(request.form, obj=tenant_make)
|
||||
|
||||
# Initialiseer de allowed_languages selectie met huidige waarden
|
||||
if tenant_make.allowed_languages:
|
||||
form.allowed_languages.data = tenant_make.allowed_languages
|
||||
|
||||
customisation_config = cache_manager.customisations_config_cache.get_config("CHAT_CLIENT_CUSTOMISATION")
|
||||
form.add_dynamic_fields("configuration", customisation_config, tenant_make.chat_customisation_options)
|
||||
|
||||
@@ -710,6 +716,8 @@ def edit_tenant_make(tenant_make_id):
|
||||
# Update basic fields
|
||||
form.populate_obj(tenant_make)
|
||||
tenant_make.chat_customisation_options = form.get_dynamic_data("configuration")
|
||||
# Verwerk allowed_languages als array
|
||||
tenant_make.allowed_languages = form.allowed_languages.data if form.allowed_languages.data else None
|
||||
|
||||
# Update logging information
|
||||
update_logging_information(tenant_make, dt.now(tz.utc))
|
||||
|
||||
Reference in New Issue
Block a user