WIP export semaine - ne fonctionne pas
This commit is contained in:
parent
fc3b0f8320
commit
1db30afc1a
@ -175,6 +175,9 @@ class CalendarList:
|
|||||||
def calendar_days_list(self):
|
def calendar_days_list(self):
|
||||||
return list(self.calendar_days.values())
|
return list(self.calendar_days.values())
|
||||||
|
|
||||||
|
def get_events(self):
|
||||||
|
return [event for jour in self.calendar_days_list() for event in jour.events]
|
||||||
|
|
||||||
|
|
||||||
class CalendarMonth(CalendarList):
|
class CalendarMonth(CalendarList):
|
||||||
def __init__(self, year, month, filter):
|
def __init__(self, year, month, filter):
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
{% load event_extra %}
|
{% load event_extra %}
|
||||||
{% load utils_extra %}
|
{% load utils_extra %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block entete_header %}
|
{% block entete_header %}
|
||||||
{% css_categories %}
|
{% css_categories %}
|
||||||
@ -20,11 +19,11 @@
|
|||||||
Semaine du {{ calendar.calendar_days_list.0.date|date|frdate }}
|
Semaine du {{ calendar.calendar_days_list.0.date|date|frdate }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% if home %}
|
{% if home %}
|
||||||
<article>{% include "agenda_culturel/static_content.html" with name="home" url_path="/" %}</article>
|
<article>{% include "agenda_culturel/static_content.html" with name="home" url_path="/" %}</article>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% include "agenda_culturel/filter-inc.html" with filter=filter %}
|
{% include "agenda_culturel/filter-inc.html" with filter=filter %}
|
||||||
@ -57,15 +56,15 @@ Semaine du {{ calendar.calendar_days_list.0.date|date|frdate }}
|
|||||||
|
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
|
<a role="button" href="{% url 'week_view_ical' day.year day %}" >Exporter ical {% picto_from_name "calendar" %}</a>
|
||||||
{% if calendar.today_in_calendar %}
|
{% if calendar.today_in_calendar %}
|
||||||
<a role="button" href="{% url 'aujourdhui' %}?{{ filter.get_url }}">Aujourd'hui</a>
|
<a role="button" href="{% url 'aujourdhui' %}?{{ filter.get_url }}">Aujourd'hui</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a role="button" href="{% url 'month_view' calendar.firstdate.year calendar.firstdate.month %}?{{ filter.get_url }}">{{ calendar.firstdate | date:"F o" }}</a>
|
<a role="button" href="{% url 'month_view' calendar.firstdate.year calendar.firstdate.month %}?{{ filter.get_url }}">{{ calendar.firstdate | date:"F o" }}</a>
|
||||||
{% if calendar.firstdate.month != calendar.lastdate.month %}
|
{% if calendar.firstdate.month != calendar.lastdate.month %}
|
||||||
<a role="button" href="{% url 'month_view' calendar.lastdate.year calendar.lastdate.month %}?{{ filter.get_url }}">{{ calendar.lastdate | date:"F o" }}</a>
|
<a role="button" href="{% url 'month_view' calendar.lastdate.year calendar.lastdate.month %}?{{ filter.get_url }}">{{ calendar.lastdate | date:"F o" }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</footer>
|
</footer>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ from .views import *
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", home, name="home"),
|
path("", home, name="home"),
|
||||||
path("semaine/<int:year>/<int:week>/", week_view, name="week_view"),
|
path("semaine/<int:year>/<int:week>/", week_view, name="week_view"),
|
||||||
|
path("semaine/<int:year>/<int:week>?feed=ical", week_view_ical, name="week_view_ical"),
|
||||||
path("mois/<int:year>/<int:month>/", month_view, name="month_view"),
|
path("mois/<int:year>/<int:month>/", month_view, name="month_view"),
|
||||||
path("jour/<int:year>/<int:month>/<int:day>/", day_view, name="day_view"),
|
path("jour/<int:year>/<int:month>/<int:day>/", day_view, name="day_view"),
|
||||||
path("jour/<int:year>/<int:month>/<int:day>?feed=ical", day_view_ical, name="day_view_ical"),
|
path("jour/<int:year>/<int:month>/<int:day>?feed=ical", day_view_ical, name="day_view_ical"),
|
||||||
|
@ -286,7 +286,11 @@ def month_view(request, year=None, month=None):
|
|||||||
return render(request, "agenda_culturel/page-month.html", context)
|
return render(request, "agenda_culturel/page-month.html", context)
|
||||||
|
|
||||||
|
|
||||||
def week_view(request, year=None, week=None, home=False):
|
def week_view_ical(request, year=None, week=None, home=False):
|
||||||
|
return week_view(request, year, week, home, True)
|
||||||
|
|
||||||
|
|
||||||
|
def week_view(request, year=None, week=None, home=False, ical=False):
|
||||||
now = date.today()
|
now = date.today()
|
||||||
if year is None:
|
if year is None:
|
||||||
year = now.year
|
year = now.year
|
||||||
@ -296,14 +300,21 @@ def week_view(request, year=None, week=None, home=False):
|
|||||||
filter = EventFilter(request.GET, queryset=get_event_qs(request), request=request)
|
filter = EventFilter(request.GET, queryset=get_event_qs(request), request=request)
|
||||||
cweek = CalendarWeek(year, week, filter)
|
cweek = CalendarWeek(year, week, filter)
|
||||||
|
|
||||||
|
if ical:
|
||||||
|
logger.warning("export ical semaine")
|
||||||
|
response = Event.export_to_ics("testsemaine", cweek.get_events())
|
||||||
|
return response
|
||||||
|
|
||||||
context = {"year": year, "week": week, "calendar": cweek, "filter": filter}
|
context = {"year": year, "week": week, "calendar": cweek, "filter": filter}
|
||||||
if home:
|
if home:
|
||||||
context["home"] = 1
|
context["home"] = 1
|
||||||
return render(request, "agenda_culturel/page-week.html", context)
|
return render(request, "agenda_culturel/page-week.html", context)
|
||||||
|
|
||||||
|
|
||||||
def day_view_ical(request, year=None, month=None, day=None):
|
def day_view_ical(request, year=None, month=None, day=None):
|
||||||
return day_view(request, year, month, day, ical=True)
|
return day_view(request, year, month, day, ical=True)
|
||||||
|
|
||||||
|
|
||||||
def day_view(request, year=None, month=None, day=None, ical=False):
|
def day_view(request, year=None, month=None, day=None, ical=False):
|
||||||
now = date.today()
|
now = date.today()
|
||||||
if year is None:
|
if year is None:
|
||||||
@ -327,7 +338,7 @@ def day_view(request, year=None, month=None, day=None, ical=False):
|
|||||||
categories = [(k, v) for k, v in categories.items()]
|
categories = [(k, v) for k, v in categories.items()]
|
||||||
categories.sort(key=lambda k: -k[1])
|
categories.sort(key=lambda k: -k[1])
|
||||||
|
|
||||||
if "ical" in str(request):
|
if ical:
|
||||||
response = Event.export_to_ics(str(day), cday.get_events())
|
response = Event.export_to_ics(str(day), cday.get_events())
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user