Skip to content

Commit

Permalink
Merge pull request #1295 from Amsterdam/WON-65-AZA-Task-filter-bad-re…
Browse files Browse the repository at this point in the history
…quest

prevent exception on no open tasks
  • Loading branch information
NvdLaan authored Jan 14, 2025
2 parents ba54fce + a5d83c9 commit 213a806
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/apps/cases/views/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class CaseFilter(filters.FilterSet):
queryset=Tag.objects.all(), method="get_tag"
)
task = filters.ModelMultipleChoiceFilter(
queryset=CaseUserTask.objects.filter(completed=False),
queryset=CaseUserTask.objects.all(),
method="get_task",
to_field_name="task_name",
)
Expand Down Expand Up @@ -294,6 +294,8 @@ def get_state_types(self, queryset, name, value):
return queryset

def get_task(self, queryset, name, value):
# Filter here instead of the queryset to prevent exceptions when there are no open tasks with a speciifc state
value = [task for task in value if not task.completed]
if value:
return queryset.filter(
workflows__completed=False,
Expand Down

0 comments on commit 213a806

Please sign in to comment.