From 2ab93ea1c046df73e0f9f64eceaf8b1e7e9dcfd1 Mon Sep 17 00:00:00 2001 From: Norbert Kwizera Date: Wed, 17 Apr 2024 19:16:17 +0200 Subject: [PATCH 1/2] Fix stories API queryset --- ureport/api/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ureport/api/views.py b/ureport/api/views.py index 63ebb5d08..14fc31345 100644 --- a/ureport/api/views.py +++ b/ureport/api/views.py @@ -912,7 +912,9 @@ class StoryList(BaseListAPIView): serializer_class = StoryReadSerializer model = Story - + def get_queryset(self): + queryset = super().get_queryset() + return queryset.filter(is_active=True).filter(Q(attachment="") | Q(attachment=None)) class StoryDetails(RetrieveAPIView): """ From 93ced4cf661e5a4901a11586f03dc0448d531212 Mon Sep 17 00:00:00 2001 From: Norbert Kwizera Date: Wed, 17 Apr 2024 20:08:11 +0200 Subject: [PATCH 2/2] Run code checks --- code_check.py | 2 +- pyproject.toml | 4 ++-- ureport/api/views.py | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/code_check.py b/code_check.py index 8fedadcd6..00d7748d3 100755 --- a/code_check.py +++ b/code_check.py @@ -77,7 +77,7 @@ def get_current_msgids(): status("Running black") cmd("black ureport") status("Running ruff") - cmd("ruff ureport") + cmd("ruff check ureport") status("Running isort") cmd("isort ureport") status("Updating locale PO files") diff --git a/pyproject.toml b/pyproject.toml index 371d4cd3e..47ea56bf3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,8 +51,8 @@ line-length = 119 [tool.ruff] line-length = 120 -select = ["E", "F", "W"] -ignore = ["E501", "F405"] +lint.select = ["E", "F", "W"] +lint.ignore = ["E501", "F405"] fix = true exclude = ["./.tox/*", "./.venv/*", "./env/*", "*/migrations/*", "./build/*"] diff --git a/ureport/api/views.py b/ureport/api/views.py index 14fc31345..195e3c87e 100644 --- a/ureport/api/views.py +++ b/ureport/api/views.py @@ -912,10 +912,12 @@ class StoryList(BaseListAPIView): serializer_class = StoryReadSerializer model = Story + def get_queryset(self): queryset = super().get_queryset() return queryset.filter(is_active=True).filter(Q(attachment="") | Q(attachment=None)) + class StoryDetails(RetrieveAPIView): """ This endpoint allows you to a single story.