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

Working plan with bugs

parent 90e9a906
No related branches found
No related tags found
No related merge requests found
...@@ -134,21 +134,56 @@ ...@@ -134,21 +134,56 @@
<div class="card lesson-card"> <div class="card lesson-card">
<div class="card-content"> <div class="card-content">
{% for element_container in col.elements %} {% for element_container in col.elements %}
<div style="background-color: {{ element_container.element.subject.hex_color }};"> <div style="
{% if not element_container.substitution.table.badge %}
{% if not element_container.is_old or type != 1 %}
background-color: {{ element_container.element.subject.hex_color }};
{% endif %}
{% endif %}"
class="{% if element_container.substitution %}lesson-with-sub{% endif %}">
<p> <p>
{% if type == 0 or type == 1 %} {% if element_container.substitution %}
{% for class in element_container.element.classes %} {% if type == 1 and element_container.is_old %}
{{ class.name }}
{% endfor %} {% elif element_container.substitution.table.badge %}
{% endif %} <span class="badge new green darken-2">{{ element_container.substitution.table.badge }}</span>
{% if type == 2 or type == 1 %} {% else %}
<span data-position="bottom" class="tooltipped" {% if type == 0 or type == 1 %}
data-tooltip="{{ element_container.element.teacher }}">{{ element_container.element.teacher.shortcode }}</span> {{ element_container.substitution.table.classes }}
{% endif %} {% endif %}
<strong>{{ element_container.element.subject.shortcode }}</strong>
{% if type == 0 or type == 2 %} <span class="tooltipped" data-position="bottom"
<span class="tooltipped" data-position="bottom" data-tooltip="{{ element_container.substitution.table.teacher_full|safe }}">{{ element_container.substitution.table.teacher|safe }}</span>
data-tooltip="{{ element_container.room.name }}">{{ element_container.room.shortcode }}</span>
{{ element_container.substitution.table.subject|safe }}
{% if type == 0 or type == 2 %}
<span class="tooltipped" data-position="bottom"
data-tooltip="{{ element_container.substitution.table.room_full|safe }}">{{ element_container.substitution.table.room|safe }}</span>
{% endif %}
{% endif %}<br>
{% if not type == 1 and not element_container.is_old %}
<small>
<em>{{ element_container.substitution.table.text|default:"" }}</em>
</small>
{% endif %}
{% else %}
{% if type == 0 or type == 1 %}
{% for class in element_container.element.classes %}
{{ class.name }}
{% endfor %}
{% endif %}
{% if type == 2 or type == 1 %}
<span data-position="bottom" class="tooltipped"
data-tooltip="{{ element_container.element.teacher }}">{{ element_container.element.teacher.shortcode }}</span>
{% endif %}
<strong>{{ element_container.element.subject.shortcode }}</strong>
{% if type == 0 or type == 2 %}
<span class="tooltipped" data-position="bottom"
data-tooltip="{{ element_container.room.name }}">{{ element_container.room.shortcode }}</span>
{% endif %}
{% endif %} {% endif %}
</p> </p>
</div> </div>
......
...@@ -7,15 +7,10 @@ from django.shortcuts import render ...@@ -7,15 +7,10 @@ from django.shortcuts import render
from django.utils import timezone from django.utils import timezone
from timetable.pdf import generate_class_tex, generate_pdf from timetable.pdf import generate_class_tex, generate_pdf
from schoolapps.settings import LESSONS
from untisconnect.parse import * from untisconnect.plan import get_plan, TYPE_TEACHER, TYPE_CLASS, TYPE_ROOM, parse_lesson_times
from untisconnect.sub import get_substitutions_by_date, date_to_untis_date, untis_date_to_date, generate_sub_table from untisconnect.sub import get_substitutions_by_date, generate_sub_table
from untisconnect.api import *
try:
from schoolapps.untisconnect.api import *
except Exception:
pass
def get_all_context(): def get_all_context():
...@@ -46,11 +41,11 @@ def quicklaunch(request): ...@@ -46,11 +41,11 @@ def quicklaunch(request):
return render(request, 'timetable/quicklaunch.html', context) return render(request, 'timetable/quicklaunch.html', context)
def get_calendar_weeks(): def get_calendar_weeks(year=timezone.datetime.now().year):
weeks = [] weeks = []
# Get first day of year > first calendar week # Get first day of year > first calendar week
first_day_of_year = timezone.datetime(year=timezone.datetime.now().year, month=1, day=1) first_day_of_year = timezone.datetime(year=year, month=1, day=1)
if first_day_of_year.isoweekday() != 1: if first_day_of_year.isoweekday() != 1:
days_to_next_monday = 1 - first_day_of_year.isoweekday() days_to_next_monday = 1 - first_day_of_year.isoweekday()
first_day_of_year += datetime.timedelta(days=days_to_next_monday) first_day_of_year += datetime.timedelta(days=days_to_next_monday)
...@@ -70,17 +65,26 @@ def get_calendar_weeks(): ...@@ -70,17 +65,26 @@ def get_calendar_weeks():
return weeks return weeks
def get_calendar_week(calendar_week, year=timezone.datetime.now().year):
weeks = get_calendar_weeks(year=year)
for week in weeks:
if week["calendar_week"] == calendar_week:
return week
return None
@login_required @login_required
@permission_required("timetable.show_plan") @permission_required("timetable.show_plan")
def plan(request, plan_type, plan_id, smart="", year=None, calendar_week=None): def plan(request, plan_type, plan_id, smart="", year=timezone.datetime.now().year,
calendar_week=timezone.datetime.now().isocalendar()[1]):
if smart == "smart": if smart == "smart":
smart = True smart = True
year = timezone.datetime.now().year if year is None else year
calendar_week = timezone.datetime.now().isocalendar()[1] if calendar_week is None else calendar_week
print(get_calendar_weeks())
else: else:
smart = False smart = False
monday_of_week = get_calendar_week(calendar_week, year)["first_day"]
print(monday_of_week)
if plan_type == 'teacher': if plan_type == 'teacher':
_type = TYPE_TEACHER _type = TYPE_TEACHER
el = get_teacher_by_id(plan_id) el = get_teacher_by_id(plan_id)
...@@ -93,8 +97,8 @@ def plan(request, plan_type, plan_id, smart="", year=None, calendar_week=None): ...@@ -93,8 +97,8 @@ def plan(request, plan_type, plan_id, smart="", year=None, calendar_week=None):
else: else:
raise Http404('Plan not found.') raise Http404('Plan not found.')
plan = get_plan(_type, plan_id) plan = get_plan(_type, plan_id, smart=smart, monday_of_week=monday_of_week)
print(parse_lesson_times()) # print(parse_lesson_times())
context = { context = {
"smart": smart, "smart": smart,
...@@ -104,7 +108,7 @@ def plan(request, plan_type, plan_id, smart="", year=None, calendar_week=None): ...@@ -104,7 +108,7 @@ def plan(request, plan_type, plan_id, smart="", year=None, calendar_week=None):
"plan": plan, "plan": plan,
"el": el, "el": el,
"times": parse_lesson_times(), "times": parse_lesson_times(),
"weeks": get_calendar_weeks(), "weeks": get_calendar_weeks(year=year),
"selected_week": calendar_week, "selected_week": calendar_week,
"selected_year": year "selected_year": year
} }
......
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