bulk_edit.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. from django import forms
  2. from django.utils.translation import gettext as _
  3. from dcim.choices import LinkStatusChoices
  4. from ipam.models import VLAN
  5. from netbox.forms import NetBoxModelBulkEditForm
  6. from tenancy.models import Tenant
  7. from utilities.forms import add_blank_choice, CommentField, DynamicModelChoiceField, SmallTextarea
  8. from wireless.choices import *
  9. from wireless.constants import SSID_MAX_LENGTH
  10. from wireless.models import *
  11. __all__ = (
  12. 'WirelessLANBulkEditForm',
  13. 'WirelessLANGroupBulkEditForm',
  14. 'WirelessLinkBulkEditForm',
  15. )
  16. class WirelessLANGroupBulkEditForm(NetBoxModelBulkEditForm):
  17. parent = DynamicModelChoiceField(
  18. queryset=WirelessLANGroup.objects.all(),
  19. required=False
  20. )
  21. description = forms.CharField(
  22. max_length=200,
  23. required=False
  24. )
  25. model = WirelessLANGroup
  26. fieldsets = (
  27. (None, ('parent', 'description')),
  28. )
  29. nullable_fields = ('parent', 'description')
  30. class WirelessLANBulkEditForm(NetBoxModelBulkEditForm):
  31. status = forms.ChoiceField(
  32. choices=add_blank_choice(WirelessLANStatusChoices),
  33. required=False
  34. )
  35. group = DynamicModelChoiceField(
  36. queryset=WirelessLANGroup.objects.all(),
  37. required=False
  38. )
  39. vlan = DynamicModelChoiceField(
  40. queryset=VLAN.objects.all(),
  41. required=False,
  42. label=_('VLAN')
  43. )
  44. ssid = forms.CharField(
  45. max_length=SSID_MAX_LENGTH,
  46. required=False,
  47. label=_('SSID')
  48. )
  49. tenant = DynamicModelChoiceField(
  50. queryset=Tenant.objects.all(),
  51. required=False
  52. )
  53. auth_type = forms.ChoiceField(
  54. choices=add_blank_choice(WirelessAuthTypeChoices),
  55. required=False
  56. )
  57. auth_cipher = forms.ChoiceField(
  58. choices=add_blank_choice(WirelessAuthCipherChoices),
  59. required=False
  60. )
  61. auth_psk = forms.CharField(
  62. required=False,
  63. label=_('Pre-shared key')
  64. )
  65. description = forms.CharField(
  66. max_length=200,
  67. required=False
  68. )
  69. comments = CommentField(
  70. widget=SmallTextarea,
  71. label='Comments'
  72. )
  73. model = WirelessLAN
  74. fieldsets = (
  75. (None, ('group', 'ssid', 'status', 'vlan', 'tenant', 'description')),
  76. ('Authentication', ('auth_type', 'auth_cipher', 'auth_psk')),
  77. )
  78. nullable_fields = (
  79. 'ssid', 'group', 'vlan', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',
  80. )
  81. class WirelessLinkBulkEditForm(NetBoxModelBulkEditForm):
  82. ssid = forms.CharField(
  83. max_length=SSID_MAX_LENGTH,
  84. required=False,
  85. label=_('SSID')
  86. )
  87. status = forms.ChoiceField(
  88. choices=add_blank_choice(LinkStatusChoices),
  89. required=False
  90. )
  91. tenant = DynamicModelChoiceField(
  92. queryset=Tenant.objects.all(),
  93. required=False
  94. )
  95. auth_type = forms.ChoiceField(
  96. choices=add_blank_choice(WirelessAuthTypeChoices),
  97. required=False
  98. )
  99. auth_cipher = forms.ChoiceField(
  100. choices=add_blank_choice(WirelessAuthCipherChoices),
  101. required=False
  102. )
  103. auth_psk = forms.CharField(
  104. required=False,
  105. label=_('Pre-shared key')
  106. )
  107. description = forms.CharField(
  108. max_length=200,
  109. required=False
  110. )
  111. comments = CommentField(
  112. widget=SmallTextarea,
  113. label='Comments'
  114. )
  115. model = WirelessLink
  116. fieldsets = (
  117. (None, ('ssid', 'status', 'tenant', 'description')),
  118. ('Authentication', ('auth_type', 'auth_cipher', 'auth_psk'))
  119. )
  120. nullable_fields = (
  121. 'ssid', 'tenant', 'description', 'auth_type', 'auth_cipher', 'auth_psk', 'comments',
  122. )