Coverage for core/ui/panels.py: 100%

50 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 DataSourcePanel(panels.ObjectAttributesPanel): 

7 title = _('Data Source') 

8 name = attrs.TextAttr('name') 

9 type = attrs.ChoiceAttr('type') 

10 enabled = attrs.BooleanAttr('enabled') 

11 status = attrs.ChoiceAttr('status') 

12 sync_interval = attrs.ChoiceAttr('sync_interval', label=_('Sync interval')) 

13 last_synced = attrs.DateTimeAttr('last_synced', label=_('Last synced')) 

14 description = attrs.TextAttr('description') 

15 source_url = attrs.TemplatedAttr( 

16 'source_url', 

17 label=_('URL'), 

18 template_name='core/datasource/attrs/source_url.html', 

19 ) 

20 ignore_rules = attrs.TemplatedAttr( 

21 'ignore_rules', 

22 label=_('Ignore rules'), 

23 template_name='core/datasource/attrs/ignore_rules.html', 

24 ) 

25 

26 

27class DataSourceBackendPanel(panels.ObjectPanel): 

28 template_name = 'core/panels/datasource_backend.html' 

29 title = _('Backend') 

30 

31 

32class DataFilePanel(panels.ObjectAttributesPanel): 

33 title = _('Data File') 

34 source = attrs.RelatedObjectAttr('source', linkify=True) 

35 path = attrs.TextAttr('path', style='font-monospace', copy_button=True) 

36 last_updated = attrs.DateTimeAttr('last_updated') 

37 size = attrs.TemplatedAttr('size', template_name='core/datafile/attrs/size.html') 

38 hash = attrs.TextAttr('hash', label=_('SHA256 hash'), style='font-monospace', copy_button=True) 

39 

40 

41class DataFileContentPanel(panels.ObjectPanel): 

42 template_name = 'core/panels/datafile_content.html' 

43 title = _('Content') 

44 

45 

46class JobPanel(panels.ObjectAttributesPanel): 

47 title = _('Job') 

48 object_type = attrs.TemplatedAttr( 

49 'object_type', 

50 label=_('Object type'), 

51 template_name='core/job/attrs/object_type.html', 

52 ) 

53 name = attrs.TextAttr('name') 

54 status = attrs.ChoiceAttr('status') 

55 error = attrs.TextAttr('error') 

56 user = attrs.TextAttr('user', label=_('Created by')) 

57 

58 

59class JobSchedulingPanel(panels.ObjectAttributesPanel): 

60 title = _('Scheduling') 

61 created = attrs.DateTimeAttr('created') 

62 scheduled = attrs.TemplatedAttr('scheduled', template_name='core/job/attrs/scheduled.html') 

63 started = attrs.DateTimeAttr('started') 

64 completed = attrs.DateTimeAttr('completed') 

65 execution_time = attrs.DurationAttr('execution_time') 

66 queue = attrs.TextAttr('queue_name', label=_('Queue')) 

67 

68 

69class ObjectChangePanel(panels.ObjectAttributesPanel): 

70 title = _('Change') 

71 time = attrs.DateTimeAttr('time') 

72 user = attrs.TemplatedAttr( 

73 'user_name', 

74 label=_('User'), 

75 template_name='core/objectchange/attrs/user.html', 

76 ) 

77 action = attrs.ChoiceAttr('action') 

78 changed_object_type = attrs.TextAttr( 

79 'changed_object_type', 

80 label=_('Object type'), 

81 ) 

82 changed_object = attrs.TemplatedAttr( 

83 'object_repr', 

84 label=_('Object'), 

85 template_name='core/objectchange/attrs/changed_object.html', 

86 ) 

87 message = attrs.TextAttr('message') 

88 request_id = attrs.TemplatedAttr( 

89 'request_id', 

90 label=_('Request ID'), 

91 template_name='core/objectchange/attrs/request_id.html', 

92 )