Compare commits
15 Commits
b8573f3826
...
fb9580c26e
Author | SHA1 | Date |
---|---|---|
|
fb9580c26e | |
|
ac0f0e75e6 | |
|
b81c70519b | |
|
214abf1f43 | |
|
0bfa51bf0c | |
|
8bd4cfa756 | |
|
4b3f1462e7 | |
|
d26e1e5690 | |
|
22b6e77997 | |
|
e671b5a1a1 | |
|
b563e962dd | |
|
b1556643de | |
|
35bf2e794a | |
|
6332e083c1 | |
|
5fd334f7fa |
|
@ -159,3 +159,5 @@ cython_debug/
|
|||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
.idea/
|
||||
|
||||
kholles_web/settings.py
|
||||
|
|
|
@ -1,47 +1,55 @@
|
|||
from datetime import date, time, datetime, timedelta
|
||||
from pytz import timezone
|
||||
|
||||
from unidecode import unidecode
|
||||
from os import path
|
||||
from icalendar import Calendar, Event, vCalAddress, vText
|
||||
|
||||
from colloscope.models import *
|
||||
|
||||
LOCAL_TZ = "Europe/Paris"
|
||||
|
||||
|
||||
def emailize(nom, prenom=None):
|
||||
if prenom is not None:
|
||||
return "{}.{}@example.com" \
|
||||
.format(
|
||||
prenom.replace(" ", "_").lower(),
|
||||
nom.replace(" ", "_").lower()
|
||||
)
|
||||
.format(
|
||||
unidecode(prenom).replace(" ", "_").lower(),
|
||||
unidecode(nom).replace(" ", "_").lower()
|
||||
)
|
||||
else:
|
||||
return "{}@example.com" \
|
||||
.format(nom.replace(" ", "_").lower())
|
||||
.format(unidecode(nom).replace(" ", "_").lower())
|
||||
|
||||
|
||||
def to_calendar(etudiant, periode):
|
||||
cal = Calendar()
|
||||
p = path.abspath('./static/Base_Calendar.ics')
|
||||
|
||||
cal.add("prodid", "-//Colloscope//colles.mp2i-vms.fr//")
|
||||
cal.add("version", "2.0")
|
||||
with open(p) as f:
|
||||
cal = Calendar.from_ical(f.read())
|
||||
|
||||
rotations = Rotation.objects \
|
||||
.filter(groupes__membres=etudiant) \
|
||||
.select_related("creneau__periode__classe__lycee") \
|
||||
.select_related("creneau__matiere") \
|
||||
.select_related("creneau__colleur") \
|
||||
.filter(groupes__membres=etudiant, creneau__periode=periode) \
|
||||
.select_related("creneau__periode__classe__lycee") \
|
||||
.select_related("creneau__matiere") \
|
||||
.select_related("creneau__colleur")
|
||||
|
||||
for rotation in rotations:
|
||||
event = Event()
|
||||
event.add("name", "Colle")
|
||||
event.add("summary", str(rotation))
|
||||
|
||||
|
||||
summary = f"Colle {rotation.creneau.matiere} ({rotation.creneau.colleur})"
|
||||
event.add("summary", summary)
|
||||
|
||||
start = rotation.datetime()
|
||||
fin = start + rotation.creneau.duree
|
||||
|
||||
event.add("dtstart", start)
|
||||
event.add("dtend", fin)
|
||||
event.add("dtstart", start, parameters={"tzid": LOCAL_TZ})
|
||||
event.add("dtend", fin, parameters={"tzid": LOCAL_TZ})
|
||||
event.add("dtstamp", datetime.now())
|
||||
event.add("uid", str(rotation.id))
|
||||
|
||||
event.add("location", f"{rotation.creneau.salle} ({rotation.creneau.periode.classe.lycee})")
|
||||
event.add("matiere", str(rotation.creneau.matiere))
|
||||
event.add("categories", "COLLE-" + str(rotation.creneau.matiere))
|
||||
|
||||
description = f"Groupes: {','.join(str(groupe) for groupe in rotation.groupes.all())}"
|
||||
event.add("description", description)
|
||||
|
||||
organizer = vCalAddress(f"mailto:{emailize(rotation.creneau.colleur.nom)}")
|
||||
organizer.params["cn"] = vText(str(rotation.creneau.colleur))
|
||||
|
@ -49,7 +57,7 @@ def to_calendar(etudiant, periode):
|
|||
event.add("organizer", organizer)
|
||||
|
||||
for e in rotation.groupe_effectif():
|
||||
attendee = vCalAddress("mailto:{emailize(e.nom, prenom=e.prenom)}")
|
||||
attendee = vCalAddress(f"mailto:{emailize(e.nom, prenom=e.prenom)}")
|
||||
attendee.params["cn"] = vText(str(e))
|
||||
attendee.params["role"] = vText("Etudiant")
|
||||
|
||||
|
|
|
@ -25,12 +25,12 @@ SECRET_KEY = 'django-insecure-$)@!wj+$^y1@^tr78ay&)cna10da_k^vncrbo+4ja-qth$8bhz
|
|||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ["127.0.0.1", "colles.mp2i-vms.fr"]
|
||||
ALLOWED_HOSTS = ["127.0.0.1"] # à modifier
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
"http://127.0.0.1:8000",
|
||||
"https://colles.mp2i-vms.fr"
|
||||
]
|
||||
] # à modifier
|
||||
|
||||
CORS_ORIGIN_WHITELIST = [
|
||||
"http://localhost:8000",
|
|
@ -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