- bug TRA-67 solved by re-introducing a 2-step process. Dynamic Attributes cannot be added to a non-existing, newly created object, it seems.
This commit is contained in:
@@ -572,15 +572,12 @@ def tenant_make():
|
|||||||
form = TenantMakeForm()
|
form = TenantMakeForm()
|
||||||
customisation_config = cache_manager.customisations_config_cache.get_config("CHAT_CLIENT_CUSTOMISATION")
|
customisation_config = cache_manager.customisations_config_cache.get_config("CHAT_CLIENT_CUSTOMISATION")
|
||||||
default_customisation_options = create_default_config_from_type_config(customisation_config["configuration"])
|
default_customisation_options = create_default_config_from_type_config(customisation_config["configuration"])
|
||||||
form.add_dynamic_fields("configuration", customisation_config, default_customisation_options)
|
|
||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
tenant_id = session['tenant']['id']
|
tenant_id = session['tenant']['id']
|
||||||
new_tenant_make = TenantMake()
|
new_tenant_make = TenantMake()
|
||||||
form.populate_obj(new_tenant_make)
|
form.populate_obj(new_tenant_make)
|
||||||
new_tenant_make.tenant_id = tenant_id
|
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
|
# Verwerk allowed_languages als array
|
||||||
new_tenant_make.allowed_languages = form.allowed_languages.data if form.allowed_languages.data else None
|
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))
|
set_logging_information(new_tenant_make, dt.now(tz.utc))
|
||||||
@@ -589,9 +586,10 @@ def tenant_make():
|
|||||||
db.session.add(new_tenant_make)
|
db.session.add(new_tenant_make)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash('Tenant Make successfully added!', 'success')
|
flash('Tenant Make successfully added!', 'success')
|
||||||
current_app.logger.info(f'Tenant Make {new_tenant_make.name} successfully added for tenant {tenant_id}!')
|
current_app.logger.info(f'Tenant Make {new_tenant_make.name}, id {new_tenant_make.id} successfully added '
|
||||||
|
f'for tenant {tenant_id}!')
|
||||||
# Enable step 2 of creation of retriever - add configuration of the retriever (dependent on type)
|
# Enable step 2 of creation of retriever - add configuration of the retriever (dependent on type)
|
||||||
return redirect(prefixed_url_for('user_bp.tenant_makes', tenant_make_id=new_tenant_make.id))
|
return redirect(prefixed_url_for('user_bp.edit_tenant_make', tenant_make_id=new_tenant_make.id))
|
||||||
except SQLAlchemyError as e:
|
except SQLAlchemyError as e:
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
flash(f'Failed to add Tenant Make. Error: {e}', 'danger')
|
flash(f'Failed to add Tenant Make. Error: {e}', 'danger')
|
||||||
|
|||||||
Reference in New Issue
Block a user