From 2bc1f3613900cc5249c352ee512fa53a5ab48be3 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sun, 22 Sep 2024 12:15:24 +0200 Subject: [PATCH] =?UTF-8?q?On=20corrige=20un=20bug=20en=20cas=20de=20cr?= =?UTF-8?q?=C3=A9ation=20sans=20run?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/agenda_culturel/models.py | 5 ++++- src/agenda_culturel/templates/agenda_culturel/rimports.html | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index ab8ba29..042871f 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -1364,7 +1364,10 @@ class RecurrentImport(models.Model): events = BatchImportation.objects.filter(recurrentImport=self).order_by( "-created_date" ) - return events[0] + if events and len(events) > 0: + return events[0] + else: + return None class BatchImportation(models.Model): diff --git a/src/agenda_culturel/templates/agenda_culturel/rimports.html b/src/agenda_culturel/templates/agenda_culturel/rimports.html index 31eab13..8436981 100644 --- a/src/agenda_culturel/templates/agenda_culturel/rimports.html +++ b/src/agenda_culturel/templates/agenda_culturel/rimports.html @@ -82,7 +82,7 @@
- {% if obj.last_import.status != "running" %} + {% if not obj.last_import or obj.last_import.status != "running" %} Exécuter {% else %} Annuler