Skip to content

Commit c25c392

Browse files
committed
Add navigation button and improve form appearance
1 parent 4e39ab4 commit c25c392

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

netbox_onboarding/forms.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from django_rq import get_queue
1717

1818
from utilities.forms import BootstrapMixin
19-
from dcim.models import Site, Platform, DeviceRole
19+
from dcim.models import Site, Platform, DeviceRole, DeviceType
2020
from extras.forms import CustomFieldModelCSVForm
2121

2222
from .models import OnboardingTask
@@ -34,24 +34,45 @@ class OnboardingTaskForm(BootstrapMixin, forms.ModelForm):
3434
site = forms.ModelChoiceField(required=True, queryset=Site.objects.all(), to_field_name="slug")
3535

3636
username = forms.CharField(required=False, help_text="Device username (will not be stored in database)")
37-
password = forms.CharField(required=False, help_text="Device password (will not be stored in database)")
38-
secret = forms.CharField(required=False, help_text="Device secret (will not be stored in database)")
37+
password = forms.CharField(
38+
required=False, widget=forms.PasswordInput, help_text="Device password (will not be stored in database)"
39+
)
40+
secret = forms.CharField(
41+
required=False, widget=forms.PasswordInput, help_text="Device secret (will not be stored in database)"
42+
)
3943

40-
device_type = forms.CharField(required=False, help_text="Device type slug (optional)")
44+
platform = forms.ModelChoiceField(
45+
queryset=Platform.objects.all(),
46+
required=False,
47+
to_field_name="slug",
48+
help_text="Device platform. Define ONLY to override auto-recognition of platform.",
49+
)
50+
role = forms.ModelChoiceField(
51+
queryset=DeviceRole.objects.all(),
52+
required=False,
53+
to_field_name="slug",
54+
help_text="Device role. Define ONLY to override auto-recognition of role.",
55+
)
56+
device_type = forms.ModelChoiceField(
57+
queryset=DeviceType.objects.all(),
58+
required=False,
59+
to_field_name="slug",
60+
help_text="Device type. Define ONLY to override auto-recognition of type.",
61+
)
4162

4263
class Meta: # noqa: D106 "Missing docstring in public nested class"
4364
model = OnboardingTask
4465
fields = [
45-
"ip_address",
4666
"site",
67+
"ip_address",
68+
"port",
69+
"timeout",
4770
"username",
4871
"password",
4972
"secret",
73+
"platform",
5074
"role",
5175
"device_type",
52-
"platform",
53-
"port",
54-
"timeout",
5576
]
5677

5778
def save(self, commit=True, **kwargs):

netbox_onboarding/navigation.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,25 @@
1313
"""
1414

1515
from extras.plugins import PluginMenuButton, PluginMenuItem
16+
from utilities.choices import ButtonColorChoices
1617

1718
menu_items = (
1819
PluginMenuItem(
1920
link="plugins:netbox_onboarding:onboarding_task_list",
2021
link_text="Onboarding Tasks",
2122
permissions=[],
2223
buttons=(
24+
PluginMenuButton(
25+
link="plugins:netbox_onboarding:onboarding_task_add",
26+
title="Onboard",
27+
icon_class="fa fa-plus",
28+
color=ButtonColorChoices.GREEN,
29+
),
2330
PluginMenuButton(
2431
link="plugins:netbox_onboarding:onboarding_task_import",
2532
title="Bulk Onboard",
2633
icon_class="fa fa-download",
34+
color=ButtonColorChoices.BLUE,
2735
),
2836
),
2937
),

0 commit comments

Comments
 (0)