13 export mois

This commit is contained in:
SebF 2024-05-19 16:59:13 +02:00
parent 6795a221da
commit 8bd4fafb17
3 changed files with 17 additions and 6 deletions

View File

@ -58,10 +58,13 @@
<footer> <footer>
{% if calendar.today_in_calendar %} <div class="buttons">
<a role="button" href="{% url 'aujourdhui' %}?{{ filter.get_url }}">Aujourd'hui</a> <a role="button" href="{% url 'month_view_ical' calendar.firstdate.year calendar.firstdate.month %}" >Exporter ical {% picto_from_name "calendar" %}</a>
<a role="button" href="{% url 'cette_semaine' %}?{{ filter.get_url }}">Cette semaine</a> {% if calendar.today_in_calendar %}
{% endif %} <a role="button" href="{% url 'aujourdhui' %}?{{ filter.get_url }}">Aujourd'hui</a>
<a role="button" href="{% url 'cette_semaine' %}?{{ filter.get_url }}">Cette semaine</a>
{% endif %}
</div>
</footer> </footer>
</article> </article>

View File

@ -13,6 +13,7 @@ urlpatterns = [
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("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("mois/<int:year>/<int:month>?feed=ical", month_view_ical, name="month_view_ical"),
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"),
path("aujourdhui/", day_view, name="aujourdhui"), path("aujourdhui/", day_view, name="aujourdhui"),

View File

@ -267,7 +267,10 @@ def home(request):
return week_view(request, home=True) return week_view(request, home=True)
def month_view(request, year=None, month=None): def month_view_ical(request, year=None, month=None):
return month_view(request, year, month, True)
def month_view(request, year=None, month=None, ical=False):
now = date.today() now = date.today()
if year is None: if year is None:
year = now.year year = now.year
@ -277,6 +280,11 @@ def month_view(request, year=None, month=None):
filter = EventFilter(request.GET, queryset=get_event_qs(request), request=request) filter = EventFilter(request.GET, queryset=get_event_qs(request), request=request)
cmonth = CalendarMonth(year, month, filter) cmonth = CalendarMonth(year, month, filter)
if ical:
logger.warning("export ical mois")
response = Event.export_to_ics("testmois", cmonth.get_events())
return response
context = { context = {
"year": year, "year": year,
"month": cmonth.get_month_name(), "month": cmonth.get_month_name(),
@ -301,7 +309,6 @@ def week_view(request, year=None, week=None, home=False, ical=False):
cweek = CalendarWeek(year, week, filter) cweek = CalendarWeek(year, week, filter)
if ical: if ical:
logger.warning("export ical semaine")
response = Event.export_to_ics("testsemaine", cweek.get_events()) response = Event.export_to_ics("testsemaine", cweek.get_events())
return response return response