Fix #112 : éléments récurrents et relatedto
This commit is contained in:
parent
ebf992112d
commit
1ca9667ac9
@ -65,5 +65,5 @@ class CExtractor(TwoStepsExtractor):
|
||||
|
||||
url_human = event_url
|
||||
|
||||
self.add_event_with_props(event_url, None, None, None, None, description, [], recurrences=None, uuid=event_url, url_human=url_human, published=published, image=image)
|
||||
self.add_event_with_props(event_url, None, None, None, None, description, [], recurrences=None, uuids=[event_url], url_human=url_human, published=published, image=image)
|
||||
|
||||
|
@ -60,5 +60,5 @@ class CExtractor(TwoStepsExtractor):
|
||||
location = CExtractor.nom_lieu
|
||||
url_human = event_url
|
||||
|
||||
self.add_event_with_props(event_url, title, category, start_day, location, description, tags, recurrences=None, uuid=event_url, url_human=url_human, start_time=start_time, end_day=end_day, end_time=end_time, published=published, image=image)
|
||||
self.add_event_with_props(event_url, title, category, start_day, location, description, tags, recurrences=None, uuids=[event_url], url_human=url_human, start_time=start_time, end_day=end_day, end_time=end_time, published=published, image=image)
|
||||
|
||||
|
@ -70,4 +70,4 @@ class CExtractor(TwoStepsExtractor):
|
||||
else:
|
||||
description = None
|
||||
|
||||
self.add_event_with_props(event_url, None, "Concert", start_day, location, description, tags, recurrences=None, uuid=event_url, url_human=url_human, start_time=start_time, end_day=end_day, end_time=end_time, published=published, image=image)
|
||||
self.add_event_with_props(event_url, None, "Concert", start_day, location, description, tags, recurrences=None, uuids=[event_url], url_human=url_human, start_time=start_time, end_day=end_day, end_time=end_time, published=published, image=image)
|
||||
|
@ -68,5 +68,5 @@ class CExtractor(TwoStepsExtractor):
|
||||
|
||||
url_human = event_url
|
||||
|
||||
self.add_event_with_props(event_url, None, None, start_day, location, description, tags, recurrences=None, uuid=event_url, url_human=url_human, start_time=start_time, end_day=end_day, end_time=end_time, published=published, image=image)
|
||||
self.add_event_with_props(event_url, None, None, start_day, location, description, tags, recurrences=None, uuids=[event_url], url_human=url_human, start_time=start_time, end_day=end_day, end_time=end_time, published=published, image=image)
|
||||
|
||||
|
@ -118,7 +118,7 @@ class Extractor(ABC):
|
||||
def clear_events(self):
|
||||
self.events = []
|
||||
|
||||
def add_event(self, title, category, start_day, location, description, tags, uuid, recurrences=None, url_human=None, start_time=None, end_day=None, end_time=None, last_modified=None, published=False, image=None, image_alt=None):
|
||||
def add_event(self, title, category, start_day, location, description, tags, uuids, recurrences=None, url_human=None, start_time=None, end_day=None, end_time=None, last_modified=None, published=False, image=None, image_alt=None):
|
||||
if title is None:
|
||||
print("ERROR: cannot import an event without name")
|
||||
return
|
||||
@ -130,7 +130,7 @@ class Extractor(ABC):
|
||||
"title": title,
|
||||
"category": category,
|
||||
"start_day": start_day,
|
||||
"uuid": uuid,
|
||||
"uuids": uuids,
|
||||
"location": location,
|
||||
"description": description,
|
||||
"tags": tags,
|
||||
|
@ -152,7 +152,7 @@ class FacebookEventExtractor(Extractor):
|
||||
"location": self.get_element("event_place_name"),
|
||||
"description": self.get_element("description"),
|
||||
"tags": [],
|
||||
"uuid": url,
|
||||
"uuids": [url],
|
||||
"url_human": url,
|
||||
"start_time": self.get_element_time("start_timestamp"),
|
||||
"end_day": self.get_element_date("end_timestamp"),
|
||||
|
@ -92,6 +92,15 @@ class ICALExtractor(Extractor):
|
||||
self.uuids[uuid] = 1
|
||||
event_url = url + "#" + uuid
|
||||
|
||||
uuidrel = None
|
||||
related_to = self.get_item_from_vevent(event, "RELATED-TO")
|
||||
if related_to is not None:
|
||||
if related_to in self.uuids:
|
||||
self.uuids[related_to] += 1
|
||||
uuidrel = url + "#" + related_to + ":{:04}".format(self.uuids[related_to] - 1)
|
||||
# possible limitation: if the ordering is not original then related
|
||||
|
||||
|
||||
tags = self.default_value_if_exists(default_values, "tags")
|
||||
|
||||
last_modified = self.get_item_from_vevent(event, "LAST-MODIFIED", raw = True)
|
||||
@ -114,7 +123,11 @@ class ICALExtractor(Extractor):
|
||||
recurrences = None
|
||||
|
||||
if title is not None:
|
||||
self.add_event(title, category, start_day, location, description, tags, recurrences=recurrences, uuid=event_url, url_human=url_human, start_time=start_time, end_day=end_day, end_time=end_time, last_modified=last_modified, published=published)
|
||||
luuids = [event_url]
|
||||
if uuidrel is not None:
|
||||
luuids += [uuidrel]
|
||||
self.add_event(title, category, start_day, location, description, tags, recurrences=recurrences, uuids=luuids, url_human=url_human, start_time=start_time, end_day=end_day, end_time=end_time, last_modified=last_modified, published=published)
|
||||
|
||||
|
||||
return self.get_structure()
|
||||
|
||||
@ -122,9 +135,9 @@ class ICALExtractor(Extractor):
|
||||
# A variation on ICAL extractor that removes any even named "Busy"
|
||||
class ICALNoBusyExtractor(ICALExtractor):
|
||||
|
||||
def add_event(self, title, category, start_day, location, description, tags, uuid, recurrences=None, url_human=None, start_time=None, end_day=None, end_time=None, last_modified=None, published=False, image=None, image_alt=None):
|
||||
def add_event(self, title, category, start_day, location, description, tags, uuids, recurrences=None, url_human=None, start_time=None, end_day=None, end_time=None, last_modified=None, published=False, image=None, image_alt=None):
|
||||
if title != 'Busy':
|
||||
super().add_event(title, category, start_day, location, description, tags, uuid, recurrences, url_human, start_time, end_day, end_time, last_modified, published, image, image_alt)
|
||||
super().add_event(title, category, start_day, location, description, tags, uuids, recurrences, url_human, start_time, end_day, end_time, last_modified, published, image, image_alt)
|
||||
|
||||
|
||||
# A variation on ICAL extractor that remove any visual composer anchors
|
||||
@ -145,5 +158,5 @@ class ICALNoVCExtractor(ICALExtractor):
|
||||
result = self.parser.format(text)
|
||||
return result
|
||||
|
||||
def add_event(self, title, category, start_day, location, description, tags, uuid, recurrences=None, url_human=None, start_time=None, end_day=None, end_time=None, last_modified=None, published=False, image=None, image_alt=None):
|
||||
super().add_event(title, category, start_day, location, self.clean_vc(description), tags, uuid, recurrences, url_human, start_time, end_day, end_time, last_modified, published, image, image_alt)
|
||||
def add_event(self, title, category, start_day, location, description, tags, uuids, recurrences=None, url_human=None, start_time=None, end_day=None, end_time=None, last_modified=None, published=False, image=None, image_alt=None):
|
||||
super().add_event(title, category, start_day, location, self.clean_vc(description), tags, uuids, recurrences, url_human, start_time, end_day, end_time, last_modified, published, image, image_alt)
|
@ -96,7 +96,7 @@ class TwoStepsExtractor(Extractor):
|
||||
self.event_properties[url] = {}
|
||||
self.event_properties[url]["location"] = loc
|
||||
|
||||
def add_event_with_props(self, event_url, title, category, start_day, location, description, tags, uuid, recurrences=None, url_human=None, start_time=None, end_day=None, end_time=None, last_modified=None, published=False, image=None, image_alt=None):
|
||||
def add_event_with_props(self, event_url, title, category, start_day, location, description, tags, uuids, recurrences=None, url_human=None, start_time=None, end_day=None, end_time=None, last_modified=None, published=False, image=None, image_alt=None):
|
||||
|
||||
if event_url in self.event_properties:
|
||||
if 'tags' in self.event_properties[event_url]:
|
||||
@ -112,7 +112,7 @@ class TwoStepsExtractor(Extractor):
|
||||
if 'location' in self.event_properties[event_url]:
|
||||
location = self.event_properties[event_url]['location']
|
||||
|
||||
self.add_event(title, category, start_day, location, description, tags, uuid, recurrences, url_human, start_time, end_day, end_time, last_modified, published, image, image_alt)
|
||||
self.add_event(title, category, start_day, location, description, tags, uuids, recurrences, url_human, start_time, end_day, end_time, last_modified, published, image, image_alt)
|
||||
|
||||
|
||||
@abstractmethod
|
||||
|
@ -407,10 +407,6 @@ class Event(models.Model):
|
||||
if "category" in event_structure and event_structure["category"] is not None:
|
||||
event_structure["category"] = Category.objects.get(name=event_structure["category"])
|
||||
|
||||
if "uuid" in event_structure and event_structure["uuid"] is not None:
|
||||
event_structure["uuids"] = [event_structure["uuid"]]
|
||||
del event_structure["uuid"]
|
||||
|
||||
if "published" in event_structure and event_structure["published"] is not None:
|
||||
if event_structure["published"]:
|
||||
event_structure["status"] = Event.STATUS.PUBLISHED
|
||||
@ -618,8 +614,8 @@ class Event(models.Model):
|
||||
max_date = sdate
|
||||
if max_date is None or (event.end_day is not None and max_date < edate):
|
||||
max_date = edate
|
||||
if len(event.uuids) > 0:
|
||||
uuids.add(event.uuids[0])
|
||||
if event.uuids and len(event.uuids) > 0:
|
||||
uuids |= set(event.uuids)
|
||||
|
||||
# imported events should be updated
|
||||
event.set_in_importation_process()
|
||||
|
@ -46,7 +46,7 @@
|
||||
</p>
|
||||
<p>
|
||||
{% picto_from_name "calendar" %}
|
||||
{% if event.end_day %}du{% else %}le{% endif %}
|
||||
{% if event.end_day and event.end_day != event.start_day %}du{% else %}le{% endif %}
|
||||
{% include "agenda_culturel/date-times-inc.html" with event=event %}
|
||||
</p>
|
||||
</header>
|
||||
|
@ -1,10 +1,10 @@
|
||||
{% load utils_extra %}
|
||||
|
||||
{{ event.start_day|date|frdate }}
|
||||
{% if event.start_time %} {% if not event.end_day %}{% if event.end_time %}de{% else %}à{% endif %}{% endif %}
|
||||
{% if event.start_time %} {% if not event.end_day or event.end_day == event.start_day %}{% if event.end_time %}de{% else %}à{% endif %}{% endif %}
|
||||
{{ event.start_time }}
|
||||
{% endif %}
|
||||
{% if event.end_day %}
|
||||
au {% if event.end_day %}{{ event.end_day|date|frdate }}{% endif %}
|
||||
{% if event.end_day and event.end_day != event.start_day %}
|
||||
au {% if event.end_day and event.end_day != event.start_day %}{{ event.end_day|date|frdate }}{% endif %}
|
||||
{% endif %}
|
||||
{% if event.end_time %} {% if not event.end_day|date|frdate %}jusqu'à{% endif %} {{ event.end_time }}{% endif %}
|
||||
{% if event.end_time %} {% if not event.end_day|date|frdate or event.end_day == event.start_day %}jusqu'à{% endif %} {{ event.end_time }}{% endif %}
|
@ -7,7 +7,7 @@
|
||||
<a href="{{ event.get_absolute_url }}">
|
||||
{% if event.title_hl %}{{ event.title_hl | safe }}{% else %}{{ event.title }}{% endif %}</a></p>
|
||||
<p class="subentry-search">{% picto_from_name "calendar" %}
|
||||
{% if event.end_day %}du{% else %}le{% endif %}
|
||||
{% if event.end_day and event.end_day != event.start_day %}du{% else %}le{% endif %}
|
||||
{% include "agenda_culturel/date-times-inc.html" with event=event %}
|
||||
</header>
|
||||
<p class="subentry-search"></p>
|
||||
|
@ -36,7 +36,7 @@
|
||||
{% if event|need_complete_display:True %}<p>
|
||||
{% picto_from_name "calendar" %}
|
||||
|
||||
<em>{% if event.end_day %}Cet événement dure du {% else %}Cet événement a lieu le{% endif %}
|
||||
<em>{% if event.end_day and event.end_day != event.start_day %}Cet événement dure du {% else %}Cet événement a lieu le{% endif %}
|
||||
{% include "agenda_culturel/date-times-inc.html" with event=event %}
|
||||
</em></p>
|
||||
{% endif %}
|
||||
|
@ -24,7 +24,7 @@
|
||||
{% if event|need_complete_display:False %}<p>
|
||||
{% picto_from_name "calendar" %}
|
||||
|
||||
<em>{% if event.end_day %}Cet événement dure du {% else %}Cet événement a lieu le{% endif %}
|
||||
<em>{% if event.end_day and event.end_day != event.start_day %}Cet événement dure du {% else %}Cet événement a lieu le{% endif %}
|
||||
{% include "agenda_culturel/date-times-inc.html" with event=event %}
|
||||
</em></p>
|
||||
{% endif %}
|
||||
|
@ -19,7 +19,7 @@
|
||||
</p>
|
||||
<p>
|
||||
{% picto_from_name "calendar" %}
|
||||
{% if event.end_day %}du{% else %}le{% endif %}
|
||||
{% if event.end_day and event.end_day != event.start_day %}du{% else %}le{% endif %}
|
||||
{% include "agenda_culturel/date-times-inc.html" with event=event %}
|
||||
</p>
|
||||
</header>
|
||||
|
@ -11,7 +11,7 @@
|
||||
<h1>{{ event|picto_status }} {{ event.title }}</h1>
|
||||
<p>
|
||||
{% picto_from_name "calendar" %}
|
||||
{% if event.end_day %}du{% else %}le{% endif %}
|
||||
{% if event.end_day and event.end_day != event.start_day %}du{% else %}le{% endif %}
|
||||
{% include "agenda_culturel/date-times-inc.html" with event=event %}
|
||||
</p>
|
||||
<p>
|
||||
|
Loading…
Reference in New Issue
Block a user