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

Show hints in plan and my plan for students

parent 68c2db69
No related branches found
No related tags found
1 merge request!86Merge school-apps
......@@ -279,7 +279,11 @@ table.striped > tbody > tr:nth-child(odd) {
}
}
.alert p, .alert div {
.alert ul, .alert p {
margin: 0;
}
.alert p:first-child, .alert div:first-child {
margin: 10px;
padding: 10px;
border-left: 5px solid;
......@@ -295,13 +299,14 @@ table.striped > tbody > tr:nth-child(odd) {
border-color: #b71c1c;
}
main .alert p, main .alert div {
margin-left: -10px;
margin-right: -10px;
.alert.primary p, .alert.primary div {
background-color: #eca4af;
border-color: #da1f3d;
}
.alert ul {
margin: 0;
main .alert p:first-child, main .alert div:first-child {
margin-left: -10px;
margin-right: -10px;
}
/*++++++++++++++++
......
......@@ -129,7 +129,7 @@
{% if perms.timetable.view_hint %}
<li>
<a href="{% url 'timetable_hints' %}">
<i class="material-icons">notes</i> Hinweismanagement
<i class="material-icons">announcement</i> Hinweismanagement
</a>
</li>
{% endif %}
......
import datetime
from timetable.models import Hint
......@@ -6,9 +8,25 @@ def get_all_hints_by_date(date):
return hints
def get_all_hints_by_class_and_time_period(_class, from_date, to_date):
hints_tmp = get_all_hints_by_time_period(from_date, to_date)
hints_match = []
for hint in hints_tmp:
if _class.id in [x.class_id for x in hint.classes.all()]:
hints_match.append(hint)
return hints_match
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")
week_days = [from_date + datetime.timedelta(days=i) for i in range(5)]
hints = []
for week_day in week_days:
hints_tmp = get_all_hints_by_date(week_day)
for hint in hints_tmp:
if hint not in hints:
hints.append(hint)
print(hints)
return hints
......
{% load martortags %}
{% if hints %}
{% for hint in hints %}
<div class="alert primary">
<div>
<em class="right">Hinweis für {{ hint.from_date|date:"D" }}
{% if hint.from_date != hint.to_date %}
bis {{ hint.to_date|date:"D" }}
{% endif %} </em>
<i class="material-icons left">announcement</i>
{{ hint.text|safe_markdown }}
{# {{ hint }}#}
</div>
</div>
{% endfor %}
{% endif %}
\ No newline at end of file
......@@ -13,6 +13,11 @@
</div>
</div>
<div class="row nomargin">
<div class="col m12 s12 l6">
{% include "timetable/hintsinplan.html" %}
</div>
</div>
<script type="text/javascript">
var dest = "/timetable/my/";
......
......@@ -93,6 +93,9 @@
</a>
{% endif %}
</div>
{% include "timetable/hintsinplan.html" %}
<div class="timetable-plan">
{# Week days #}
......
......@@ -11,7 +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.hints import get_all_hints_by_date, get_all_hints_by_time_period, get_all_hints_by_class_and_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
......@@ -94,7 +94,10 @@ def plan(request, plan_type, plan_id, regular="", year=timezone.datetime.now().y
smart = True
monday_of_week = get_calendar_week(calendar_week, year)["first_day"]
friday = monday_of_week + datetime.timedelta(days=4)
# print(monday_of_week)
hints = None
if plan_type == 'teacher':
_type = TYPE_TEACHER
......@@ -102,6 +105,12 @@ def plan(request, plan_type, plan_id, regular="", year=timezone.datetime.now().y
elif plan_type == 'class':
_type = TYPE_CLASS
el = get_class_by_id(plan_id)
# Get hints
if smart:
hints = list(get_all_hints_by_class_and_time_period(el, monday_of_week, friday))
print(hints)
elif plan_type == 'room':
_type = TYPE_ROOM
el = get_room_by_id(plan_id)
......@@ -111,12 +120,6 @@ 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,
......@@ -128,7 +131,8 @@ def plan(request, plan_type, plan_id, regular="", year=timezone.datetime.now().y
"weeks": get_calendar_weeks(year=year),
"selected_week": calendar_week,
"selected_year": year,
"week_days": WEEK_DAYS
"week_days": WEEK_DAYS,
"hints": hints
}
return render(request, 'timetable/plan.html', context)
......@@ -158,6 +162,7 @@ def my_plan(request, year=None, day=None, month=None):
plan_id = el.id
raw_type = "teacher"
# print(el)
hints = []
elif _type == UserInformation.STUDENT:
_type = TYPE_CLASS
_name = UserInformation.user_classes(request.user)[0]
......@@ -165,6 +170,10 @@ def my_plan(request, year=None, day=None, month=None):
el = get_class_by_name(_name)
plan_id = el.id
raw_type = "class"
# Get hints
hints = list(get_all_hints_by_class_and_time_period(el, date, date))
print(hints)
else:
return redirect("timetable_admin_all")
# print(monday_of_week)
......@@ -183,7 +192,8 @@ def my_plan(request, year=None, day=None, month=None):
"week_days": WEEK_DAYS,
"date": date,
"date_js": int(date.timestamp()) * 1000,
"display_date_only": True
"display_date_only": True,
"hints": hints
}
# print(context["week_day"])
......
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