Exemple #1
0
class ComplianceRuleFilterForm(utilities_forms.BootstrapMixin,
                               extras_forms.CustomFieldFilterForm):
    """Form for ComplianceRule instances."""

    model = models.ComplianceRule
    platform = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=Platform.objects.all(), required=False)
    feature = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=models.ComplianceFeature.objects.all(), required=False)
Exemple #2
0
class ConfigReplaceFeatureFilterForm(utilities_forms.BootstrapMixin,
                                     extras_forms.CustomFieldFilterForm):
    """Filter Form for Line Replacement."""

    model = models.ConfigReplace

    platform = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=Platform.objects.all(), required=False)
    name = utilities_forms.DynamicModelChoiceField(
        queryset=models.ConfigReplace.objects.all(), required=False)
class ConfigRemoveFeatureFilterForm(utilities_forms.BootstrapMixin, extras_forms.CustomFieldFilterForm):
    """Filter Form for Line Removal."""

    model = models.ConfigRemove
    platform = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=Platform.objects.all(), required=False, null_option="None"
    )
    name = utilities_forms.DynamicModelChoiceField(
        queryset=models.ConfigRemove.objects.all(), to_field_name="name", required=False
    )
Exemple #4
0
class ConfigComplianceFilterForm(GoldenConfigFilterForm):
    """Filter Form for ConfigCompliance instances."""

    model = models.ConfigCompliance
    device = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=Device.objects.filter(id__in=Subquery(
            models.ConfigCompliance.objects.distinct("device").values(
                "device"))),
        to_field_name="name",
        required=False,
        null_option="None",
    )
 def __init__(self, *args, **kwargs):
     """Required for status to work."""
     super().__init__(*args, **kwargs)
     self.fields["device_status"] = utilities_forms.DynamicModelMultipleChoiceField(
         required=False,
         queryset=Status.objects.all(),
         query_params={"content_types": Device._meta.label_lower},
         display_field="label",
         label="Device Status",
         to_field_name="slug",
     )
     self.order_fields(self.field_order)  # Reorder fields again
Exemple #6
0
class GoldenConfigFilterForm(utilities_forms.BootstrapMixin,
                             extras_forms.CustomFieldFilterForm):
    """Filter Form for GoldenConfig instances."""

    model = models.GoldenConfig

    class Meta:
        """Meta definitions of searchable fields."""

    field_order = [
        "q",
        "tenant_group",
        "tenant",
        "region",
        "site",
        "rack_group_id",
        "rack_id",
        "role",
        "manufacturer",
        "platform",
        "device_status_id",
        "device_type_id",
        "device",
    ]
    q = forms.CharField(required=False, label="Search")
    tenant_group = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=TenantGroup.objects.all(),
        to_field_name="slug",
        required=False,
        null_option="None")
    tenant = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=Tenant.objects.all(),
        to_field_name="slug",
        required=False,
        null_option="None",
        query_params={"group": "$tenant_group"},
    )
    region = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=Region.objects.all(), to_field_name="slug", required=False)
    site = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=Site.objects.all(),
        to_field_name="slug",
        required=False,
        query_params={"region": "$region"})
    rack_group_id = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=RackGroup.objects.all(),
        required=False,
        label="Rack group",
        query_params={"site": "$site"})
    rack_id = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=Rack.objects.all(),
        required=False,
        label="Rack",
        null_option="None",
        query_params={
            "site": "$site",
            "group_id": "$rack_group_id",
        },
    )
    role = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=DeviceRole.objects.all(),
        to_field_name="slug",
        required=False)
    manufacturer = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=Manufacturer.objects.all(),
        to_field_name="slug",
        required=False,
        label="Manufacturer")
    device_type_id = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=DeviceType.objects.all(),
        required=False,
        label="Model",
        display_field="model",
        query_params={"manufacturer": "$manufacturer"},
    )
    platform = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=Platform.objects.all(),
        to_field_name="slug",
        required=False,
        null_option="None")
    device = utilities_forms.DynamicModelMultipleChoiceField(
        queryset=Device.objects.all(),
        required=False,
        null_option="None",
        label="Device")

    def __init__(self, *args, **kwargs):
        """Required for status to work."""
        super().__init__(*args, **kwargs)
        self.fields[
            "device_status_id"] = utilities_forms.DynamicModelMultipleChoiceField(
                required=False,
                queryset=Status.objects.all(),
                query_params={"content_types": Device._meta.label_lower},
                display_field="label",
                label="Device Status",
                to_field_name="name",
            )
        self.order_fields(self.field_order)  # Reorder fields again