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

Last bugs

parent 03de0329
No related branches found
No related tags found
1 merge request!86Merge school-apps
......@@ -15,7 +15,7 @@
</div>
{# <h5>{{ date|date:"l, j. F Y" }}</h5>#}
<div class="row">
<div class="timetable-plan col s12 m6">
<div class="timetable-plan col s12 m12 l6">
{# Week days #}
<div class="row">
......
{% include 'partials/header.html' %}
<script type="text/javascript">
function updateDatepicker() {
$("#date").val(formatDate(activeDate));
}
function update() {
console.log("Render new.");
updateDatepicker();
}
function loadNew() {
window.location.href = "/timetable/substitutions/" + formatDateForDjango(activeDate);
}
function onDateBeforeClick() {
activeDate.setDate(activeDate.getDate() - 1);
update();
loadNew();
}
function onDateNextClick() {
activeDate.setDate(activeDate.getDate() + 1);
update();
loadNew();
}
function onDateChanged() {
var str = $("#date").val();
var split = str.split(".")
activeDate = new Date(split[2], split[1] - 1, split[0]);
update();
loadNew();
}
var activeDate = new Date({{ date_js }});
$(document).ready(function () {
$("#date-before").click(onDateBeforeClick);
$("#date-next").click(onDateNextClick);
$("#date").change(onDateChanged);
update();
})
<script type="text/javascript">
var dest = "/timetable/substitutions/";
</script>
<main>
......@@ -51,20 +10,7 @@
<div class="row no-print">
<div class="col s12 m6 l4 xl3">
<div class="col s2">
<a class="waves-effect waves-teal btn-flat btn-flat-medium right" id="date-before">
<i class="material-icons center">navigate_before</i>
</a>
</div>
<div class="col s8">
<input type="text" class="datepicker center-align" id="date">
</div>
<div class="col s2">
<a class="waves-effect waves-teal btn-flat btn-flat-medium left" id="date-next">
<i class="material-icons center">navigate_next</i>
</a>
</div>
{% include "timetable/datepicker.html" %}
</div>
<div class="col l4 xl6">
</div>
......
......@@ -85,7 +85,7 @@ def plan(request, plan_type, plan_id, smart="", year=timezone.datetime.now().yea
smart = False
monday_of_week = get_calendar_week(calendar_week, year)["first_day"]
print(monday_of_week)
# print(monday_of_week)
if plan_type == 'teacher':
_type = TYPE_TEACHER
......@@ -136,16 +136,16 @@ def my_plan(request, year=None, day=None, month=None):
shortcode = request.user.username
el = get_teacher_by_shortcode(shortcode)
plan_id = el.id
print(el)
# print(el)
elif _type == UserInformation.STUDENT:
_type = TYPE_CLASS
_name = UserInformation.user_classes(request.user)[0]
print(_name)
# print(_name)
el = get_class_by_name(_name)
plan_id = el.id
else:
redirect("timetable_admin_all")
print(monday_of_week)
# print(monday_of_week)
plan = get_plan(_type, plan_id, smart=True, monday_of_week=monday_of_week)
# print(parse_lesson_times())
......@@ -161,7 +161,7 @@ def my_plan(request, year=None, day=None, month=None):
"date": date,
"date_js": int(date.timestamp()) * 1000
}
print(context["week_day"])
# print(context["week_day"])
return render(request, 'timetable/myplan.html', context)
......
......@@ -86,6 +86,7 @@ def get_teacher_by_id(id):
def get_teacher_by_shortcode(shortcode):
shortcode = shortcode.upper()
teacher = run_one(models.Teacher.objects).get(name__icontains=shortcode)
return one_by_id(teacher, Teacher)
......@@ -131,7 +132,8 @@ def get_class_by_id(id):
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)
......@@ -195,7 +197,7 @@ def get_all_corridors():
def get_corridor_by_id(id):
print(id)
# print(id)
corridor = run_one(models.Corridor.objects, filter_term=False).get(corridor_id=id)
return one_by_id(corridor, Corridor)
......
......@@ -67,16 +67,16 @@ def get_plan(type, id, smart=False, monday_of_week=None):
times_parsed = parse_lesson_times()
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)]
print(week_days)
# print(week_days)
subs_for_weekday = []
for week_day in week_days:
print(week_day)
# print(week_day)
subs = get_substitutions_by_date_as_dict(week_day)
subs_for_weekday.append(subs)
print(subs)
print(len(subs))
# print(subs)
# print(len(subs))
# Init plan array
plan = []
already_added_subs_as_ids = []
......@@ -107,7 +107,7 @@ def get_plan(type, id, smart=False, monday_of_week=None):
for time in lesson.times:
for j, lroom in enumerate(time.rooms):
if lroom.id == id:
print(lroom.name)
# print(lroom.name)
found = True
# 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