ajout d'un affichage des événements concurrents (en même temps)
This commit is contained in:
parent
99047597bd
commit
a578e3d70c
@ -21,7 +21,7 @@ from datetime import time, timedelta, date
|
|||||||
from django.utils.timezone import datetime
|
from django.utils.timezone import datetime
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from .calendar import CalendarList
|
from .calendar import CalendarList, CalendarDay
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -296,7 +296,6 @@ class Event(models.Model):
|
|||||||
if self.modified_date is None or not self.is_in_importation_process():
|
if self.modified_date is None or not self.is_in_importation_process():
|
||||||
self.modified_date = now
|
self.modified_date = now
|
||||||
|
|
||||||
|
|
||||||
def get_recurrence_at_date(self, year, month, day):
|
def get_recurrence_at_date(self, year, month, day):
|
||||||
dtstart = timezone.make_aware(datetime(year, month, day, 0, 0), timezone.get_default_timezone())
|
dtstart = timezone.make_aware(datetime(year, month, day, 0, 0), timezone.get_default_timezone())
|
||||||
recurrences = self.get_recurrences_between(dtstart, dtstart)
|
recurrences = self.get_recurrences_between(dtstart, dtstart)
|
||||||
@ -650,6 +649,41 @@ class Event(models.Model):
|
|||||||
|
|
||||||
return imported, nb_updated, nb_draft
|
return imported, nb_updated, nb_draft
|
||||||
|
|
||||||
|
def set_current_date(self, date):
|
||||||
|
self.current_date = date
|
||||||
|
|
||||||
|
|
||||||
|
def get_start_end_datetimes(self, day):
|
||||||
|
if self.start_day == day:
|
||||||
|
if self.start_time is None:
|
||||||
|
dtstart = datetime.combine(self.start_day, time().min)
|
||||||
|
else:
|
||||||
|
dtstart = datetime.combine(self.start_day, self.start_time)
|
||||||
|
else:
|
||||||
|
dtstart = datetime.combine(day, time().min)
|
||||||
|
|
||||||
|
end_day = self.get_consolidated_end_day()
|
||||||
|
|
||||||
|
if end_day == day:
|
||||||
|
if self.end_time is None:
|
||||||
|
dtend = datetime.combine(end_day, time().max)
|
||||||
|
else:
|
||||||
|
dtend = datetime.combine(end_day, self.end_time)
|
||||||
|
else:
|
||||||
|
dtend = datetime.combine(day, time().max)
|
||||||
|
|
||||||
|
return dtstart, dtend
|
||||||
|
|
||||||
|
def get_concurrent_events(self):
|
||||||
|
day = self.current_date if hasattr(self, "current_date") else self.start_day
|
||||||
|
day_events = CalendarDay(self.start_day).get_events()
|
||||||
|
return [e for e in day_events if e != self and self.is_concurrent_event(e, day) and e.status == Event.STATUS.PUBLISHED]
|
||||||
|
|
||||||
|
def is_concurrent_event(self, e, day):
|
||||||
|
dtstart, dtend = self.get_start_end_datetimes(day)
|
||||||
|
e_dtstart, e_dtend = e.get_start_end_datetimes(day)
|
||||||
|
|
||||||
|
return (dtstart <= e_dtstart <= dtend) or (e_dtstart <= dtstart <= e_dtend)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
</article>
|
</article>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
<head>
|
<header>
|
||||||
<p class="message warning"><strong>Attention :</strong> n'utilisez pas le formulaire ci-dessous pour proposer un événement, il sera ignoré. Utilisez plutôt la page <a href="{% url 'add_event' %}">ajouter un événement</a>.</p>
|
<p class="message warning"><strong>Attention :</strong> n'utilisez pas le formulaire ci-dessous pour proposer un événement, il sera ignoré. Utilisez plutôt la page <a href="{% url 'add_event' %}">ajouter un événement</a>.</p>
|
||||||
</head>
|
</header>
|
||||||
<form method="post">{% csrf_token %}
|
<form method="post">{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
<input type="submit" value="Envoyer">
|
<input type="submit" value="Envoyer">
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
|
|
||||||
<aside>
|
<aside>
|
||||||
<article>
|
<article>
|
||||||
<head>
|
<header>
|
||||||
<h2>En résumé</h2>
|
<h2>En résumé</h2>
|
||||||
{% if events|length == 0 %}
|
{% if events|length == 0 %}
|
||||||
<p class="remarque">Il n'y a pas d'événement le {{ day }}</p>
|
<p class="remarque">Il n'y a pas d'événement le {{ day }}</p>
|
||||||
@ -90,13 +90,13 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</head>
|
</header>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
<head>
|
<header>
|
||||||
<h2>Voir aussi</h2>
|
<h2>Voir aussi</h2>
|
||||||
</head>
|
</header>
|
||||||
<a role="button" href="{% url 'week_view' day.year day|week %}?{{ filter.get_url }}">Toute la semaine</a>
|
<a role="button" href="{% url 'week_view' day.year day|week %}?{{ filter.get_url }}">Toute la semaine</a>
|
||||||
</article>
|
</article>
|
||||||
</aside>
|
</aside>
|
||||||
|
@ -15,11 +15,30 @@
|
|||||||
<div class="grid two-columns">
|
<div class="grid two-columns">
|
||||||
{% include "agenda_culturel/single-event/event-single-inc.html" with event=event filter=filter %}
|
{% include "agenda_culturel/single-event/event-single-inc.html" with event=event filter=filter %}
|
||||||
<aside>
|
<aside>
|
||||||
|
{% with event.get_concurrent_events as concurrent_events %}
|
||||||
|
{% if concurrent_events %}
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<h2>En même temps</h2>
|
||||||
|
<p class="remarque">{% if concurrent_events.count > 1 %}Plusieurs événements se déroulent en même temps.{% else %}Un autre événement se déroule en même temps.{% endif %}</p>
|
||||||
|
</header>
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
{% for e in concurrent_events %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ e.get_absolute_url }}">{{ e.title }}</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</article>
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
<!-- TODO: en même temps -->
|
<!-- TODO: en même temps -->
|
||||||
<article>
|
<article>
|
||||||
{% with event.get_nb_events_same_dates as nb_events_same_dates %}
|
{% with event.get_nb_events_same_dates as nb_events_same_dates %}
|
||||||
{% with nb_events_same_dates|length as c_dates %}
|
{% with nb_events_same_dates|length as c_dates %}
|
||||||
<head>
|
<header>
|
||||||
<h2>Voir aussi</h2>
|
<h2>Voir aussi</h2>
|
||||||
{% if c_dates != 1 %}
|
{% if c_dates != 1 %}
|
||||||
<p class="remarque">
|
<p class="remarque">
|
||||||
@ -32,7 +51,7 @@
|
|||||||
que l'événement affiché.
|
que l'événement affiché.
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</head>
|
</header>
|
||||||
<nav>
|
<nav>
|
||||||
{% if c_dates == 1 %}
|
{% if c_dates == 1 %}
|
||||||
<a role="button" href="{% url 'day_view' nb_events_same_dates.0.1.year nb_events_same_dates.0.1.month nb_events_same_dates.0.1.day %}">Toute la journée</a>
|
<a role="button" href="{% url 'day_view' nb_events_same_dates.0.1.year nb_events_same_dates.0.1.month nb_events_same_dates.0.1.day %}">Toute la journée</a>
|
||||||
@ -51,7 +70,7 @@
|
|||||||
</article>
|
</article>
|
||||||
{% if event.possibly_duplicated %}
|
{% if event.possibly_duplicated %}
|
||||||
<article>
|
<article>
|
||||||
<head>
|
<header>
|
||||||
<h2>Possibles doublons</h2>
|
<h2>Possibles doublons</h2>
|
||||||
<p class="remarque">Notre algorithme a détecté que l'événement affiché pourrait être dupliqué sur l'agenda, et consultable dans
|
<p class="remarque">Notre algorithme a détecté que l'événement affiché pourrait être dupliqué sur l'agenda, et consultable dans
|
||||||
{% if event.get_possibly_duplicated.count == 1 %}
|
{% if event.get_possibly_duplicated.count == 1 %}
|
||||||
@ -60,7 +79,7 @@
|
|||||||
d'autres versions
|
d'autres versions
|
||||||
{% endif %}
|
{% endif %}
|
||||||
ci-dessous.</p>
|
ci-dessous.</p>
|
||||||
</head>
|
</header>
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
{% for e in event.get_possibly_duplicated %}
|
{% for e in event.get_possibly_duplicated %}
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
{% load duplicated_extra %}
|
{% load duplicated_extra %}
|
||||||
<aside>
|
<aside>
|
||||||
<article>
|
<article>
|
||||||
<head>
|
<header>
|
||||||
<h2>Consulter</h2>
|
<h2>Consulter</h2>
|
||||||
</head>
|
</header>
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a {% if current == "tags" %}class="selected" {% endif %}href="{% url 'view_all_tags' %}">Toutes les étiquettes</a></li>
|
<li><a {% if current == "tags" %}class="selected" {% endif %}href="{% url 'view_all_tags' %}">Toutes les étiquettes</a></li>
|
||||||
@ -13,9 +13,9 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</article>
|
</article>
|
||||||
<article>
|
<article>
|
||||||
<head>
|
<header>
|
||||||
<h2>Administrer</h2>
|
<h2>Administrer</h2>
|
||||||
</head>
|
</header>
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a {% if current == "moderation" %}class="selected" {% endif %}href="{% url 'moderation' %}">Derniers événements soumis</a>{% show_badges_events "left" %}</li>
|
<li><a {% if current == "moderation" %}class="selected" {% endif %}href="{% url 'moderation' %}">Derniers événements soumis</a>{% show_badges_events "left" %}</li>
|
||||||
@ -26,9 +26,9 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</article>
|
</article>
|
||||||
<article>
|
<article>
|
||||||
<head>
|
<header>
|
||||||
<h2>Configurer</h2>
|
<h2>Configurer</h2>
|
||||||
</head>
|
</header>
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="{% url 'admin:index' %}">Administration de django</a></li>
|
<li><a href="{% url 'admin:index' %}">Administration de django</a></li>
|
||||||
|
@ -222,7 +222,9 @@ class EventDetailView(UserPassesTestMixin, DetailView):
|
|||||||
y = self.kwargs["year"]
|
y = self.kwargs["year"]
|
||||||
m = self.kwargs["month"]
|
m = self.kwargs["month"]
|
||||||
d = self.kwargs["day"]
|
d = self.kwargs["day"]
|
||||||
return o.get_recurrence_at_date(y, m, d)
|
obj = o.get_recurrence_at_date(y, m, d)
|
||||||
|
obj.set_current_date(date(y, m, d))
|
||||||
|
return obj
|
||||||
|
|
||||||
|
|
||||||
@login_required(login_url="/accounts/login/")
|
@login_required(login_url="/accounts/login/")
|
||||||
|
Loading…
Reference in New Issue
Block a user