- Add a default make to the tenant
- Add a make to the SpecialistMagicLink
This commit is contained in:
@@ -25,6 +25,8 @@ class TenantForm(FlaskForm):
|
||||
currency = SelectField('Currency', choices=[], validators=[DataRequired()])
|
||||
# Timezone
|
||||
timezone = SelectField('Timezone', choices=[], validators=[DataRequired()])
|
||||
# Default tenant make
|
||||
default_tenant_make_id = SelectField('Default Tenant Make', choices=[], validators=[Optional()])
|
||||
|
||||
# For Super Users only - Allow to assign the tenant to the partner
|
||||
assign_to_partner = BooleanField('Assign to Partner', default=False)
|
||||
@@ -42,6 +44,13 @@ class TenantForm(FlaskForm):
|
||||
self.timezone.choices = [(tz, tz) for tz in pytz.common_timezones]
|
||||
# Initialize fallback algorithms
|
||||
self.type.choices = [(t, t) for t in current_app.config['TENANT_TYPES']]
|
||||
# Initialize default tenant make choices
|
||||
tenant_id = session.get('tenant', {}).get('id') if 'tenant' in session else None
|
||||
if tenant_id:
|
||||
tenant_makes = TenantMake.query.filter_by(tenant_id=tenant_id, active=True).all()
|
||||
self.default_tenant_make_id.choices = [(str(make.id), make.name) for make in tenant_makes]
|
||||
# Add empty choice
|
||||
self.default_tenant_make_id.choices.insert(0, ('', 'Geen'))
|
||||
# Show field only for Super Users with partner in session
|
||||
if not current_user.has_roles('Super User') or 'partner' not in session:
|
||||
self._fields.pop('assign_to_partner', None)
|
||||
|
||||
Reference in New Issue
Block a user