- Add a default make to the tenant

- Add a make to the SpecialistMagicLink
This commit is contained in:
Josako
2025-06-09 18:13:38 +02:00
parent 199cf94cf2
commit 3f77871c4f
8 changed files with 153 additions and 5 deletions

View File

@@ -691,9 +691,13 @@ def specialist_magic_link():
try:
new_specialist_magic_link = SpecialistMagicLink()
# Populate fields individually instead of using populate_obj (gives problem with QueryMultipleSelectField)
# Populate fields individually instead of using populate_obj
form.populate_obj(new_specialist_magic_link)
# Handle the tenant_make_id special case (0 = None)
if form.tenant_make_id.data == 0:
new_specialist_magic_link.tenant_make_id = None
set_logging_information(new_specialist_magic_link, dt.now(tz.utc))
# Create 'public' SpecialistMagicLinkTenant
@@ -733,12 +737,23 @@ def edit_specialist_magic_link(specialist_magic_link_id):
form.add_dynamic_fields("arguments", specialist_config, specialist_ml.specialist_args)
# Set the tenant_make_id default value
if request.method == 'GET':
if specialist_ml.tenant_make_id is None:
form.tenant_make_id.data = 0
else:
form.tenant_make_id.data = specialist_ml.tenant_make_id
if form.validate_on_submit():
# Update the basic fields
form.populate_obj(specialist_ml)
# Update the arguments dynamic fields
specialist_ml.specialist_args = form.get_dynamic_data("arguments")
# Handle the tenant_make_id special case (0 = None)
if form.tenant_make_id.data == 0:
specialist_ml.tenant_make_id = None
# Update logging information
update_logging_information(specialist_ml, dt.now(tz.utc))