diff --git a/src/agenda_culturel/celery.py b/src/agenda_culturel/celery.py index 7b2976c..32d7e4f 100644 --- a/src/agenda_culturel/celery.py +++ b/src/agenda_culturel/celery.py @@ -109,10 +109,11 @@ def run_recurrent_import(self, pk): category = str(rimport.defaultCategory) location = rimport.defaultLocation tags = rimport.defaultTags + published = rimport.defaultPublished try: # get events from website - events = u2e.process(url, browsable_url, default_values = {"category": category, "location": location, "tags": tags}, published = True) + events = u2e.process(url, browsable_url, default_values = {"category": category, "location": location, "tags": tags}, published = published) # convert it to json json_events = json.dumps(events, default=str) diff --git a/src/agenda_culturel/migrations/0031_recurrentimport_defaultpublished.py b/src/agenda_culturel/migrations/0031_recurrentimport_defaultpublished.py new file mode 100644 index 0000000..1368334 --- /dev/null +++ b/src/agenda_culturel/migrations/0031_recurrentimport_defaultpublished.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-01-26 12:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda_culturel', '0030_recurrentimport_downloader'), + ] + + operations = [ + migrations.AddField( + model_name='recurrentimport', + name='defaultPublished', + field=models.BooleanField(default=True, help_text='Status of each imported event (published or draft)', verbose_name='Published'), + ), + ] diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index 46c57c4..287a8f6 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -397,7 +397,10 @@ class Event(models.Model): del event_structure["uuid"] if "published" in event_structure and event_structure["published"] is not None: - event_structure["status"] = Event.STATUS.PUBLISHED + if event_structure["published"]: + event_structure["status"] = Event.STATUS.PUBLISHED + else: + event_structure["status"] = Event.STATUS.DRAFT del event_structure["published"] else: event_structure["status"] = Event.STATUS.DRAFT @@ -728,8 +731,8 @@ class RecurrentImport(models.Model): source = models.URLField(verbose_name=_('Source'), help_text=_("URL of the source document"), max_length=1024) browsable_url = models.URLField(verbose_name=_('Browsable url'), help_text=_("URL of the corresponding document that will be shown to visitors."), max_length=1024, blank=True, null=True) + defaultPublished = models.BooleanField(verbose_name=_('Published'), help_text=_('Status of each imported event (published or draft)'), default=True) defaultLocation = models.CharField(verbose_name=_('Location'), help_text=_('Address for each imported event'), max_length=512, null=True, blank=True) - defaultCategory = models.ForeignKey(Category, verbose_name=_('Category'), help_text=_('Category of each imported event'), blank=True, null=True, on_delete=models.SET_NULL) defaultTags = ArrayField(models.CharField(max_length=64), verbose_name=_('Tags for each imported event'), help_text=_("A list of tags that describe each imported event."), blank=True, null=True) diff --git a/src/agenda_culturel/templates/agenda_culturel/page-rimport.html b/src/agenda_culturel/templates/agenda_culturel/page-rimport.html index 2976233..1f3a85d 100644 --- a/src/agenda_culturel/templates/agenda_culturel/page-rimport.html +++ b/src/agenda_culturel/templates/agenda_culturel/page-rimport.html @@ -30,6 +30,7 @@