finetune Form presentation
Ease the development of future forms Adapt tenant and user forms
This commit is contained in:
@@ -19,7 +19,7 @@ class UserForm(FlaskForm):
|
||||
confirm_password = PasswordField('Confirm Password', validators=[DataRequired(), Length(min=8)])
|
||||
first_name = StringField('First Name', validators=[DataRequired(), Length(max=80)])
|
||||
last_name = StringField('Last Name', validators=[DataRequired(), Length(max=80)])
|
||||
is_active = BooleanField('Is Active')
|
||||
is_active = BooleanField('Is Active', id='flexSwitchCheckDefault')
|
||||
valid_to = DateField('Valid to', id='datepicker')
|
||||
tenant_id = IntegerField('Tenant ID', validators=[NumberRange(min=0)])
|
||||
submit = SubmitField('Submit')
|
||||
|
||||
@@ -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