aboutsummaryrefslogtreecommitdiff
path: root/management
diff options
context:
space:
mode:
authorAlban Gruin2017-10-24 19:13:28 +0200
committerAlban Gruin2017-10-24 19:13:28 +0200
commit1edd7f6b2431095b27fd98205bb2ce5f462183e9 (patch)
treeb2fe976b0999dca2aa052e4deda171e826f96035 /management
parent3830f9c786f1a790d67958b0a6d38bea75679159 (diff)
parent07e9a1d1e6c77d64e5c3daf0324ae751117f168e (diff)
Merge branch 'fusion/alban'
Diffstat (limited to 'management')
-rw-r--r--management/commands/_private.py40
-rw-r--r--management/commands/timetables.py1
2 files changed, 1 insertions, 40 deletions
diff --git a/management/commands/_private.py b/management/commands/_private.py
index a9d283d..b663454 100644
--- a/management/commands/_private.py
+++ b/management/commands/_private.py
@@ -30,42 +30,6 @@ def add_time(date, time):
delta = datetime.timedelta(hours=ptime.hour, minutes=ptime.minute)
return date + delta
-def consolidate_group(group):
- group_content_key = ("mention", "subgroup", "td", "tp")
- group_content_list = group.group_info[1:]
-
- if group.subgroup is not None:
- group_content = dict(zip(group_content_key, group_content_list))
-
- for i in range(len(group_content_list))[::-1]:
- del group_content[group_content_key[i]]
- group_content[group_content_key[i] + "__isnull"] = True
-
- if group_content_list[i] is not None:
- break
-
- group.parent = Group.objects.filter(timetable=group.timetable,
- **group_content).first()
- group.save()
-
- if group.tp is None:
- group_content = dict(zip(group_content_key, group_content_list))
- last_is_none = False
-
- for i, key in enumerate(group_content_key):
- if group_content_list[i] is None or last_is_none:
- del group_content[key]
- group_content[key + "__isnull"] = last_is_none
- last_is_none = True
-
- Group.objects.filter(timetable=group.timetable, parent__isnull=True,
- **group_content).update(parent=group)
-
-def consolidate_groups(groups):
- for group in groups:
- if group.parent is None:
- consolidate_group(group)
-
def delete_courses_in_week(timetable, year, week, today):
start, end = get_week(year, week)
Course.objects.filter(begin__gte=max(start, today), begin__lt=end,
@@ -96,12 +60,10 @@ def get_event(timetable, event, event_week, today):
# Création de l’objet cours
course = Course.objects.create(timetable=timetable, begin=begin, end=end)
- # On récupère les groupes concernés par les cours, on les
- # « consolide », puis on les insère dans l’objet cours.
+ # On récupère les groupes concernés par les cours
groups = [get_from_db_or_create(Group, timetable=timetable,
celcat_name=item.text)
for item in event.resources.group.find_all("item")]
- consolidate_groups(groups)
course.groups.add(*groups)
# On récupère le champ « remarque »
diff --git a/management/commands/timetables.py b/management/commands/timetables.py
index 35fb26e..2d8a17e 100644
--- a/management/commands/timetables.py
+++ b/management/commands/timetables.py
@@ -18,7 +18,6 @@ import datetime
from django.core.management.base import BaseCommand
from django.db import transaction
from django.db.models import Min
-from django.utils import timezone
from edt.models import Course, Timetable
from edt.utils import get_week, tz_now