Skip to content
Snippets Groups Projects
Commit a297331e authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Last bugs

parent 21516694
No related branches found
No related tags found
No related merge requests found
...@@ -86,6 +86,7 @@ def get_teacher_by_id(id): ...@@ -86,6 +86,7 @@ def get_teacher_by_id(id):
def get_teacher_by_shortcode(shortcode): def get_teacher_by_shortcode(shortcode):
shortcode = shortcode.upper()
teacher = run_one(models.Teacher.objects).get(name__icontains=shortcode) teacher = run_one(models.Teacher.objects).get(name__icontains=shortcode)
return one_by_id(teacher, Teacher) return one_by_id(teacher, Teacher)
...@@ -131,7 +132,8 @@ def get_class_by_id(id): ...@@ -131,7 +132,8 @@ def get_class_by_id(id):
def get_class_by_name(name): def get_class_by_name(name):
_class = run_one(models.Class.objects).get(name__icontains=name) name = name[0].upper() + name[1:]
_class = run_one(models.Class.objects).filter(name__icontains=name).all()[0]
return one_by_id(_class, Class) return one_by_id(_class, Class)
...@@ -195,7 +197,7 @@ def get_all_corridors(): ...@@ -195,7 +197,7 @@ def get_all_corridors():
def get_corridor_by_id(id): def get_corridor_by_id(id):
print(id) # print(id)
corridor = run_one(models.Corridor.objects, filter_term=False).get(corridor_id=id) corridor = run_one(models.Corridor.objects, filter_term=False).get(corridor_id=id)
return one_by_id(corridor, Corridor) return one_by_id(corridor, Corridor)
......
...@@ -67,16 +67,16 @@ def get_plan(type, id, smart=False, monday_of_week=None): ...@@ -67,16 +67,16 @@ def get_plan(type, id, smart=False, monday_of_week=None):
times_parsed = parse_lesson_times() times_parsed = parse_lesson_times()
if smart: if smart:
print("Get substitutions for smart plan") # print("Get substitutions for smart plan")
week_days = [monday_of_week + datetime.timedelta(days=i) for i in range(5)] week_days = [monday_of_week + datetime.timedelta(days=i) for i in range(5)]
print(week_days) # print(week_days)
subs_for_weekday = [] subs_for_weekday = []
for week_day in week_days: for week_day in week_days:
print(week_day) # print(week_day)
subs = get_substitutions_by_date_as_dict(week_day) subs = get_substitutions_by_date_as_dict(week_day)
subs_for_weekday.append(subs) subs_for_weekday.append(subs)
print(subs) # print(subs)
print(len(subs)) # print(len(subs))
# Init plan array # Init plan array
plan = [] plan = []
already_added_subs_as_ids = [] already_added_subs_as_ids = []
...@@ -107,7 +107,7 @@ def get_plan(type, id, smart=False, monday_of_week=None): ...@@ -107,7 +107,7 @@ def get_plan(type, id, smart=False, monday_of_week=None):
for time in lesson.times: for time in lesson.times:
for j, lroom in enumerate(time.rooms): for j, lroom in enumerate(time.rooms):
if lroom.id == id: if lroom.id == id:
print(lroom.name) # print(lroom.name)
found = True found = True
# If the lesson element is important then add it to plan array # If the lesson element is important then add it to plan array
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment