diff --git a/api/src/pcapi/core/categories/subcategories_v2.py b/api/src/pcapi/core/categories/subcategories_v2.py index a925bba0527..9634842ec6e 100644 --- a/api/src/pcapi/core/categories/subcategories_v2.py +++ b/api/src/pcapi/core/categories/subcategories_v2.py @@ -26,14 +26,12 @@ def __init__( technical_name: str | None = None, gtls: list[str] | None = None, position: int | None = None, - search_filter: str | None = None, ) -> None: self.id = technical_name or str(uuid.uuid4()) self.label = label self.gtls = gtls self.parents = parents or [] self.position = position - self.search_filter = search_filter @property def search_value(self) -> str | None: @@ -192,17 +190,17 @@ def get_show_nodes() -> list[ShowGenre]: SEARCH_GROUP_ARTS_LOISIRS_CREATIFS = SearchGroup( technical_name="ARTS_LOISIRS_CREATIFS", label="Arts & loisirs créatifs", - position=5, + position=6, ) SEARCH_GROUP_CARTES_JEUNES = SearchGroup( technical_name="CARTES_JEUNES", label="Cartes jeunes", - position=11, + position=12, ) SEARCH_GROUP_CD_VINYLE_MUSIQUE_EN_LIGNE = SearchGroup( technical_name="CD_VINYLE_MUSIQUE_EN_LIGNE", label="CD, vinyles, musique en ligne", - position=4, + position=5, ) SEARCH_GROUP_CONCERTS_FESTIVALS = SearchGroup( technical_name="CONCERTS_FESTIVALS", @@ -212,17 +210,27 @@ def get_show_nodes() -> list[ShowGenre]: SEARCH_GROUP_EVENEMENTS_EN_LIGNE = SearchGroup( technical_name="EVENEMENTS_EN_LIGNE", label="Évènements en ligne", - position=12, + position=14, ) SEARCH_GROUP_FILMS_SERIES_CINEMA = SearchGroup( technical_name="FILMS_SERIES_CINEMA", label="Cinéma, films et séries", - position=13, + position=2, +) +SEARCH_GROUP_CINEMA = SearchGroup( + technical_name="CINEMA", + label="Cinéma", + position=2, +) +SEARCH_GROUP_FILMS_DOCUMENTAIRES_SERIES = SearchGroup( + technical_name="FILMS_DOCUMENTAIRES_SERIES", + label="Films, documentaires et séries", + position=3, ) SEARCH_GROUP_INSTRUMENTS = SearchGroup( technical_name="INSTRUMENTS", label="Instruments de musique", - position=2, + position=10, ) SEARCH_GROUP_JEUX_JEUX_VIDEOS = SearchGroup( technical_name="JEUX_JEUX_VIDEOS", @@ -232,17 +240,17 @@ def get_show_nodes() -> list[ShowGenre]: SEARCH_GROUP_LIVRES = SearchGroup( technical_name="LIVRES", label="Livres", - position=8, + position=4, ) SEARCH_GROUP_MEDIA_PRESSE = SearchGroup( technical_name="MEDIA_PRESSE", label="Médias & presse", - position=3, + position=11, ) SEARCH_GROUP_MUSEES_VISITES_CULTURELLES = SearchGroup( technical_name="MUSEES_VISITES_CULTURELLES", label="Musées & visites culturelles", - position=10, + position=8, ) SEARCH_GROUP_NONE = SearchGroup( technical_name="NONE", @@ -252,12 +260,12 @@ def get_show_nodes() -> list[ShowGenre]: SEARCH_GROUP_RENCONTRES_CONFERENCES = SearchGroup( technical_name="RENCONTRES_CONFERENCES", label="Conférences & rencontres", - position=7, + position=13, ) SEARCH_GROUP_SPECTACLES = SearchGroup( technical_name="SPECTACLES", label="Spectacles", - position=6, + position=7, ) # endregion @@ -295,7 +303,7 @@ def get_show_nodes() -> list[ShowGenre]: NATIVE_CATEGORY_CARTES_CINEMA = NativeCategory( technical_name="CARTES_CINEMA", label="Cartes cinéma", - parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id], + parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id, SEARCH_GROUP_CINEMA.id], ) NATIVE_CATEGORY_CD = NativeCategory( technical_name="CD", @@ -330,7 +338,7 @@ def get_show_nodes() -> list[ShowGenre]: NATIVE_CATEGORY_DVD_BLU_RAY = NativeCategory( technical_name="DVD_BLU_RAY", label="DVD, Blu-Ray", - parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id], + parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id, SEARCH_GROUP_FILMS_DOCUMENTAIRES_SERIES.id], ) NATIVE_CATEGORY_ESCAPE_GAMES = NativeCategory( technical_name="ESCAPE_GAMES", @@ -340,7 +348,7 @@ def get_show_nodes() -> list[ShowGenre]: NATIVE_CATEGORY_EVENEMENTS_CINEMA = NativeCategory( technical_name="EVENEMENTS_CINEMA", label="Evènements cinéma", - parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id], + parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id, SEARCH_GROUP_CINEMA.id], ) NATIVE_CATEGORY_EVENEMENTS_PATRIMOINE = NativeCategory( technical_name="EVENEMENTS_PATRIMOINE", @@ -360,7 +368,7 @@ def get_show_nodes() -> list[ShowGenre]: NATIVE_CATEGORY_FILMS_SERIES_EN_LIGNE = NativeCategory( technical_name="FILMS_SERIES_EN_LIGNE", label="Films, séries en ligne", - parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id], + parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id, SEARCH_GROUP_FILMS_DOCUMENTAIRES_SERIES.id], ) NATIVE_CATEGORY_JEUX_EN_LIGNE = NativeCategory( technical_name="JEUX_EN_LIGNE", @@ -402,6 +410,7 @@ def get_show_nodes() -> list[ShowGenre]: label="Musique en ligne", parents=[SEARCH_GROUP_CD_VINYLE_MUSIQUE_EN_LIGNE.id], ) +NATIVE_CATEGORY_NONE = NativeCategory(technical_name="NATIVE_CATEGORY_NONE", label="None", parents=[]) NATIVE_CATEGORY_PARTITIONS_DE_MUSIQUE = NativeCategory( technical_name="PARTITIONS_DE_MUSIQUE", label="Partitions de musique", @@ -456,7 +465,7 @@ def get_show_nodes() -> list[ShowGenre]: NATIVE_CATEGORY_SEANCES_DE_CINEMA = NativeCategory( technical_name="SEANCES_DE_CINEMA", label="Séances de cinéma", - parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id], + parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id, SEARCH_GROUP_CINEMA.id], ) NATIVE_CATEGORY_SPECTACLES_ENREGISTRES = NativeCategory( technical_name="SPECTACLES_ENREGISTRES", @@ -609,7 +618,7 @@ class EacFormat(Enum): class Subcategory: id: str category: categories.Category - native_category: NativeCategory | None + native_category: NativeCategory pro_label: str app_label: str search_group_name: str @@ -647,8 +656,8 @@ def category_id(self) -> str: return self.category.id @property - def native_category_id(self) -> str | None: - return self.native_category.id if self.native_category else None + def native_category_id(self) -> str: + return self.native_category.id @property def is_offline_only(self) -> bool: @@ -1294,7 +1303,7 @@ def is_online_only(self) -> bool: CARTE_JEUNES = Subcategory( id="CARTE_JEUNES", category=categories.CARTE_JEUNES, - native_category=None, + native_category=NATIVE_CATEGORY_NONE, pro_label="Carte jeunes", app_label="Carte jeunes", search_group_name=SEARCH_GROUP_CARTES_JEUNES.id, diff --git a/api/src/pcapi/core/search/backends/algolia.py b/api/src/pcapi/core/search/backends/algolia.py index af87182cb26..43f9687d13a 100644 --- a/api/src/pcapi/core/search/backends/algolia.py +++ b/api/src/pcapi/core/search/backends/algolia.py @@ -16,6 +16,7 @@ from pcapi import settings from pcapi.core.categories import categories +from pcapi.core.categories import subcategories_v2 from pcapi.core.educational.academies import get_academy_from_department import pcapi.core.educational.api.offer as educational_api_offer import pcapi.core.educational.models as educational_models @@ -526,7 +527,7 @@ def serialize_offer(cls, offer: offers_models.Offer, last_30_days_bookings: int) search_groups = ( offer.subcategory.native_category.parents - if offer.subcategory.native_category + if offer.subcategory.native_category != subcategories_v2.NATIVE_CATEGORY_NONE else [offer.subcategory.search_group_name] ) diff --git a/api/tests/routes/native/openapi_test.py b/api/tests/routes/native/openapi_test.py index 4f2b7a4fddc..83f375439e0 100644 --- a/api/tests/routes/native/openapi_test.py +++ b/api/tests/routes/native/openapi_test.py @@ -1094,6 +1094,7 @@ def test_public_api(client): "LUDOTHEQUE", "MATERIELS_CREATIFS", "MUSIQUE_EN_LIGNE", + "NATIVE_CATEGORY_NONE", "PARTITIONS_DE_MUSIQUE", "PODCAST", "PRATIQUES_ET_ATELIERS_ARTISTIQUES", @@ -1756,6 +1757,8 @@ def test_public_api(client): "CONCERTS_FESTIVALS", "EVENEMENTS_EN_LIGNE", "FILMS_SERIES_CINEMA", + "CINEMA", + "FILMS_DOCUMENTAIRES_SERIES", "INSTRUMENTS", "JEUX_JEUX_VIDEOS", "LIVRES", diff --git a/api/tests/routes/native/v1/offers_test.py b/api/tests/routes/native/v1/offers_test.py index 413e66de2fa..ef231fcb4a4 100644 --- a/api/tests/routes/native/v1/offers_test.py +++ b/api/tests/routes/native/v1/offers_test.py @@ -2339,7 +2339,7 @@ def test_get_subcategories_v2(self, client): assert found_subcategory_ids == expected_subcategory_ids found_search_group_names = {x["name"] for x in response.json["searchGroups"]} - expected_search_group_names = {x.search_group_name for x in subcategories.ALL_SUBCATEGORIES} + expected_search_group_names = {x.name for x in subcategories.SEARCH_GROUPS} assert found_search_group_names == expected_search_group_names found_home_labels = {x["name"] for x in response.json["homepageLabels"]}