diff --git a/schoolapps/timetable/hints.py b/schoolapps/timetable/hints.py new file mode 100644 index 0000000000000000000000000000000000000000..839006fd249c9acb102498f15410c32968255818 --- /dev/null +++ b/schoolapps/timetable/hints.py @@ -0,0 +1,18 @@ +from timetable.models import Hint + + +def get_all_hints_by_date(date): + hints = filter_date(date) + return hints + + +def get_all_hints_by_time_period(from_date, to_date): + print(from_date, to_date) + hints = Hint.objects.filter(from_date__gte=from_date, to_date__lte=to_date).order_by("from_date", "classes") + print(hints) + return hints + + +def filter_date(date): + hints = Hint.objects.filter(from_date__lte=date, to_date__gte=date).order_by("from_date", "classes") + return hints diff --git a/schoolapps/timetable/views.py b/schoolapps/timetable/views.py index 138079ae2046e658b215ad90c6c91f557c6eac88..5fb9c75cf2b6ec026100c3a60ce132deb0fc911f 100755 --- a/schoolapps/timetable/views.py +++ b/schoolapps/timetable/views.py @@ -11,6 +11,7 @@ from material import Fieldset, Row from schoolapps.settings import WEEK_DAYS from timetable.filters import HintFilter from timetable.forms import HintForm +from timetable.hints import get_all_hints_by_date, get_all_hints_by_time_period from timetable.pdf import generate_class_tex, generate_pdf from untisconnect.plan import get_plan, TYPE_TEACHER, TYPE_CLASS, TYPE_ROOM, parse_lesson_times @@ -110,6 +111,12 @@ def plan(request, plan_type, plan_id, regular="", year=timezone.datetime.now().y plan = get_plan(_type, plan_id, smart=smart, monday_of_week=monday_of_week) # print(parse_lesson_times()) + # Get hints + if smart: + friday = monday_of_week + datetime.timedelta(days=4) + hints = list(get_all_hints_by_time_period(monday_of_week, friday)) + print(hints) + context = { "smart": smart, "type": _type,