Example #1
0
class StatusFilterForm(BootstrapMixin, CustomFieldFilterForm):
    """Filtering/search form for `Status` objects."""

    model = Status
    q = forms.CharField(required=False, label="Search")
    # "CSV" field is being used here because it is using the slug-form input for
    # content-types, which improves UX.
    content_types = CSVMultipleContentTypeField(
        queryset=ContentType.objects.filter(
            FeatureQuery("statuses").get_query()).order_by(
                "app_label", "model"),
        required=False,
        label="Content type(s)",
    )
    color = forms.CharField(max_length=6, required=False, widget=ColorSelect())
Example #2
0
class StatusCSVForm(CustomFieldModelCSVForm):
    """Generic CSV bulk import form for `Status` objects."""

    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>)"),
        }
Example #3
0
class StatusCSVForm(CustomFieldModelCSVForm):
    """Generic CSV bulk import form for `Status` objects."""

    slug = SlugField()
    content_types = CSVMultipleContentTypeField(
        queryset=ContentType.objects.filter(
            FeatureQuery("statuses").get_query()).order_by(
                "app_label", "model"),
        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>)"),
        }