-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ [#209] added queryparams to digitaaladres
- Loading branch information
1 parent
81f16aa
commit 5268000
Showing
8 changed files
with
304 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/openklant/components/klantinteracties/api/filterset/digitaal_adres.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import uuid | ||
|
||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from django_filters.rest_framework import FilterSet, filters | ||
|
||
from openklant.components.klantinteracties.models.digitaal_adres import DigitaalAdres | ||
|
||
|
||
class DigitaalAdresFilterSet(FilterSet): | ||
verstrekt_door_betrokkene__uuid = filters.UUIDFilter( | ||
help_text=_( | ||
"Zoek digitaal adres(sen) object(s) op basis van de betrokkene uuid." | ||
), | ||
field_name="betrokkene__uuid", | ||
) | ||
verstrekt_door_betrokkene__url = filters.CharFilter( | ||
help_text=_( | ||
"Zoek digitaal adres(sen) object(s) op basis van de betrokkene url." | ||
), | ||
method="filter_betrokkene_url", | ||
) | ||
verstrekt_door_betrokkene__rol = filters.ChoiceFilter( | ||
help_text=_( | ||
"Zoek digitaal adres(sen) object(s) op basis van de betrokkene rol." | ||
), | ||
field_name="betrokkene__rol", | ||
) | ||
verstrekt_door_partij__uuid = filters.UUIDFilter( | ||
help_text=_("Zoek digitaal adres(sen) object(s) op basis van de partij uuid."), | ||
field_name="betrokkene__uuid", | ||
) | ||
verstrekt_door_partij__url = filters.CharFilter( | ||
help_text=_("Zoek digitaal adres(sen) object(s) op basis van de partij url."), | ||
method="filter_partij_url", | ||
) | ||
verstrekt_door_partij__soort_partij = filters.ChoiceFilter( | ||
help_text=_("Zoek digitaal adres(sen) object(s) op basis van de partij soort."), | ||
field_name="partij__soort_partij", | ||
) | ||
adres = filters.CharFilter( | ||
lookup_expr="exact", | ||
help_text=_( | ||
"Zoek digitaal adres(sen) object(s) op basis van adres die de exacte waarden bevat." | ||
), | ||
) | ||
adres__icontains = filters.CharFilter( | ||
lookup_expr="icontains", | ||
help_text=_( | ||
"Zoek digitaal adres(sen) object(s) op basis van adres die de opgegeven waarden bevat." | ||
), | ||
) | ||
omschrijving = filters.CharFilter( | ||
lookup_expr="icontains", | ||
help_text=_( | ||
"Zoek digitaal adres(sen) object(s) op basis van omschijving die de opgegeven waarden bevat." | ||
), | ||
) | ||
|
||
class Meta: | ||
model = DigitaalAdres | ||
fields = ( | ||
"verstrekt_door_betrokkene__uuid", | ||
"verstrekt_door_betrokkene__url", | ||
"verstrekt_door_betrokkene__rol", | ||
"verstrekt_door_partij__uuid", | ||
"verstrekt_door_partij__url", | ||
"verstrekt_door_partij__soort_partij", | ||
"adres", | ||
"adres__icontains", | ||
"soort_digitaal_adres", | ||
"omschrijving", | ||
) | ||
|
||
def filter_betrokkene_url(self, queryset, name, value): | ||
try: | ||
url_uuid = uuid.UUID(value.split("/")[-1]) | ||
return queryset.filter(betrokkene__uuid=url_uuid) | ||
except ValueError: | ||
return queryset.none() | ||
|
||
def filter_partij_url(self, queryset, name, value): | ||
try: | ||
url_uuid = uuid.UUID(value.split("/")[-1]) | ||
return queryset.filter(partij__uuid=url_uuid) | ||
except ValueError: | ||
return queryset.none() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.