finetune Form presentation
Ease the development of future forms Adapt tenant and user forms
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user