Coverage for tenancy/forms/forms.py: 100%
15 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 18:35 +0000
1from django import forms
2from django.utils.translation import gettext_lazy as _
4from utilities.forms.fields import DynamicModelChoiceField, DynamicModelMultipleChoiceField
6from ..models import *
8__all__ = (
9 'ContactModelFilterForm',
10 'TenancyFilterForm',
11 'TenancyForm',
12)
15class TenancyForm(forms.Form):
16 tenant_group = DynamicModelChoiceField(
17 label=_('Tenant group'),
18 queryset=TenantGroup.objects.all(),
19 required=False,
20 null_option='None',
21 initial_params={
22 'tenants': '$tenant'
23 }
24 )
25 tenant = DynamicModelChoiceField(
26 label=_('Tenant'),
27 queryset=Tenant.objects.all(),
28 required=False,
29 quick_add=True,
30 query_params={
31 'group_id': '$tenant_group'
32 }
33 )
36class TenancyFilterForm(forms.Form):
37 tenant_group_id = DynamicModelMultipleChoiceField(
38 queryset=TenantGroup.objects.all(),
39 required=False,
40 null_option='None',
41 label=_('Tenant group')
42 )
43 tenant_id = DynamicModelMultipleChoiceField(
44 queryset=Tenant.objects.all(),
45 required=False,
46 null_option='None',
47 query_params={
48 'group_id': '$tenant_group_id'
49 },
50 label=_('Tenant')
51 )
54class ContactModelFilterForm(forms.Form):
55 contact = DynamicModelMultipleChoiceField(
56 queryset=Contact.objects.all(),
57 required=False,
58 label=_('Contact')
59 )
60 contact_role = DynamicModelMultipleChoiceField(
61 queryset=ContactRole.objects.all(),
62 required=False,
63 label=_('Contact Role')
64 )
65 contact_group = DynamicModelMultipleChoiceField(
66 queryset=ContactGroup.objects.all(),
67 required=False,
68 label=_('Contact Group')
69 )