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

- Remove datepicker at "My Plan", move next/back buttons to card header

- Skip saturday and sunday in Smart Plan (issue #124)
- Remove link "Alle Pläne" (issue #114)
- Refactoring (remove prints)
parent 294a5323
No related branches found
No related tags found
1 merge request!86Merge school-apps
......@@ -30,7 +30,7 @@ def upload(request):
@login_required
@permission_required("menu.add_menu")
def delete(request, id):
print(id)
# print(id)
Menu.objects.get(id=id).delete()
return redirect("menu_index_msg", msg="delete_success")
......
......@@ -117,14 +117,14 @@
<span class="badge new primary-color ">SMART PLAN</span>
</a>
</li>
<li>
<a href="{% url 'timetable_admin_all' %}">
<i class="material-icons">grid_on</i> Alle Pläne
</a>
</li>
{# <li>#}
{# <a href="{% url 'timetable_admin_all' %}">#}
{# <i class="material-icons">grid_on</i> Alle Pläne#}
{# </a>#}
{# </li>#}
<li>
<a href="{% url 'timetable_quicklaunch' %}">
<i class="material-icons">directions</i> Schnellzugriff
<i class="material-icons">grid_on</i> Alle Pläne
</a>
</li>
<li>
......
......@@ -173,7 +173,7 @@ def generate_class_tex(subs, date, header_info):
color = "\color{%s}" % sub.color
# Print classes
print(sub.classes)
# print(sub.classes)
tex_body += color
tex_body += '\\textbf{' + sub.classes + '} & '
......
<script type="text/javascript">
function updateDatepicker() {
$("#date").val(formatDate(activeDate));
{% if not display_date_only %}
$("#date").val(formatDate(activeDate));
{% endif %}
}
function update() {
......@@ -14,13 +16,23 @@
}
function onDateBeforeClick() {
activeDate.setDate(activeDate.getDate() - 1);
if (activeDate.getDay() === 1) {
var minus = 3;
} else {
var minus = 1;
}
activeDate.setDate(activeDate.getDate() - minus);
update();
loadNew();
}
function onDateNextClick() {
activeDate.setDate(activeDate.getDate() + 1);
if (activeDate.getDay() === 5) {
var plus = 3;
} else {
var plus = 1;
}
activeDate.setDate(activeDate.getDate() + plus);
update();
loadNew();
}
......@@ -46,16 +58,24 @@
<div class="col s2">
<a class="waves-effect waves-teal btn-flat btn-flat-medium right" id="date-before">
<a class="waves-effect waves-teal btn-flat btn-flat-medium left" 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">
{% if display_date_only %}
<div class="col s8">
<span class="card-title center-block" id="date">
{{ date|date:"l, j.n.Y" }}
</span>
</div>
{% else %}
<div class="col s8">
<input type="text" class="datepicker center-align" id="date">
</div>
{% endif %}
<div class="col s2" style="display: initial;">
<a class="waves-effect waves-teal btn-flat btn-flat-medium right" id="date-next">
<i class="material-icons center">navigate_next</i>
</a>
</div>
......
......@@ -16,11 +16,7 @@
<script type="text/javascript">
var dest = "/timetable/my/";
</script>
<div class="row">
<div class="col s12 m6">
{% include "timetable/datepicker.html" %}
</div>
</div>
<div class="row">
<div class="timetable-plan col s12 m12 l6">
......@@ -31,7 +27,7 @@
<div class="card timetable-title-card">
<div class="card-content">
<span class="card-title">
{{ date|date:"l, j.n.Y" }}
{% include "timetable/datepicker.html" %}
</span>
</div>
</div>
......
from django.test import TestCase
# Create your tests here.
......@@ -127,6 +127,12 @@ def my_plan(request, year=None, day=None, month=None):
date = timezone.datetime.now()
if year is not None and day is not None and month is not None:
date = timezone.datetime(year=year, month=month, day=day)
next_weekday = get_next_weekday(date)
if next_weekday != date:
print("Hi")
return redirect("timetable_my_plan", next_weekday.year, next_weekday.month, next_weekday.day)
print(date)
print(get_next_weekday(date))
calendar_week = date.isocalendar()[1]
monday_of_week = get_calendar_week(calendar_week, date.year)["first_day"]
......@@ -161,7 +167,8 @@ def my_plan(request, year=None, day=None, month=None):
"week_day": date.isoweekday() - 1,
"week_days": WEEK_DAYS,
"date": date,
"date_js": int(date.timestamp()) * 1000
"date_js": int(date.timestamp()) * 1000,
"display_date_only": True
}
# print(context["week_day"])
......@@ -191,7 +198,7 @@ def sub_pdf(request):
subs = get_substitutions_by_date(first_day)
sub_table = generate_sub_table(subs)
header_info = get_header_information(subs)
print(header_info.affected_teachers)
# print(header_info.affected_teachers)
# Generate LaTeX
tex = generate_class_tex(sub_table, first_day, header_info)
......
......@@ -189,8 +189,8 @@ def get_lesson_element_by_id_and_teacher(lesson_id, teacher, hour=None, weekday=
# print(t)
room = None
if t is not None and len(t.rooms) > i:
print(t.rooms)
print(len(t.rooms))
# print(t.rooms)
# print(len(t.rooms))
room = t.rooms[i]
if el is not None:
......
......@@ -159,7 +159,7 @@ class SubRow(object):
def generate_teacher_row(sub, full=False):
print(sub.id)
# print(sub.id)
teacher = ""
if sub.type == 1:
teacher = "<s>{}</s>".format(sub.teacher_old.shortcode if not full else sub.teacher_old.name)
......@@ -179,6 +179,8 @@ def generate_teacher_row(sub, full=False):
def generate_subject_row(sub, full=False):
if sub.type == 3:
subject = "Aufsicht"
elif not sub.subject_new and not sub.subject_old:
subject = ""
elif sub.type == 1 or sub.type == 2:
subject = "<s>{}</s>".format(sub.subject_old.shortcode if not full else sub.subject_old.name)
elif sub.subject_new and sub.subject_old:
......@@ -187,8 +189,6 @@ def generate_subject_row(sub, full=False):
sub.subject_new.shortcode if not full else sub.subject_new.name)
elif sub.subject_new and not sub.subject_old:
subject = "<strong>{}</strong>".format(sub.subject_new.shortcode if not full else sub.subject_new.name)
elif not sub.subject_new and not sub.subject_old:
subject = ""
else:
subject = "<strong>{}</strong>".format(sub.subject_old.shortcode if not full else sub.subject_old.name)
......@@ -284,7 +284,7 @@ def get_header_information(subs):
info.affected_teachers.append(sub.teacher_old)
if sub.teacher_new and sub.teacher_new not in info.affected_teachers:
info.affected_teachers.append(sub.teacher_new)
print(sub.teacher_old)
# print(sub.teacher_old)
for _class in sub.classes:
if _class not in info.affected_classes:
......@@ -292,7 +292,7 @@ def get_header_information(subs):
if info.affected_teachers:
joined = ", ".join(sorted([x.shortcode for x in info.affected_teachers]))
print(joined)
# print(joined)
info.rows.append(("Betroffene Lehrkräfte", joined))
if info.affected_classes:
......@@ -321,14 +321,14 @@ def get_substitutions_by_date(date):
def get_substitutions_by_date_as_dict(date):
subs_raw = get_substitutions_by_date(date)
sub_table = generate_sub_table(subs_raw)
print("SUB RAW LEN", len(sub_table))
# print("SUB RAW LEN", len(sub_table))
subs = {}
for i, sub_raw in enumerate(subs_raw):
print(i)
# print(i)
if sub_raw.lesson_id not in subs.keys():
subs[sub_raw.lesson_id] = []
subs[sub_raw.lesson_id].append({"sub": sub_raw, "table": sub_table[i]})
# print(sub_raw.teacher_old)
# print(sub_table[i].teacher)
print(len(subs))
# print(len(subs))
return subs
......@@ -15,7 +15,7 @@ class UserInformation:
def user_groups(user):
raw_groups = user.groups.all()
groups = [group.name for group in raw_groups]
print(groups)
# print(groups)
return groups
@staticmethod
......
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