From e4eec17f63ac00b6597b339bc1fcf9dacb85dcc0 Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Wed, 16 Oct 2024 14:56:34 +0200 Subject: [PATCH] [qa] fix reqparse not parsing bool type correctly (always True) --- zou/app/blueprints/assets/resources.py | 6 +++--- zou/app/blueprints/news/resources.py | 13 +++++++++---- zou/app/blueprints/source/otio.py | 6 +++--- zou/app/blueprints/tasks/resources.py | 8 ++++++-- zou/app/blueprints/user/resources.py | 12 ++++++------ 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/zou/app/blueprints/assets/resources.py b/zou/app/blueprints/assets/resources.py index 3bdaa50f33..099b976ab6 100644 --- a/zou/app/blueprints/assets/resources.py +++ b/zou/app/blueprints/assets/resources.py @@ -1,5 +1,5 @@ from flask import request -from flask_restful import Resource +from flask_restful import Resource, inputs from flask_jwt_extended import jwt_required from zou.app.utils import permissions, query @@ -486,7 +486,7 @@ def get_arguments(self): "is_shared", True, False, - bool, + inputs.boolean, ), "episode_id", ] @@ -688,7 +688,7 @@ def post(self, project_id=None, asset_type_id=None, asset_ids=None): "is_shared", True, False, - bool, + inputs.boolean, ), ] ) diff --git a/zou/app/blueprints/news/resources.py b/zou/app/blueprints/news/resources.py index ebc663e627..9ca78a57f1 100644 --- a/zou/app/blueprints/news/resources.py +++ b/zou/app/blueprints/news/resources.py @@ -1,4 +1,4 @@ -from flask_restful import Resource +from flask_restful import Resource, inputs from flask_jwt_extended import jwt_required from zou.app.mixin import ArgsMixin @@ -7,7 +7,7 @@ from zou.app.utils import permissions -class NewsMixin: +class NewsMixin(ArgsMixin): def get_news(self, project_ids=[]): ( only_preview, @@ -21,7 +21,6 @@ def get_news(self, project_ids=[]): before, ) = self.get_arguments() - user_service after = self.parse_date_parameter(after) before = self.parse_date_parameter(before) result = news_service.get_last_news_for_project( @@ -38,6 +37,7 @@ def get_news(self, project_ids=[]): ) stats = news_service.get_news_stats_for_project( project_ids=project_ids, + only_preview=only_preview, task_type_id=task_type_id, task_status_id=task_status_id, episode_id=episode_id, @@ -51,7 +51,12 @@ def get_news(self, project_ids=[]): def get_arguments(self): args = self.get_args( [ - {"name": "only_preview", "default": False, "type": bool}, + ( + "only_preview", + False, + False, + inputs.boolean, + ), "task_type_id", "task_status_id", "person_id", diff --git a/zou/app/blueprints/source/otio.py b/zou/app/blueprints/source/otio.py index 656b7e6f51..67fd8691e0 100644 --- a/zou/app/blueprints/source/otio.py +++ b/zou/app/blueprints/source/otio.py @@ -6,7 +6,7 @@ from string import Template from flask import request, current_app -from flask_restful import Resource +from flask_restful import Resource, inputs from flask_jwt_extended import jwt_required from zou.app import config @@ -308,7 +308,7 @@ def post_args(self): False, str, ), - ("match_case", True, False, bool), + ("match_case", True, False, inputs.boolean), ] ) @@ -359,6 +359,6 @@ def post_args(self): False, str, ), - ("match_case", True, False, bool), + ("match_case", True, False, inputs.boolean), ] ) diff --git a/zou/app/blueprints/tasks/resources.py b/zou/app/blueprints/tasks/resources.py index e30e27d22a..5237a879a5 100644 --- a/zou/app/blueprints/tasks/resources.py +++ b/zou/app/blueprints/tasks/resources.py @@ -2,7 +2,7 @@ from flask import abort, request -from flask_restful import Resource +from flask_restful import Resource, inputs from flask_jwt_extended import jwt_required from zou.app.services.exception import ( @@ -793,7 +793,11 @@ def get_arguments(self): ("comment", ""), ("name", "main"), {"name": "revision", "default": 1, "type": int}, - {"name": "change_status", "default": True, "type": bool}, + { + "name": "change_status", + "default": True, + "type": inputs.boolean, + }, ] ) diff --git a/zou/app/blueprints/user/resources.py b/zou/app/blueprints/user/resources.py index 37ace5bf6a..e824312069 100644 --- a/zou/app/blueprints/user/resources.py +++ b/zou/app/blueprints/user/resources.py @@ -1,5 +1,5 @@ from flask import abort, request -from flask_restful import Resource +from flask_restful import Resource, inputs from zou.app.mixin import ArgsMixin from zou.app.services import ( @@ -556,7 +556,7 @@ def get_arguments(self): ("list_type", "todo", True), ("project_id", None, False), ("entity_type", None, False), - ("is_shared", False, False, bool), + ("is_shared", False, False, inputs.boolean), ("search_filter_group_id", None, False), ] ) @@ -589,7 +589,7 @@ def put(self, filter_id): ("name", None, False), ("search_query", None, False), ("search_filter_group_id", None, False), - ("is_shared", None, False, bool), + ("is_shared", None, False, inputs.boolean), ("project_id", None, None), ] ) @@ -695,7 +695,7 @@ def get_arguments(self): ("color", "", True), ("list_type", "todo", True), ("project_id", None, False), - ("is_shared", False, False, bool), + ("is_shared", False, False, inputs.boolean), ("entity_type", None, False), ] ) @@ -741,7 +741,7 @@ def put(self, filter_group_id): [ ("name", None, False), ("color", None, False), - ("is_shared", None, False, bool), + ("is_shared", None, False, inputs.boolean), ("project_id", None, None), ] ) @@ -919,7 +919,7 @@ def put(self, notification_id): 200: description: Notification """ - data = self.get_args([("read", None, False, bool)]) + data = self.get_args([("read", None, False, inputs.boolean)]) return user_service.update_notification(notification_id, data["read"])