From 2a6697b28db115e27187cf300957296962bd5c41 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sun, 15 Sep 2024 11:34:48 +0200 Subject: [PATCH] =?UTF-8?q?On=20remplace=20"Autre"=20par=20"Sans=20cat?= =?UTF-8?q?=C3=A9gorie"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- experimentations/get_ical_events.py | 2 +- .../import_tasks/custom_extractors/lacomedie.py | 6 +++--- .../import_tasks/custom_extractors/wordpress_mec.py | 8 ++++---- src/agenda_culturel/models.py | 9 ++++++--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/experimentations/get_ical_events.py b/experimentations/get_ical_events.py index 0920f59..199f36b 100755 --- a/experimentations/get_ical_events.py +++ b/experimentations/get_ical_events.py @@ -32,7 +32,7 @@ if __name__ == "__main__": url = "https://calendar.google.com/calendar/ical/programmation.lesaugustes%40gmail.com/public/basic.ics" url_human = "https://www.cafelesaugustes.fr/la-programmation/" - events = u2e.process(url, url_human, cache = "cache-augustes.ical", default_values = {"category": "Autre", "location": "Café lecture les Augustes"}, published = True) + events = u2e.process(url, url_human, cache = "cache-augustes.ical", default_values = {"category": "Sans catégorie", "location": "Café lecture les Augustes"}, published = True) exportfile = "events-augustes.json" print("Saving events to file {}".format(exportfile)) diff --git a/src/agenda_culturel/import_tasks/custom_extractors/lacomedie.py b/src/agenda_culturel/import_tasks/custom_extractors/lacomedie.py index 762d119..01b5030 100644 --- a/src/agenda_culturel/import_tasks/custom_extractors/lacomedie.py +++ b/src/agenda_culturel/import_tasks/custom_extractors/lacomedie.py @@ -13,9 +13,9 @@ class CExtractor(TwoStepsExtractor): mapping = { "Théâtre": "Théâtre", "Danse": "Danse", - "Rencontre": "Autre", - "Sortie de résidence": "Autre", - "PopCorn Live": "Autre", + "Rencontre": "Sans catégorie", + "Sortie de résidence": "Sans catégorie", + "PopCorn Live": "Sans catégorie", } if category in mapping: return mapping[category] diff --git a/src/agenda_culturel/import_tasks/custom_extractors/wordpress_mec.py b/src/agenda_culturel/import_tasks/custom_extractors/wordpress_mec.py index be3f5f0..cf0f2db 100644 --- a/src/agenda_culturel/import_tasks/custom_extractors/wordpress_mec.py +++ b/src/agenda_culturel/import_tasks/custom_extractors/wordpress_mec.py @@ -10,11 +10,11 @@ class CExtractor(TwoStepsExtractor): mapping = { "Musique": "Concert", "CONCERT": "Concert", - "VISITE": "Autre", + "VISITE": "Sans catégorie", "Spectacle": "Théâtre", - "Rencontre": "Autre", - "Atelier": "Autre", - "Projection": "Autre", + "Rencontre": "Sans catégorie", + "Atelier": "Sans catégorie", + "Projection": "Sans catégorie", } if category in mapping: return mapping[category] diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index ab9c209..af1e373 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -714,9 +714,12 @@ class Event(models.Model): def from_structure(event_structure, import_source=None): if "category" in event_structure and event_structure["category"] is not None: - event_structure["category"] = Category.objects.get( - name=event_structure["category"] - ) + try: + event_structure["category"] = Category.objects.get( + name=event_structure["category"] + ) + except Category.DoesNotExist: + event_structure["category"] = Category.get_default_category() if "published" in event_structure and event_structure["published"] is not None: if event_structure["published"]: