Compare commits

..

No commits in common. "b563e962dd2f905d252a1b838b75c20cde7b3375" and "6332e083c1e5c705b99faf4dfa87acc9131452aa" have entirely different histories.

2 changed files with 28 additions and 34 deletions

View File

@ -1,7 +1,7 @@
from datetime import date, time, datetime, timedelta
from pytz import timezone
from uuid import uuid4
from os import path
from icalendar import Calendar, Event, vCalAddress, vText
from colloscope.models import *
@ -10,12 +10,32 @@ LOCAL_TZ = "Europe/Paris"
def to_calendar(etudiant, periode):
cal = Calendar()
p = path.abspath('./static/Base_Calendar.ics')
with open(p) as f:
cal = Calendar.from_ical(f.read())
cal.add("prodid", "-//Colloscope//colles.mp2i-vms.fr//")
cal.add("version", "2.0")
cal.add(
"""
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 \
.filter(groupes__membres=etudiant) \
@ -42,7 +62,7 @@ def to_calendar(etudiant, periode):
event.add("categories", "COLLE-" + str(rotation.creneau.matiere))
description = "Groupes: {','.join(str(groupe) for groupe in rotation.groupes.all())}"
event.add("description", description)
event.add(description)
organizer = vCalAddress("mailto:unknown@mp2i-vms.fr")
organizer.params["cn"] = vText(str(rotation.creneau.colleur))

View File

@ -1,26 +0,0 @@
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