Skip to content

Commit

Permalink
chore: clean up unnecessary fields in core filters (#2455)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanFl authored Jan 14, 2025
1 parent 4555216 commit eac344f
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions backend/application/core/api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
ChoiceFilter,
FilterSet,
ModelChoiceFilter,
NumberFilter,
OrderingFilter,
)

Expand Down Expand Up @@ -73,7 +72,6 @@ class Meta:


class ProductMemberFilter(FilterSet):
product = NumberFilter(field_name="product")
is_product_group = BooleanFilter(field_name="product__is_product_group")

ordering = OrderingFilter(
Expand All @@ -91,7 +89,6 @@ class Meta:


class ProductAuthorizationGroupMemberFilter(FilterSet):
product = NumberFilter(field_name="product")
is_product_group = BooleanFilter(field_name="product__is_product_group")

ordering = OrderingFilter(
Expand All @@ -109,7 +106,6 @@ class Meta:


class BranchFilter(FilterSet):
product = NumberFilter(field_name="product")

ordering = OrderingFilter(
# tuple-mapping retains order
Expand Down Expand Up @@ -169,21 +165,17 @@ class ObservationFilter(FilterSet):
queryset=Product.objects.filter(is_product_group=True),
)

has_pending_assessment = ChoiceFilter(
has_pending_assessment = BooleanFilter(
field_name="has_pending_assessment",
method="get_has_pending_assessment",
choices=[
("true", "true"),
("false", "false"),
],
)

def get_has_pending_assessment(
self, queryset, field_name, value
): # pylint: disable=unused-argument
# field_name is used as a positional argument

if value == "true":
if value:
return queryset.filter(
id__in=Observation_Log.objects.filter(
assessment_status="Needs approval"
Expand Down

0 comments on commit eac344f

Please sign in to comment.