diff --git a/src/agenda_culturel/celery.py b/src/agenda_culturel/celery.py index 2904f7c..6c83ebc 100644 --- a/src/agenda_culturel/celery.py +++ b/src/agenda_culturel/celery.py @@ -243,14 +243,17 @@ def import_events_from_url(self, url, cat): url, published=False, default_values=values ) - # convert it to json - json_events = json.dumps(events, default=str) + if events: + # convert it to json + json_events = json.dumps(events, default=str) - # import events (from json) - success, error_message = importer.import_events(json_events) + # import events (from json) + success, error_message = importer.import_events(json_events) - # finally, close task - close_import_task(self.request.id, success, error_message, importer) + # finally, close task + close_import_task(self.request.id, success, error_message, importer) + else: + close_import_task(self.request.id, False, "Cannot find any event", importer) except Exception as e: logger.error(e) close_import_task(self.request.id, False, e, importer) diff --git a/src/agenda_culturel/import_tasks/extractor_facebook.py b/src/agenda_culturel/import_tasks/extractor_facebook.py index 1909317..fd131a5 100644 --- a/src/agenda_culturel/import_tasks/extractor_facebook.py +++ b/src/agenda_culturel/import_tasks/extractor_facebook.py @@ -264,6 +264,8 @@ class FacebookEventExtractor(Extractor): event["category"] = default_values["category"] self.add_event(**event) return self.get_structure() + else: + logger.warning("cannot find any event in page") return None diff --git a/src/agenda_culturel/import_tasks/extractor_ggcal_link.py b/src/agenda_culturel/import_tasks/extractor_ggcal_link.py index de7533d..b5840c7 100644 --- a/src/agenda_culturel/import_tasks/extractor_ggcal_link.py +++ b/src/agenda_culturel/import_tasks/extractor_ggcal_link.py @@ -66,5 +66,4 @@ class GoogleCalendarLinkEventExtractor(Extractor): break - logger.warning("ça marche") return self.get_structure() \ No newline at end of file