diff --git a/client/src/components/History/model/queries.js b/client/src/components/History/model/queries.js index 6a643409176..1a5f684c7dd 100644 --- a/client/src/components/History/model/queries.js +++ b/client/src/components/History/model/queries.js @@ -47,21 +47,11 @@ function buildLegacyQueryStringFrom(filters) { function buildLegacyParam(fields = {}) { return Object.keys(fields).reduce((result, key) => { - result[key] = pythonBooleanFormat(fields[key]); + result[key] = fields[key]; return result; }, {}); } -function pythonBooleanFormat(val) { - if (val === true) { - return "True"; - } - if (val === false) { - return "False"; - } - return val; -} - /** * Some of the current endpoints don't accept JSON, so we need to * do some massaging to send in old form post data. diff --git a/client/src/store/historyStore/historyItemsFiltering.js b/client/src/store/historyStore/historyItemsFiltering.js index ab947bc510a..01e7ffef2ee 100644 --- a/client/src/store/historyStore/historyItemsFiltering.js +++ b/client/src/store/historyStore/historyItemsFiltering.js @@ -20,9 +20,9 @@ function toLower(value) { return String(value).toLowerCase(); } -/** Converts user input to python boolean. */ -function toBoolPython(value) { - return toLower(value) == "true" ? "True" : "False"; +/** Converts user input to boolean. */ +function toBool(value) { + return toLower(value) == "true"; } /** Converts user input to lower case and strips quotation marks. */ @@ -97,14 +97,14 @@ const validFilters = { create_time_gt: compare("create_time", "gt", toDate), create_time_le: compare("create_time", "le", toDate), create_time_lt: compare("create_time", "lt", toDate), - deleted: equals("deleted", "deleted", toBoolPython), + deleted: equals("deleted", "deleted", toBool), extension: equals("extension"), hid: equals("hid"), hid_ge: compare("hid", "ge"), hid_gt: compare("hid", "gt"), hid_le: compare("hid", "le"), hid_lt: compare("hid", "lt"), - visible: equals("visible", "visible", toBoolPython), + visible: equals("visible", "visible", toBool), name: contains("name"), state: equals("state"), tag: contains("tags", "tag"), diff --git a/client/src/store/historyStore/historyItemsFiltering.test.js b/client/src/store/historyStore/historyItemsFiltering.test.js index 850bcf2934f..a18df29032c 100644 --- a/client/src/store/historyStore/historyItemsFiltering.test.js +++ b/client/src/store/historyStore/historyItemsFiltering.test.js @@ -55,8 +55,8 @@ describe("historyItemsFiltering", () => { expect(queryDict["state-eq"]).toBe("success"); expect(queryDict["extension-eq"]).toBe("ext"); expect(queryDict["tag"]).toBe("first"); - expect(queryDict["deleted"]).toBe("False"); - expect(queryDict["visible"]).toBe("True"); + expect(queryDict["deleted"]).toBe(false); + expect(queryDict["visible"]).toBe(true); }); }); test("validate filtering of a history item", () => { diff --git a/lib/galaxy/managers/base.py b/lib/galaxy/managers/base.py index 72175120ecc..14f55897f0e 100644 --- a/lib/galaxy/managers/base.py +++ b/lib/galaxy/managers/base.py @@ -1252,9 +1252,9 @@ def parse_bool(bool_string: Union[str, bool]) -> bool: Parse a boolean from a string. """ # Be strict here to remove complexity of options (but allow already parsed). - if bool_string in ("True", True): + if bool_string in ("True", "true", True): return True - if bool_string in ("False", False): + if bool_string in ("False", "false", False): return False raise ValueError(f"invalid boolean: {bool_string}") diff --git a/test/unit/app/managers/test_HistoryManager.py b/test/unit/app/managers/test_HistoryManager.py index 22897ce87e4..1298a8a19fb 100644 --- a/test/unit/app/managers/test_HistoryManager.py +++ b/test/unit/app/managers/test_HistoryManager.py @@ -748,7 +748,7 @@ class HistoryFiltersTestCase(BaseTestCase): exceptions.RequestParameterInvalidException, self.filter_parser.parse_filters, [ - ("deleted", "eq", "true"), + ("deleted", "eq", "wot"), ], )