class TagCSVForm(CustomFieldModelCSVForm): slug = SlugField() class Meta: model = Tag fields = Tag.csv_headers help_texts = { "color": mark_safe("RGB color in hexadecimal (e.g. <code>00ff00</code>)"), }
class CircuitTypeCSVForm(CustomFieldModelCSVForm): slug = SlugField() class Meta: model = CircuitType fields = CircuitType.csv_headers help_texts = { "name": "Name of circuit type", }
class RIRCSVForm(CustomFieldModelCSVForm): slug = SlugField() class Meta: model = RIR fields = RIR.csv_headers help_texts = { "name": "RIR name", }
class StatusForm(BootstrapMixin, CustomFieldModelForm, RelationshipModelForm): """Generic create/update form for `Status` objects.""" slug = SlugField() content_types = MultipleContentTypeField(feature="statuses", label="Content Type(s)") class Meta: model = Status widgets = {"color": ColorSelect()} fields = ["name", "slug", "description", "content_types", "color"]
class ClusterGroupForm(BootstrapMixin, CustomFieldModelForm, RelationshipModelForm): slug = SlugField() class Meta: model = ClusterGroup fields = [ "name", "slug", "description", ]
class ClusterGroupForm(NautobotModelForm): slug = SlugField() class Meta: model = ClusterGroup fields = [ "name", "slug", "description", ]
class CircuitTypeForm(NautobotModelForm): slug = SlugField() class Meta: model = CircuitType fields = [ "name", "slug", "description", ]
class CircuitTypeForm(BootstrapMixin, CustomFieldModelForm, RelationshipModelForm): slug = SlugField() class Meta: model = CircuitType fields = [ "name", "slug", "description", ]
class RoleForm(NautobotModelForm): slug = SlugField() class Meta: model = Role fields = [ "name", "slug", "weight", "description", ]
class RIRForm(BootstrapMixin, CustomFieldModelForm, RelationshipModelForm): slug = SlugField() class Meta: model = RIR fields = [ "name", "slug", "is_private", "description", ]
class RoleForm(BootstrapMixin, CustomFieldModelForm, RelationshipModelForm): slug = SlugField() class Meta: model = Role fields = [ "name", "slug", "weight", "description", ]
class RIRForm(NautobotModelForm): slug = SlugField() class Meta: model = RIR fields = [ "name", "slug", "is_private", "description", ]
class TenantCSVForm(CustomFieldModelCSVForm): slug = SlugField() group = CSVModelChoiceField( queryset=TenantGroup.objects.all(), required=False, to_field_name="name", help_text="Assigned group", ) class Meta: model = Tenant fields = Tenant.csv_headers
class ComplianceFeatureForm( utilities_forms.BootstrapMixin, extras_forms.CustomFieldModelForm, extras_forms.RelationshipModelForm ): """Filter Form for ComplianceFeature instances.""" slug = SlugField() class Meta: """Boilerplate form Meta data for compliance feature.""" model = models.ComplianceFeature fields = ("name", "slug", "description")
class ConfigContextSchemaForm(BootstrapMixin, forms.ModelForm): data_schema = JSONField(label="") slug = SlugField() class Meta: model = ConfigContextSchema fields = ( "name", "slug", "description", "data_schema", )
class VLANGroupCSVForm(CustomFieldModelCSVForm): site = CSVModelChoiceField( queryset=Site.objects.all(), required=False, to_field_name="name", help_text="Assigned site", ) slug = SlugField() class Meta: model = VLANGroup fields = VLANGroup.csv_headers
class TenantGroupCSVForm(CustomFieldModelCSVForm): parent = CSVModelChoiceField( queryset=TenantGroup.objects.all(), required=False, to_field_name="name", help_text="Parent group", ) slug = SlugField() class Meta: model = TenantGroup fields = TenantGroup.csv_headers
class RelationshipForm(BootstrapMixin, forms.ModelForm): slug = SlugField() source_type = forms.ModelChoiceField( queryset=ContentType.objects.filter( FeatureQuery("relationships").get_query()).order_by( "app_label", "model"), help_text="The source object type to which this relationship applies.", ) source_filter = JSONField( required=False, help_text= "Queryset filter matching the applicable source objects of the selected type.<br>" 'Enter in <a href="https://json.org/">JSON</a> format.', ) destination_type = forms.ModelChoiceField( queryset=ContentType.objects.filter( FeatureQuery("relationships").get_query()).order_by( "app_label", "model"), help_text= "The destination object type to which this relationship applies.", ) destination_filter = JSONField( required=False, help_text= "Queryset filter matching the applicable destination objects of the selected type.<br>" 'Enter in <a href="https://json.org/">JSON</a> format.', ) class Meta: model = Relationship fields = [ "name", "slug", "description", "type", "source_type", "source_label", "source_hidden", "source_filter", "destination_type", "destination_label", "destination_hidden", "destination_filter", ] def save(self, commit=True): # TODO add support for owner when a CR is created in the UI obj = super().save(commit) return obj
class SecretsGroupForm(BootstrapMixin, CustomFieldModelForm, RelationshipModelForm): """Create/update form for `SecretsGroup` objects.""" slug = SlugField() class Meta: model = SecretsGroup fields = [ "name", "slug", "description", ]
class TenantGroupForm(NautobotModelForm): parent = DynamicModelChoiceField(queryset=TenantGroup.objects.all(), required=False) slug = SlugField() class Meta: model = TenantGroup fields = [ "parent", "name", "slug", "description", ]
class TenantGroupForm(BootstrapMixin, CustomFieldModelForm, RelationshipModelForm): parent = DynamicModelChoiceField(queryset=TenantGroup.objects.all(), required=False) slug = SlugField() class Meta: model = TenantGroup fields = [ "parent", "name", "slug", "description", ]
class GraphQLQueryForm(BootstrapMixin, forms.ModelForm): slug = SlugField() query = TextField() class Meta: model = GraphQLQuery fields = ( "name", "slug", "query", ) def get_action_url(self): return reverse("extras:graphqlquery_add")
class GitRepositoryForm(BootstrapMixin, RelationshipModelForm): slug = SlugField(help_text="Filesystem-friendly unique shorthand") remote_url = forms.URLField( required=True, label="Remote URL", help_text="Only http:// and https:// URLs are presently supported", ) _token = forms.CharField( required=False, label="Token", widget=PasswordInputWithPlaceholder( placeholder=GitRepository.TOKEN_PLACEHOLDER), help_text="<em>Deprecated</em> - use a secrets group instead.", ) username = forms.CharField( required=False, label="Username", help_text= "Username for token authentication.<br><em>Deprecated</em> - use a secrets group instead", ) secrets_group = DynamicModelChoiceField( required=False, queryset=SecretsGroup.objects.all()) provided_contents = forms.MultipleChoiceField( required=False, label="Provides", choices=get_git_datasource_content_choices, ) tags = DynamicModelMultipleChoiceField(queryset=Tag.objects.all(), required=False) class Meta: model = GitRepository fields = [ "name", "slug", "remote_url", "branch", "username", "_token", "secrets_group", "provided_contents", "tags", ]
class StatusForm(BootstrapMixin, CustomFieldModelForm, RelationshipModelForm): """Generic create/update form for `Status` objects.""" slug = SlugField() content_types = forms.ModelMultipleChoiceField( queryset=ContentType.objects.filter( FeatureQuery("statuses").get_query()).order_by( "app_label", "model"), label="Content type(s)", ) class Meta: model = Status widgets = {"color": ColorSelect()} fields = ["name", "slug", "description", "content_types", "color"]
class TenantForm(NautobotModelForm): slug = SlugField() group = DynamicModelChoiceField(queryset=TenantGroup.objects.all(), required=False) comments = CommentField() class Meta: model = Tenant fields = ( "name", "slug", "group", "description", "comments", "tags", )
class TenantForm(BootstrapMixin, CustomFieldModelForm, RelationshipModelForm): slug = SlugField() group = DynamicModelChoiceField(queryset=TenantGroup.objects.all(), required=False) comments = CommentField() tags = DynamicModelMultipleChoiceField(queryset=Tag.objects.all(), required=False) class Meta: model = Tenant fields = ( "name", "slug", "group", "description", "comments", "tags", )
class VLANGroupForm(BootstrapMixin, CustomFieldModelForm, RelationshipModelForm): region = DynamicModelChoiceField(queryset=Region.objects.all(), required=False, initial_params={"sites": "$site"}) site = DynamicModelChoiceField( queryset=Site.objects.all(), required=False, query_params={"region_id": "$region"}, ) slug = SlugField() class Meta: model = VLANGroup fields = [ "region", "site", "name", "slug", "description", ]
class ProviderNetworkForm(NautobotModelForm): slug = SlugField() provider = DynamicModelChoiceField(queryset=Provider.objects.all()) comments = CommentField(label="Comments") class Meta: model = ProviderNetwork fields = [ "provider", "name", "slug", "description", "comments", "tags", ] fieldsets = (("Provider Network", ("provider", "name", "slug", "description", "comments", "tags")), )
class ComputedFieldForm(BootstrapMixin, forms.ModelForm): content_type = forms.ModelChoiceField( queryset=ContentType.objects.filter(FeatureQuery("custom_fields").get_query()).order_by("app_label", "model"), required=True, label="Content Type", ) slug = SlugField(slug_source="label") class Meta: model = ComputedField fields = ( "content_type", "label", "slug", "description", "template", "fallback_value", "weight", )
class StatusCSVForm(CustomFieldModelCSVForm): """Generic CSV bulk import form for `Status` objects.""" slug = SlugField() content_types = CSVMultipleContentTypeField( feature="statuses", choices_as_strings=True, help_text=mark_safe( "The object types to which this status applies. Multiple values " "must be comma-separated and wrapped in double quotes. (e.g. " '<code>"dcim.device,dcim.rack"</code>)'), label="Content type(s)", ) class Meta: model = Status fields = Status.csv_headers help_texts = { "color": mark_safe("RGB color in hexadecimal (e.g. <code>00ff00</code>)"), }