Au moment de l'import, si un événement fait plus de x jours, on le place comme brouillon
Fix #194
This commit is contained in:
parent
0872af5144
commit
7a9e74b057
@ -4,6 +4,7 @@ from django_better_admin_arrayfield.models.fields import ArrayField
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.template.defaultfilters import slugify
|
from django.template.defaultfilters import slugify
|
||||||
|
from django.utils.dateparse import parse_date
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from colorfield.fields import ColorField
|
from colorfield.fields import ColorField
|
||||||
from django_ckeditor_5.fields import CKEditor5Field
|
from django_ckeditor_5.fields import CKEditor5Field
|
||||||
@ -719,6 +720,9 @@ class Event(models.Model):
|
|||||||
def is_single_day(self, intuitive=True):
|
def is_single_day(self, intuitive=True):
|
||||||
return self.start_day == self.get_consolidated_end_day(intuitive)
|
return self.start_day == self.get_consolidated_end_day(intuitive)
|
||||||
|
|
||||||
|
def is_event_long_duration(self, min_days=4, intuitive=True):
|
||||||
|
return parse_date(self.start_day) + timedelta(days=min_days) < parse_date(self.get_consolidated_end_day(intuitive))
|
||||||
|
|
||||||
def contains_date(self, d, intuitive=True):
|
def contains_date(self, d, intuitive=True):
|
||||||
return d >= self.start_day and d <= self.get_consolidated_end_day(intuitive)
|
return d >= self.start_day and d <= self.get_consolidated_end_day(intuitive)
|
||||||
|
|
||||||
@ -1480,6 +1484,10 @@ class Event(models.Model):
|
|||||||
# import this new event
|
# import this new event
|
||||||
to_import.append(event)
|
to_import.append(event)
|
||||||
|
|
||||||
|
for e in to_import:
|
||||||
|
if e.is_event_long_duration():
|
||||||
|
e.status = Event.STATUS.DRAFT
|
||||||
|
|
||||||
# then import all the new events
|
# then import all the new events
|
||||||
imported = Event.objects.bulk_create(to_import)
|
imported = Event.objects.bulk_create(to_import)
|
||||||
# update organisers (m2m relation)
|
# update organisers (m2m relation)
|
||||||
|
Loading…
Reference in New Issue
Block a user