Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent exception on no open tasks #1295

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading