1616from django_rq import get_queue
1717
1818from utilities .forms import BootstrapMixin
19- from dcim .models import Site , Platform , DeviceRole
19+ from dcim .models import Site , Platform , DeviceRole , DeviceType
2020from extras .forms import CustomFieldModelCSVForm
2121
2222from .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 ):
0 commit comments