Merge pull request 'fix broken ics export' (#2) from dev into main
Reviewed-on: sl_game_studio/kholles-web#2
This commit is contained in:
commit
b563e962dd
|
@ -1,7 +1,7 @@
|
||||||
from datetime import date, time, datetime, timedelta
|
from datetime import date, time, datetime, timedelta
|
||||||
from pytz import timezone
|
from pytz import timezone
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
from os import path
|
||||||
from icalendar import Calendar, Event, vCalAddress, vText
|
from icalendar import Calendar, Event, vCalAddress, vText
|
||||||
|
|
||||||
from colloscope.models import *
|
from colloscope.models import *
|
||||||
|
@ -10,32 +10,12 @@ LOCAL_TZ = "Europe/Paris"
|
||||||
|
|
||||||
|
|
||||||
def to_calendar(etudiant, periode):
|
def to_calendar(etudiant, periode):
|
||||||
cal = Calendar()
|
|
||||||
|
|
||||||
cal.add("prodid", "-//Colloscope//colles.mp2i-vms.fr//")
|
p = path.abspath('./static/Base_Calendar.ics')
|
||||||
cal.add("version", "2.0")
|
|
||||||
cal.add(
|
with open(p) as f:
|
||||||
"""
|
cal = Calendar.from_ical(f.read())
|
||||||
BEGIN:VTIMEZONE
|
|
||||||
TZID:Europe/Paris
|
|
||||||
X-LIC-LOCATION:Europe/Paris
|
|
||||||
BEGIN:DAYLIGHT
|
|
||||||
TZOFFSETFROM:+0100
|
|
||||||
TZOFFSETTO:+0200
|
|
||||||
TZNAME:CEST
|
|
||||||
DTSTART:19700329T020000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
|
|
||||||
END:DAYLIGHT
|
|
||||||
BEGIN:STANDARD
|
|
||||||
TZOFFSETFROM:+0200
|
|
||||||
TZOFFSETTO:+0100
|
|
||||||
TZNAME:CET
|
|
||||||
DTSTART:19701025T030000
|
|
||||||
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
|
|
||||||
END:STANDARD
|
|
||||||
END:VTIMEZONE
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
rotations = Rotation.objects \
|
rotations = Rotation.objects \
|
||||||
.filter(groupes__membres=etudiant) \
|
.filter(groupes__membres=etudiant) \
|
||||||
|
@ -62,7 +42,7 @@ def to_calendar(etudiant, periode):
|
||||||
event.add("categories", "COLLE-" + str(rotation.creneau.matiere))
|
event.add("categories", "COLLE-" + str(rotation.creneau.matiere))
|
||||||
|
|
||||||
description = "Groupes: {','.join(str(groupe) for groupe in rotation.groupes.all())}"
|
description = "Groupes: {','.join(str(groupe) for groupe in rotation.groupes.all())}"
|
||||||
event.add(description)
|
event.add("description", description)
|
||||||
|
|
||||||
organizer = vCalAddress("mailto:unknown@mp2i-vms.fr")
|
organizer = vCalAddress("mailto:unknown@mp2i-vms.fr")
|
||||||
organizer.params["cn"] = vText(str(rotation.creneau.colleur))
|
organizer.params["cn"] = vText(str(rotation.creneau.colleur))
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
BEGIN:VCALENDAR
|
||||||
|
PRODID:-//mp2i-vms-[2]-(23-24)-s3//Stackity Bot Inc//EN
|
||||||
|
VERSION:2.0
|
||||||
|
CALSCALE:GREGORIAN
|
||||||
|
METHOD:PUBLISH
|
||||||
|
X-WR-CALNAME:EDT
|
||||||
|
X-WR-TIMEZONE:Europe/Paris
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
TZID:Europe/Paris
|
||||||
|
X-LIC-LOCATION:Europe/Paris
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
TZNAME:CEST
|
||||||
|
DTSTART:19700329T020000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
TZNAME:CET
|
||||||
|
DTSTART:19701025T030000
|
||||||
|
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
|
||||||
|
END:STANDARD
|
||||||
|
END:VTIMEZONE
|
||||||
|
END:VCALENDAR
|
Loading…
Reference in New Issue