Skip to content

Commit

Permalink
Allow default filtering on models previously using lci fields. (#535)
Browse files Browse the repository at this point in the history
- We have now moved on to collations in #513 so these hacks are no longer required.
  • Loading branch information
terjekv authored May 23, 2024
1 parent 75dccd7 commit 3fc4b79
Showing 1 changed file with 3 additions and 32 deletions.
35 changes: 3 additions & 32 deletions mreg/api/v1/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ class Meta:
fields = "__all__"


# Not that due to the email field being a CIEmailField, filtering on it
# with lookups (email__contains=..., email__regex=..., etc) won't work.
# This field is inherited from BaseZone.
class ForwardZoneFilterSet(filters.FilterSet):
class Meta:
model = ForwardZone
Expand Down Expand Up @@ -73,19 +70,10 @@ class Meta:
fields = "__all__"


# We can't use fields = '__all__' due to our use of LCI-fields:
# https://github.com/unioslo/mreg/issues/489#issuecomment-1610209358
# For the HostGroup model, this applies to the field "name"
class HostGroupFilterSet(filters.FilterSet):
class Meta:
model = HostGroup
fields = {
"name": ["exact", "regex", "contains"],
"description": ["exact", "regex", "contains"],
"owners__name": ["exact", "regex", "contains"],
"parent__name": ["exact", "regex", "contains"],
"hosts__name": ["exact", "regex", "contains"],
}
fields = "__all__"


class IpaddressFilterSet(filters.FilterSet):
Expand All @@ -94,16 +82,10 @@ class Meta:
fields = "__all__"


# We can't use fields = '__all__' due to our use of LCI-fields:
# https://github.com/unioslo/mreg/issues/489#issuecomment-1610209358
# For the Label model, this applies to the field "name"
class LabelFilterSet(filters.FilterSet):
class Meta:
model = Label
fields = {
"name": ["exact", "regex", "contains"],
"description": ["exact", "regex", "contains"],
}
fields = "__all__"


class LocFilterSet(filters.FilterSet):
Expand Down Expand Up @@ -174,21 +156,10 @@ class Meta:
model = ReverseZoneDelegation
fields = "__all__"

# We can't use fields = '__all__' due to our use of LCI-fields:
# https://github.com/unioslo/mreg/issues/489#issuecomment-1610209358
# For the Srv model, this applies to the field "name"

class SrvFilterSet(filters.FilterSet):
class Meta:
model = Srv
fields = {
"name": ["exact", "contains", "regex"],
"priority": ["exact", "lt", "gt"],
"weight": ["exact", "lt", "gt"],
"port": ["exact", "lt", "gt"],
"ttl": ["exact", "lt", "gt"],
"host__name": ["exact", "contains", "regex"],
}
fields = "__all__"


class SshfpFilterSet(filters.FilterSet):
Expand Down

0 comments on commit 3fc4b79

Please sign in to comment.