Skip to content

Commit

Permalink
✨ [#499] Add log filtering for event
Browse files Browse the repository at this point in the history
  • Loading branch information
SilviaAmAm committed Nov 26, 2024
1 parent 5152d26 commit d633295
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/src/openarchiefbeheer/logging/api/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.db.models import QuerySet
from django.utils.translation import gettext_lazy as _

from django_filters import FilterSet, UUIDFilter
from django_filters import CharFilter, FilterSet, UUIDFilter
from timeline_logger.models import TimelineLog

from openarchiefbeheer.destruction.models import DestructionList
Expand All @@ -14,6 +14,11 @@ class LogsFilterset(FilterSet):
method="filter_destruction_list",
help_text=_("Retrieve the logs of a particular destruction list."),
)
event = CharFilter(
field_name="event",
method="filter_event",
help_text=_("Retrieve the logs for a particular event."),
)

class Meta:
model = TimelineLog
Expand All @@ -32,3 +37,9 @@ def filter_destruction_list(
content_type=content_type,
object_id=destruction_list.pk,
)

def filter_event(
self, queryset: QuerySet[TimelineLog], name: str, value: str
) -> QuerySet[TimelineLog]:
template = f"logging/{value}.txt"
return queryset.filter(template=template)

0 comments on commit d633295

Please sign in to comment.