finetune Form presentation

Ease the development of future forms
Adapt tenant and user forms
This commit is contained in:
Josako
2024-04-26 18:17:42 +02:00
parent 9c1a3e8f55
commit e8f97b7317
9 changed files with 106 additions and 79 deletions

View File

@@ -64,6 +64,20 @@ def tenant():
return render_template('user/tenant.html', form=form)
@user_bp.route('/tenant/<int:tenant_id>', methods=['GET', 'POST'])
def edit_tenant(tenant_id):
tenant = Tenant.query.get_or_404(tenant_id) # This will return a 404 if no tenant is found
form = TenantForm(obj=tenant)
if request.method == 'POST' and form.validate_on_submit():
# Populate the tenant with form data
form.populate_obj(tenant)
db.session.commit()
flash('User updated successfully.', 'success')
return redirect(url_for(f"user/tenant/tenant_id"))
return render_template('user/edit_tenant.html', form=form, tenant_id=tenant_id)
@user_bp.route('/user', methods=['GET', 'POST'])
def user():
form = UserForm()