diff --git a/newsroom/tests/fixtures.py b/newsroom/tests/fixtures.py index fd69a10c9..836a570d2 100644 --- a/newsroom/tests/fixtures.py +++ b/newsroom/tests/fixtures.py @@ -74,6 +74,13 @@ "versioncreated": datetime.now() - timedelta(days=10), "service": [{"code": "c", "name": "Service C"}], }, + { + "_id": "tag:out-of-default-range", + "type": "text", + "version": 1, + "versioncreated": datetime.now() - timedelta(days=365), + "service": [{"code": "c", "name": "Service C"}], + }, ] agenda_items = [ diff --git a/newsroom/wire/search.py b/newsroom/wire/search.py index e653ff402..55250db2d 100644 --- a/newsroom/wire/search.py +++ b/newsroom/wire/search.py @@ -341,7 +341,7 @@ def apply_request_filter(self, search, highlights=True): date_range_query = self.get_date_range_query(date_filter) else: default_time_filter: Optional[TimeFilter] = next((f for f in self.get_time_filters() if f["default"]), None) - if default_time_filter: + if default_time_filter and not search.args.get("bookmarks"): date_range_query = default_time_filter["query"] date_range_query["time_zone"] = app.config.get("DEFAULT_TIMEZONE") diff --git a/tests/core/test_wire.py b/tests/core/test_wire.py index 4313e38bb..240ae9dae 100644 --- a/tests/core/test_wire.py +++ b/tests/core/test_wire.py @@ -1095,3 +1095,17 @@ def _set_search_query(user_id, args): ] == _set_search_query( ADMIN_USER_ID, {"date_filter": "custom_date", "created_from": "2024-06-20", "created_to": "2024-06-23"} ) + + +def test_bookmark_old_items(client, public_user, company_products): + login(client, public_user) + resp = client.get("/wire/search") + assert 200 == resp.status_code + assert len(resp.json["_items"]) + + resp = client.post("/wire_bookmark", json={"items": ["tag:foo", "tag:out-of-default-range"]}) + assert 200 == resp.status_code + + resp = client.get("/wire/search?bookmarks={}".format(public_user["_id"])) + assert resp.status_code == 200 + assert 2 == len(resp.json["_items"])