Coverage for wireless/ui/panels.py: 94%

33 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-10 18:35 +0000

1from django.utils.translation import gettext_lazy as _ 

2 

3from netbox.ui import attrs, panels 

4 

5 

6class WirelessLANGroupPanel(panels.NestedGroupObjectPanel): 

7 pass 

8 

9 

10class WirelessLANPanel(panels.ObjectAttributesPanel): 

11 ssid = attrs.TextAttr('ssid', label=_('SSID')) 

12 group = attrs.NestedObjectAttr('group', linkify=True) 

13 status = attrs.ChoiceAttr('status') 

14 scope = attrs.GenericForeignKeyAttr('scope', linkify=True, nested=True, max_depth=3) 

15 description = attrs.TextAttr('description') 

16 vlan = attrs.RelatedObjectAttr('vlan', label=_('VLAN'), linkify=True) 

17 tenant = attrs.RelatedObjectAttr('tenant', linkify=True, grouped_by='group') 

18 

19 

20class WirelessAuthenticationPanel(panels.ObjectAttributesPanel): 

21 title = _('Authentication') 

22 

23 auth_type = attrs.ChoiceAttr('auth_type', label=_('Type')) 

24 auth_cipher = attrs.ChoiceAttr('auth_cipher', label=_('Cipher')) 

25 auth_psk = attrs.TemplatedAttr('auth_psk', label=_('PSK'), template_name='wireless/attrs/auth_psk.html') 

26 

27 

28class WirelessLinkInterfacePanel(panels.ObjectPanel): 

29 template_name = 'wireless/panels/wirelesslink_interface.html' 

30 

31 def __init__(self, interface_attr, title, **kwargs): 

32 super().__init__(**kwargs) 

33 self.interface_attr = interface_attr 

34 self.title = title 

35 

36 def get_context(self, context): 

37 ctx = super().get_context(context) 

38 return { 

39 **ctx, 

40 'interface': getattr(ctx['object'], self.interface_attr), 

41 } 

42 

43 

44class WirelessLinkPropertiesPanel(panels.ObjectAttributesPanel): 

45 title = _('Link Properties') 

46 

47 status = attrs.ChoiceAttr('status') 

48 ssid = attrs.TextAttr('ssid', label=_('SSID')) 

49 tenant = attrs.RelatedObjectAttr('tenant', linkify=True, grouped_by='group') 

50 description = attrs.TextAttr('description') 

51 distance = attrs.DistanceAttr('distance')