Ajout d'un drapeau permettant de décider si les événements sont publiés par défaut
This commit is contained in:
parent
8d5dca4910
commit
2275203ff9
@ -109,10 +109,11 @@ def run_recurrent_import(self, pk):
|
|||||||
category = str(rimport.defaultCategory)
|
category = str(rimport.defaultCategory)
|
||||||
location = rimport.defaultLocation
|
location = rimport.defaultLocation
|
||||||
tags = rimport.defaultTags
|
tags = rimport.defaultTags
|
||||||
|
published = rimport.defaultPublished
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# get events from website
|
# 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
|
# convert it to json
|
||||||
json_events = json.dumps(events, default=str)
|
json_events = json.dumps(events, default=str)
|
||||||
|
@ -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'),
|
||||||
|
),
|
||||||
|
]
|
@ -397,7 +397,10 @@ class Event(models.Model):
|
|||||||
del event_structure["uuid"]
|
del event_structure["uuid"]
|
||||||
|
|
||||||
if "published" in event_structure and event_structure["published"] is not None:
|
if "published" in event_structure and event_structure["published"] is not None:
|
||||||
|
if event_structure["published"]:
|
||||||
event_structure["status"] = Event.STATUS.PUBLISHED
|
event_structure["status"] = Event.STATUS.PUBLISHED
|
||||||
|
else:
|
||||||
|
event_structure["status"] = Event.STATUS.DRAFT
|
||||||
del event_structure["published"]
|
del event_structure["published"]
|
||||||
else:
|
else:
|
||||||
event_structure["status"] = Event.STATUS.DRAFT
|
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)
|
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)
|
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)
|
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)
|
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)
|
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)
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
<li><strong>Adresse naviguable :</strong> <a href="{{ object.browsable_url }}">{{ object.browsable_url }}</a></li>
|
<li><strong>Adresse naviguable :</strong> <a href="{{ object.browsable_url }}">{{ object.browsable_url }}</a></li>
|
||||||
<li><strong>Valeurs par défaut :</strong>
|
<li><strong>Valeurs par défaut :</strong>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><strong>Publié :</strong> {{ object.defaultPublished }}</li>
|
||||||
<li><strong>Localisation :</strong> {{ object.defaultLocation }}</li>
|
<li><strong>Localisation :</strong> {{ object.defaultLocation }}</li>
|
||||||
<li><strong>Catégorie :</strong> {{ object.defaultCategory }}</li>
|
<li><strong>Catégorie :</strong> {{ object.defaultCategory }}</li>
|
||||||
<li><strong>Étiquettes :</strong>
|
<li><strong>Étiquettes :</strong>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user