2021-09-27 17:19:05 -04:00
|
|
|
from django import forms
|
|
|
|
from django.utils.translation import gettext as _
|
|
|
|
|
2022-03-09 16:35:47 +00:00
|
|
|
from tenancy.models import *
|
2021-09-27 17:19:05 -04:00
|
|
|
from utilities.forms import DynamicModelChoiceField, DynamicModelMultipleChoiceField
|
|
|
|
|
|
|
|
__all__ = (
|
|
|
|
'TenancyForm',
|
|
|
|
'TenancyFilterForm',
|
2022-03-09 16:35:47 +00:00
|
|
|
'ContactModelFilterForm'
|
2021-09-27 17:19:05 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class TenancyForm(forms.Form):
|
|
|
|
tenant_group = DynamicModelChoiceField(
|
|
|
|
queryset=TenantGroup.objects.all(),
|
|
|
|
required=False,
|
|
|
|
null_option='None',
|
|
|
|
initial_params={
|
|
|
|
'tenants': '$tenant'
|
|
|
|
}
|
|
|
|
)
|
|
|
|
tenant = DynamicModelChoiceField(
|
|
|
|
queryset=Tenant.objects.all(),
|
|
|
|
required=False,
|
|
|
|
query_params={
|
|
|
|
'group_id': '$tenant_group'
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class TenancyFilterForm(forms.Form):
|
|
|
|
tenant_group_id = DynamicModelMultipleChoiceField(
|
|
|
|
queryset=TenantGroup.objects.all(),
|
|
|
|
required=False,
|
|
|
|
null_option='None',
|
2021-12-29 09:30:43 -05:00
|
|
|
label=_('Tenant group')
|
2021-09-27 17:19:05 -04:00
|
|
|
)
|
|
|
|
tenant_id = DynamicModelMultipleChoiceField(
|
|
|
|
queryset=Tenant.objects.all(),
|
|
|
|
required=False,
|
|
|
|
null_option='None',
|
|
|
|
query_params={
|
|
|
|
'group_id': '$tenant_group_id'
|
|
|
|
},
|
2021-12-29 09:30:43 -05:00
|
|
|
label=_('Tenant')
|
2021-09-27 17:19:05 -04:00
|
|
|
)
|
2022-03-09 16:35:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ContactModelFilterForm(forms.Form):
|
|
|
|
contact = DynamicModelMultipleChoiceField(
|
|
|
|
queryset=Contact.objects.all(),
|
|
|
|
required=False,
|
|
|
|
label=_('Contact')
|
|
|
|
)
|
|
|
|
contact_role = DynamicModelMultipleChoiceField(
|
|
|
|
queryset=ContactRole.objects.all(),
|
|
|
|
required=False,
|
|
|
|
label=_('Contact Role')
|
2022-03-09 17:55:45 +00:00
|
|
|
)
|