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

Merge branch 'dev' into feature/dashboard

# Conflicts:
#	schoolapps/dashboard/views.py
#	schoolapps/static/common/style.css
#	schoolapps/templates/partials/footer.html
#	schoolapps/timetable/views.py
parents 2d1bd3bc d963baab
No related branches found
No related tags found
No related merge requests found
# Generated by Django 2.2.1 on 2019-08-18 07:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('timetable', '0009_hint_classes_formatted'),
]
operations = [
migrations.AlterField(
model_name='hintclass',
name='class_id',
field=models.IntegerField(),
),
]
{% load martortags %}
{% if hints %}
\subsection*{Hinweise}
\subsection*{\hspace{0.7em}Hinweise}
\vspace{-0.7em}
\begin{itemize}
\setlength\itemsep{0.1em}
......@@ -12,5 +12,4 @@
{{ hint.text_as_latex|safe }}
{% endfor %}
\end{itemize}
\vspace{-1em}
{% endif %}
\ No newline at end of file
......@@ -5,7 +5,7 @@
\usepackage[ngerman]{babel}
\usepackage[sfdefault]{cabin}
\usepackage[utf8]{inputenc}
\usepackage[a4paper,left=1cm,right=1cm,top=2cm,bottom=2cm,bindingoffset=0mm]{geometry}
\usepackage[a4paper,left=1cm,right=1cm,top=1.5cm,bottom=1.5cm,bindingoffset=0mm]{geometry}
% Packages
\usepackage{fancyhdr}
......@@ -24,12 +24,12 @@
% Badge box
\usepackage{tcolorbox}
\newtcbox{\badge}{nobeforeafter,colframe=green,colback=green,boxrule=0.5pt,arc=4pt,
boxsep=0pt,left=4pt,right=4pt,top=4pt,bottom=4pt,tcbox raise base,
\newtcbox{\badge}{nobeforeafter,colframe=green,colback=green,boxrule=0pt,arc=2pt,
boxsep=0pt,left=4pt,right=4pt,top=2pt,bottom=3pt,tcbox raise base,
grow to left by=0pt,
grow to right by=-3pt,
enlarge top by=3pt,
enlarge bottom by=3pt,coltext=white}
enlarge top by=1pt,
enlarge bottom by=1pt,coltext=white}
% Define colors
\definecolor{grey}{RGB}{208, 208, 208}
......@@ -48,6 +48,7 @@ enlarge bottom by=3pt,coltext=white}
% Define footer
\lfoot{Katharineum zu Lübeck}
\cfoot{}
\rfoot{\small Umsetzung: © 2018--2019 by Computer-AG}
\rhead{\textbf{
Vertretungen {{ date|date:"j. F Y, \\K\\W W"}}}\\
......@@ -63,7 +64,7 @@ Stand: {% now "j. F Y H:i" %}\\
{% include "timetable/latex/hints.tex" %}
{% if header_info.is_box_needed %}
\begin{tabular}{p{0.22\linewidth}p{0.73\linewidth}}
\begin{tabular}{@{\hspace{-1em}}p{0.22\linewidth}p{0.73\linewidth}}
{% for row in header_info.rows %}
\textbf{ {{ row.0 }} } & {{ row.1 }} \\
{% endfor %}
......@@ -74,8 +75,8 @@ Stand: {% now "j. F Y H:i" %}\\
{% set color_background = 1 %}
{% set last_classes = "" %}
\def\arraystretch{1.5}
\begin{longtable}{p{20mm}p{8mm}p{32mm}p{25mm}p{30mm}p{45mm}}
\def\arraystretch{1.1}
\begin{longtable}{p{20mm}p{10mm}p{30mm}p{25mm}p{30mm}p{45mm}}
\textbf{Klassen} &
\textbf{Std.} &
\textbf{Lehrer} &
......@@ -125,7 +126,7 @@ Stand: {% now "j. F Y H:i" %}\\
{# Display badge (for cancellations) #} {# Display notice and new line #}
{% if sub.badge %}
\normalsize\badge{ {{ sub.badge }} }
\footnotesize\badge{ {{ sub.badge }} }
{% endif %} \color{ {{c}}} \large\textit{ {{sub.text|default:""|safe|texify|safe}} } \\
{% endwith %}
......
......@@ -4,17 +4,24 @@
{# Every element of the lesson #}
{% for element_container in col.elements %}
<div style="
{# Display background color only if no badge exists and it is not the old room #}
{# Display background color only if no badge exists and it is not the old room and there are no holidays #}
{% if not element_container.substitution.table.badge %}
{% if not element_container.is_old or type != 1 %}
background-color: {{ element_container.element.subject.hex_color }};
{% if not element_container.is_hol %}
background-color: {{ element_container.element.subject.hex_color }};
{% endif %}
{% endif %}
{% endif %}"
{# Add CSS class for sub when it's a sub #}
class="{% if element_container.substitution %}{% if element_container.substitution.table.is_event %}lesson-with-event{% else %}lesson-with-sub{% endif %}{% endif %}">
<p>
{% if element_container.substitution %}
{% if element_container.is_hol %}
{# <p><strong>{ element_container.element.holiday_reason }}</strong></p>span class="badge new blue darken-2">Schulfrei</span>#}
{% elif element_container.substitution %}
{# SUBSTITUTION #}
{% if type == 1 and element_container.is_old %}
{# When it's the old room, let it empty #}
......
......@@ -34,6 +34,9 @@
<div class="card-content">
<span class="card-title">
{% include "timetable/datepicker.html" %}
{% if holiday %}
<span class="badge new blue center-align holiday-badge">{{ holiday.0 }}</span>
{% endif %}
</span>
</div>
</div>
......
{% include 'partials/header.html' %}
{% load copy_filter %}
<script type="text/javascript">
{% if smart %}
var week = {{ selected_week }};
......@@ -118,7 +119,7 @@
</div>
{% include "timetable/hintsinplan.html" %}
{# show full timetable on tablets, laptops and pcs #}
<div class="timetable-plan hide-on-small-and-down">
......@@ -128,25 +129,31 @@
</div>
{# Show short weekdays on tablets #}
{% for short_week_day in short_week_days %}
{% for day in short_week_days|deepcopy %}
<div class="col s2 hide-on-large-only">
<div class="card timetable-title-card">
<div class="card-content">
<span class="card-title">
{{ short_week_day }}
{{ day.0 }}
</span>
{% if day.1 %}
<span class="badge new blue center-align holiday-badge">{{ day.1.0 }}</span>
{% endif %}
</div>
</div>
</div>
{% endfor %}
{# Show long weekdays elsewere #}
{% for long_week_day in long_week_days %}
{% for day in long_week_days|deepcopy %}
<div class="col s2 hide-on-med-only">
<div class="card timetable-title-card">
<div class="card-content">
<span class="card-title">
{{ long_week_day.0 }}
{{ day.0.0 }}
</span>
{% if day.1 %}
<span class="badge new blue center-align holiday-badge">{{ day.1.0 }}</span>
{% endif %}
</div>
</div>
</div>
......@@ -154,7 +161,7 @@
</div>
{# Lessons #}
{% for row, time in plan %}
{% for row, time in plan|deepcopy %}
<div class="row">
<div class="col s2">
<div class="card timetable-title-card">
......@@ -187,15 +194,15 @@
{# show 5 seperate ones on mobiles #}
<div class="timetable-plan hide-on-med-and-up">
{% for long_week_day in long_week_days %}
{% for day in long_week_days|deepcopy %}
<div class="card timetable-mobile-title-card">
<div class="card-content">
<span class="card-title">
{{ long_week_day.0 }}
{{ day.0.0 }}
</span>
</div>
</div>
{% for row, time in plan %}
{% for row, time in plan|deepcopy %}
<div class="row">
<div class="col s4">
<div class="card timetable-title-card">
......@@ -216,8 +223,8 @@
</div>
</div>
{% for col in row %}
{% if forloop.counter0 == long_week_day.1 %}
{% for col in row|deepcopy %}
{% if forloop.counter0 == day.0.1 %}
<div class="col s8">
{# A lesson #}
{% include "timetable/lesson.html" %}
......
......@@ -52,7 +52,7 @@
<h5 class="hide-on-small-and-down">{{ date|date:"l, j. F Y" }}</h5>
<table class="substitutions striped">
<table class="substitutions striped responsive-table">
<thead>
<tr>
<th><i class="material-icons">people</i></th>
......
......@@ -22,8 +22,8 @@ try:
path('substitutions/', views.substitutions, name='timetable_substitutions'),
path('substitutions/<int:year>/<int:month>/<int:day>/', views.substitutions,
name='timetable_substitutions_date'),
path('class.pdf', views.sub_pdf, name="timetable_substitutions_pdf"),
path('<str:plan_date>-class.pdf', views.sub_pdf, name="timetable_substitutions_pdf_date")
path('aktuell.pdf', views.sub_pdf, name="timetable_substitutions_pdf"),
path('<str:plan_date>-aktuell.pdf', views.sub_pdf, name="timetable_substitutions_pdf_date")
]
except (Terms.DoesNotExist, Schoolyear.DoesNotExist):
......@@ -45,5 +45,5 @@ except (Terms.DoesNotExist, Schoolyear.DoesNotExist):
path('substitutions/', fallback_view.fallback, name='timetable_substitutions'),
path('substitutions/<int:year>/<int:month>/<int:day>/', fallback_view.fallback,
name='timetable_substitutions_date'),
path('class.pdf', fallback_view.fallback, name="timetable_substitutions_pdf")
path('aktuell.pdf', fallback_view.fallback, name="timetable_substitutions_pdf")
]
......@@ -63,7 +63,7 @@ def quicklaunch(request):
@login_required
@permission_required("timetable.show_plan")
def plan(request, plan_type, plan_id, regular="", year=current_year(), calendar_week=current_calendar_week()):
def plan(request, plan_type, plan_id, regular="", year=None, calendar_week=None):
"""
[DJANGO VIEW]
Show a timetable (class, teacher, room, smart/regular)
......@@ -75,6 +75,10 @@ def plan(request, plan_type, plan_id, regular="", year=current_year(), calendar_
:param calendar_week: calendar week in year (only for smart plan)
:return:
"""
if year is None or calendar_week is None:
date = get_next_weekday_with_time(timezone.datetime.now(), timezone.datetime.now().time())
year = date.year
calendar_week = date.isocalendar()[1]
# Regular or smart plan?
if regular == "regular":
......@@ -117,7 +121,7 @@ def plan(request, plan_type, plan_id, regular="", year=current_year(), calendar_
raise Http404('Plan not found.')
# Get plan
plan = get_plan(_type, plan_id, smart=smart, monday_of_week=monday)
plan, holidays = get_plan(_type, plan_id, smart=smart, monday_of_week=monday)
context = {
"smart": smart,
......@@ -130,8 +134,9 @@ def plan(request, plan_type, plan_id, regular="", year=current_year(), calendar_
"weeks": get_calendar_weeks(year=year),
"selected_week": calendar_week,
"selected_year": year,
"short_week_days": SHORT_WEEK_DAYS,
"long_week_days": LONG_WEEK_DAYS,
"short_week_days": zip(SHORT_WEEK_DAYS, holidays),
"long_week_days": zip(LONG_WEEK_DAYS, holidays),
"holidays": holidays,
"hints": hints,
"hints_b": hints_b,
"hints_b_mode": "week",
......@@ -180,7 +185,11 @@ def my_plan(request, year=None, month=None, day=None):
return redirect("timetable_admin_all")
# Get plan
plan = get_plan(_type, plan_id, smart=True, monday_of_week=monday_of_week)
plan, holidays = get_plan(_type, plan_id, smart=True, monday_of_week=monday_of_week)
# print(parse_lesson_times())
holiday_for_the_day = holidays[date.isoweekday() - 1]
# print(holiday_for_the_day)
context = {
"type": _type,
......@@ -193,6 +202,7 @@ def my_plan(request, year=None, month=None, day=None):
"date": date,
"date_js": int(date.timestamp()) * 1000,
"display_date_only": True,
"holiday": holiday_for_the_day,
"hints": hints,
"hints_b": hints_b,
"hints_b_mode": "day",
......@@ -201,6 +211,8 @@ def my_plan(request, year=None, month=None, day=None):
return render(request, 'timetable/myplan.html', context)
#################
# SUBSTITUTIONS #
#################
......@@ -239,18 +251,18 @@ def sub_pdf(request, plan_date=None):
tex = generate_class_tex(sub_table, date, header_info, hints)
# Generate PDF
generate_pdf(tex, "class{}".format(i))
generate_pdf(tex, "aktuell{}".format(i))
# Merge PDFs
try:
merger = PdfFileMerger()
class0 = open(os.path.join(BASE_DIR, "latex", "class0.pdf"), "rb")
class1 = open(os.path.join(BASE_DIR, "latex", "class1.pdf"), "rb")
class0 = open(os.path.join(BASE_DIR, "latex", "aktuell0.pdf"), "rb")
class1 = open(os.path.join(BASE_DIR, "latex", "aktuell1.pdf"), "rb")
merger.append(fileobj=class0)
merger.append(fileobj=class1)
# Write merged PDF to class.pdf
output = open(os.path.join(BASE_DIR, "latex", "class.pdf"), "wb")
# Write merged PDF to aktuell.pdf
output = open(os.path.join(BASE_DIR, "latex", "aktuell.pdf"), "wb")
merger.write(output)
output.close()
......@@ -261,7 +273,7 @@ def sub_pdf(request, plan_date=None):
register_traceback("merge_class", "pypdf2")
# Read and response PDF
file = open(os.path.join(BASE_DIR, "latex", "class.pdf"), "rb")
file = open(os.path.join(BASE_DIR, "latex", "aktuell.pdf"), "rb")
return FileResponse(file, content_type="application/pdf")
......
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