aboutsummaryrefslogtreecommitdiff
path: root/management/commands/_private.py
diff options
context:
space:
mode:
Diffstat (limited to 'management/commands/_private.py')
-rw-r--r--management/commands/_private.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/management/commands/_private.py b/management/commands/_private.py
index 4dd9262..171b6e9 100644
--- a/management/commands/_private.py
+++ b/management/commands/_private.py
@@ -19,7 +19,7 @@ import re
from bs4 import BeautifulSoup
from django.utils import timezone
-from edt.models import Group, Room, Course
+from edt.models import Course, Group, Room
from edt.utils import get_week
import requests
@@ -30,10 +30,10 @@ def add_time(date, time):
delta = datetime.timedelta(hours=ptime.hour, minutes=ptime.minute)
return date + delta
-def delete_courses_in_week(timetable, year, week, today):
+def delete_courses_in_week(source, year, week, today):
start, end = get_week(year, week)
Course.objects.filter(begin__gte=max(start, today), begin__lt=end,
- timetable=timetable).delete()
+ source=source).delete()
def get_from_db_or_create(cls, **kwargs):
obj = cls.objects.all().filter(**kwargs)
@@ -45,7 +45,7 @@ def get_from_db_or_create(cls, **kwargs):
return obj
-def get_event(timetable, event, event_week, today):
+def get_event(source, event, event_week, today):
"""Renvoie une classe Course à partir d’un événement récupéré par BS4"""
# On récupère la date de l’évènement à partir de la semaine
# et de la semaine référencée, puis l’heure de début et de fin
@@ -58,10 +58,10 @@ def get_event(timetable, event, event_week, today):
return
# Création de l’objet cours
- course = Course.objects.create(timetable=timetable, begin=begin, end=end)
+ course = Course.objects.create(source=source, begin=begin, end=end)
# On récupère les groupes concernés par les cours
- groups = [get_from_db_or_create(Group, timetable=timetable,
+ groups = [get_from_db_or_create(Group, source=source,
celcat_name=item.text)
for item in event.resources.group.find_all("item")]
course.groups.add(*groups)
@@ -96,7 +96,7 @@ def get_event(timetable, event, event_week, today):
return course
-def get_events(timetable, soup, weeks_in_soup, today, year=None, week=None):
+def get_events(source, soup, weeks_in_soup, today, year=None, week=None):
"""Récupère tous les cours disponibles dans l’emploi du temps Celcat.
Le traîtement se limitera à la semaine indiquée si il y en a une."""
for event in soup.find_all("event"):
@@ -110,7 +110,7 @@ def get_events(timetable, soup, weeks_in_soup, today, year=None, week=None):
year is None or week is None) and \
event.resources.group is not None and \
event.starttime is not None and event.endtime is not None:
- course = get_event(timetable, event, event_week, today)
+ course = get_event(source, event, event_week, today)
# On renvoie le cours si il n’est pas nul
if course is not None: