diff --git a/schoolapps/timetable/pdf.py b/schoolapps/timetable/pdf.py index 4eeaf655c7f5f104088e713b5998b1cfaf08dcfc..62e4a98c52192ce86fec26548011264d7e253573 100644 --- a/schoolapps/timetable/pdf.py +++ b/schoolapps/timetable/pdf.py @@ -10,7 +10,7 @@ from schoolapps.settings import BASE_DIR # LaTeX constants from untisconnect.sub import get_header_information -DIR = os.path.join(BASE_DIR, "static", "common", "logo.png") +LOGO_FILENAME = os.path.join(BASE_DIR, "static", "common", "logo.png") TEX_HEADER_1 = """\\documentclass[11pt]{article} \\usepackage[ngerman]{babel} \\usepackage[sfdefault]{cabin} @@ -58,7 +58,7 @@ TEX_HEADER_2 = """}} \\rfoot{\\small Umsetzung: © 2018--2019 by Computer-AG} \\begin{document}""" -TEX_HEADER = TEX_HEADER_1 + DIR + TEX_HEADER_2 +TEX_HEADER = TEX_HEADER_1 + LOGO_FILENAME + TEX_HEADER_2 TEX_FOOTER = '\end{document}' @@ -205,6 +205,7 @@ def generate_class_tex(subs, date, header_info): context = { "subs": subs, "date": date, - "header_info": header_info + "header_info": header_info, + "LOGO_FILENAME": LOGO_FILENAME } return render_to_string("timetable/latex/substitutions.tex", context) diff --git a/schoolapps/timetable/templates/timetable/latex/room.tex b/schoolapps/timetable/templates/timetable/latex/room.tex new file mode 100644 index 0000000000000000000000000000000000000000..917f43e79a17ac67d5721e9661fb53c7a382a67b --- /dev/null +++ b/schoolapps/timetable/templates/timetable/latex/room.tex @@ -0,0 +1,13 @@ +{% if sub.sub.type == 3 %} +{{ sub.sub.corridor.name }} +{% elif sub.sub.type == 1 or sub.sub.type == 2 %} +{% elif sub.sub.roow_new and sub.sub.room_old %} +\sout{ {{ sub.sub.room_old.shortcode }} } +$\rightarrow$ +\textbf{ {{ sub.sub.room_new.shortcode }} } +{% elif sub.sub.room_new and not sub.sub.room_old %} +{{ sub.sub.room_new.shortcode }} +{% elif not sub.sub.room_new and not sub.sub.room_old %} +{% else %} +{{ sub.sub.room_old.shortcode }} +{% endif %} \ No newline at end of file diff --git a/schoolapps/timetable/templates/timetable/latex/subject.tex b/schoolapps/timetable/templates/timetable/latex/subject.tex new file mode 100644 index 0000000000000000000000000000000000000000..0a2cca45c8c50c1d0d62353eee429f4496343452 --- /dev/null +++ b/schoolapps/timetable/templates/timetable/latex/subject.tex @@ -0,0 +1,12 @@ +{% if sub.sub.type == 3 %} +\textbf {Aufsicht } +{% elif not sub.sub.subject_new and not sub.sub.subject_old %} +{% elif sub.sub.type == 1 or sub.sub.type == 2 %} +\sout { {{ sub.sub.subject_old.shortcode }} } +{% elif sub.sub.subject_new and sub.sub.subject_old %} +\sout { {{ sub.sub.subject_old.shortcode }} } $\rightarrow$ \textbf { {{ sub.sub.subject_new.shortcode }} } +{% elif sub.sub.subject_new and not sub.sub.subject_old %} +\textbf { {{ sub.sub.subject_new.shortcode }} } +{% else %} +\textbf { {{ sub.sub.subject_old.shortcode }} } +{% endif %} \ No newline at end of file diff --git a/schoolapps/timetable/templates/timetable/latex/substitutions.tex b/schoolapps/timetable/templates/timetable/latex/substitutions.tex index 6e4246cda4f8ec6588dad2d3fa12f2a2ebc43705..051e55789a1c6b47ea33cdc70200a87b7d8e0fd0 100644 --- a/schoolapps/timetable/templates/timetable/latex/substitutions.tex +++ b/schoolapps/timetable/templates/timetable/latex/substitutions.tex @@ -40,7 +40,7 @@ enlarge bottom by=3pt,coltext=white} \pagestyle{fancy} % Left header: logo -%\lhead{\includegraphics[width=5cm]{}} +\lhead{\includegraphics[width=5cm]{% templatetag openbrace %}{{LOGO_FILENAME}}{% templatetag closebrace %}} % Define footer \lfoot{Katharineum zu Lübeck} @@ -114,23 +114,17 @@ Stand: {% now "j. F Y H:i" %}\\ \color{ {{c}} } {{ sub.lesson }} & - \color{ {{c}} } - lehrer & + \color{ {{c}} } {% include "timetable/latex/teacher.tex" %} & - \color{ {{c}} } - fach & + \color{ {{c}} } {% include "timetable/latex/subject.tex" %} & - \color{ {{c}} } - raum & + \color{ {{c}} } {% include "timetable/latex/room.tex" %} & - {# Display badge (for cancellations) #} + {# Display badge (for cancellations) #} {# Display notice and new line #} {% if sub.badge %} \large\badge{ {{ sub.badge }} } - {% endif %} + {% endif %} \color{ {{c}} } \Large\textit{ {{sub.text|default:""}} } \\ - {# Display notice and new line #} - \color{ {{c}} } - \Large\textit{ {{sub.text|default:""}} } \\ {% endwith %} {% endfor %} \end{longtable} diff --git a/schoolapps/timetable/templates/timetable/latex/teacher.tex b/schoolapps/timetable/templates/timetable/latex/teacher.tex new file mode 100644 index 0000000000000000000000000000000000000000..f4a4018d804c6b34a2afc3149cbac451c327fa39 --- /dev/null +++ b/schoolapps/timetable/templates/timetable/latex/teacher.tex @@ -0,0 +1,11 @@ +{% if sub.sub.type == 1 %} +\sout{ {{ sub.sub.teacher_old.shortcode }} } +{% elif sub.sub.teacher_new and sub.sub.teacher_old %} +\sout{ {{ sub.sub.teacher_old.shortcode }} } +$\rightarrow$ +\textbf{ {{ sub.sub.teacher_new.shortcode }} } +{% elif sub.sub.teacher_new and not sub.sub.teacher_old %} +\textbf{ {{ sub.sub.teacher_new.shortcode }} } +{% elif sub.sub.teacher_old %} +\textbf{ {{ sub.sub.teacher_old.shortcode }} } +{% endif %} \ No newline at end of file diff --git a/schoolapps/timetable/views.py b/schoolapps/timetable/views.py index 971456b71cf26cbd4728208860043305d1667faa..73141f4081b9eb5a20fd1383f40448775b3269f5 100755 --- a/schoolapps/timetable/views.py +++ b/schoolapps/timetable/views.py @@ -197,7 +197,7 @@ def sub_pdf(request): today = timezone.datetime.now() first_day = get_next_weekday(today) - second_day = get_next_weekday(today + datetime.timedelta(days=1)) + second_day = get_next_weekday(first_day + datetime.timedelta(days=1)) # Get subs and generate table for i, date in enumerate([first_day, second_day]):