From 0f014e1c2fbaeaad628472ad38eac7d29029ace0 Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Fri, 10 Jan 2020 11:15:28 +0100 Subject: [PATCH] Remove old and unnecessary stuff (e. g. LaTeX stuff) --- aleksis/apps/chronos/fallback_view.py | 7 --- aleksis/apps/chronos/forms.py | 34 +--------- aleksis/apps/chronos/m2l.py | 45 ------------- aleksis/apps/chronos/pdf.py | 52 --------------- .../chronos/templates/chronos/fallback.html | 6 -- .../templates/chronos/latex/header.tex | 63 ------------------- .../chronos/templates/chronos/latex/hints.tex | 15 ----- .../chronos/templates/chronos/latex/room.tex | 15 ----- .../templates/chronos/latex/subject.tex | 14 ----- .../templates/chronos/latex/substitutions.tex | 50 --------------- .../templates/chronos/latex/teacher.tex | 13 ---- aleksis/apps/chronos/views.py | 2 +- 12 files changed, 3 insertions(+), 313 deletions(-) delete mode 100644 aleksis/apps/chronos/fallback_view.py delete mode 100644 aleksis/apps/chronos/m2l.py delete mode 100644 aleksis/apps/chronos/pdf.py delete mode 100644 aleksis/apps/chronos/templates/chronos/fallback.html delete mode 100644 aleksis/apps/chronos/templates/chronos/latex/header.tex delete mode 100644 aleksis/apps/chronos/templates/chronos/latex/hints.tex delete mode 100644 aleksis/apps/chronos/templates/chronos/latex/room.tex delete mode 100644 aleksis/apps/chronos/templates/chronos/latex/subject.tex delete mode 100644 aleksis/apps/chronos/templates/chronos/latex/substitutions.tex delete mode 100644 aleksis/apps/chronos/templates/chronos/latex/teacher.tex diff --git a/aleksis/apps/chronos/fallback_view.py b/aleksis/apps/chronos/fallback_view.py deleted file mode 100644 index 50103287..00000000 --- a/aleksis/apps/chronos/fallback_view.py +++ /dev/null @@ -1,7 +0,0 @@ -from django.contrib.auth.decorators import login_required -from django.shortcuts import render - - -@login_required -def fallback(request, *args, **kwargs): - return render(request, "timetable/fallback.html") diff --git a/aleksis/apps/chronos/forms.py b/aleksis/apps/chronos/forms.py index 871ec7dc..d519ba6c 100644 --- a/aleksis/apps/chronos/forms.py +++ b/aleksis/apps/chronos/forms.py @@ -1,37 +1,7 @@ from django import forms -from django.db.models import Count -from django.utils.translation import ugettext_lazy as _ +from django_select2.forms import ModelSelect2MultipleWidget -from django_select2.forms import ModelSelect2MultipleWidget, Select2Widget - -from aleksis.core.models import Group, Person - -from .models import LessonPeriod, LessonSubstitution, Room, Subject - - -class SelectForm(forms.Form): - group = forms.ModelChoiceField( - queryset=Group.objects.annotate(lessons_count=Count("lessons")).filter(lessons_count__gt=0), - label=_("Group"), - required=False, - widget=Select2Widget, - ) - teacher = forms.ModelChoiceField( - queryset=Person.objects.annotate(lessons_count=Count("lessons_as_teacher")).filter( - lessons_count__gt=0 - ), - label=_("Teacher"), - required=False, - widget=Select2Widget, - ) - room = forms.ModelChoiceField( - queryset=Room.objects.annotate(lessons_count=Count("lesson_periods")).filter( - lessons_count__gt=0 - ), - label=_("Room"), - required=False, - widget=Select2Widget, - ) +from .models import LessonSubstitution class LessonSubstitutionForm(forms.ModelForm): diff --git a/aleksis/apps/chronos/m2l.py b/aleksis/apps/chronos/m2l.py deleted file mode 100644 index 75457806..00000000 --- a/aleksis/apps/chronos/m2l.py +++ /dev/null @@ -1,45 +0,0 @@ -import os -import subprocess - -from debug.models import register_log_with_filename -from aleksis.settings import BASE_DIR - - -# from .models import register_log_with_filename - - -def convert_markdown_2_latex(s): - try: - # Write markdown file - md_file = open(os.path.join(BASE_DIR, "latex", "m2l.md"), "w", encoding="utf8") - md_file.write(s) - md_file.close() - - # Execute pandoc to convert markdown to latex - bash_command = "pandoc --log={} --from markdown --to latex --output {} {}".format( - os.path.join(BASE_DIR, "latex", "m2l.log"), - os.path.join(BASE_DIR, "latex", "m2l.tex"), - os.path.join(BASE_DIR, "latex", "m2l.md")) - process = subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE) - output = process.communicate()[0] - del output - - # Register log file in debugging tool - register_log_with_filename("m2l", "m2l", "m2l.log", process.returncode) - - # Read converted latex from file - tex_file = open(os.path.join(BASE_DIR, "latex", "m2l.tex"), "r", encoding="utf8") - r = tex_file.read() - tex_file.close() - - # Replace some things - r = r.replace("\subparagraph", "\subsubsection") - r = r.replace("\paragraph", "\subsubsection") - r = r.replace("section", "section*") - - # Return latex - return r - except Exception as e: - # Print error - print("[MD TO LATEX]", e) - return "" diff --git a/aleksis/apps/chronos/pdf.py b/aleksis/apps/chronos/pdf.py deleted file mode 100644 index 16814fcf..00000000 --- a/aleksis/apps/chronos/pdf.py +++ /dev/null @@ -1,52 +0,0 @@ -import os -import subprocess - -from django.template.loader import render_to_string - -from aleksis.settings import BASE_DIR -from debug.models import register_log_with_filename - -LOGO_FILENAME = os.path.join(BASE_DIR, "static", "common", "logo.png") - - -def generate_pdf(tex, filename): - """Generate a PDF by LaTeX code""" - - # Write LaTeX file - tex_file = open(os.path.join(BASE_DIR, "latex", filename + ".tex"), "w", encoding="utf8") - tex_file.write(tex) - tex_file.close() - - # Execute pdflatex to generate the PDF - bash_command = "pdflatex -halt-on-error -output-directory {} {}.tex".format(os.path.join(BASE_DIR, "latex"), - os.path.join(BASE_DIR, "latex", - filename)) - run_args = list(bash_command.split()) - - # Execute two times to get number of last page - subprocess.run(run_args, stdout=None) - process = subprocess.run(run_args, stdout=None) - - # Register log file in debugging tool - register_log_with_filename("latex_{}".format(filename), "latex", "{}.log".format(filename), process.returncode) - -def generate_class_tex_header(): - """Generate LaTeX for a PDF by a substitution table""" - - context = { - "LOGO_FILENAME": LOGO_FILENAME, - } - return render_to_string("timetable/latex/header.tex", context) - - -def generate_class_tex_body(subs, date, header_info, hints=None): - """Generate LaTeX for a PDF by a substitution table""" - - context = { - "subs": subs, - "date": date, - "header_info": header_info, - "LOGO_FILENAME": LOGO_FILENAME, - "hints": hints - } - return render_to_string("timetable/latex/substitutions.tex", context) diff --git a/aleksis/apps/chronos/templates/chronos/fallback.html b/aleksis/apps/chronos/templates/chronos/fallback.html deleted file mode 100644 index b0fb65a2..00000000 --- a/aleksis/apps/chronos/templates/chronos/fallback.html +++ /dev/null @@ -1,6 +0,0 @@ -{% extends 'core/base.html' %} - -{% block content %} - <h3>{% blocktrans %}The timetables are currently unavailable.{% endblocktrans %}</h3> - -{% endblock %} diff --git a/aleksis/apps/chronos/templates/chronos/latex/header.tex b/aleksis/apps/chronos/templates/chronos/latex/header.tex deleted file mode 100644 index 1f80f970..00000000 --- a/aleksis/apps/chronos/templates/chronos/latex/header.tex +++ /dev/null @@ -1,63 +0,0 @@ -\documentclass[11pt]{article} -\usepackage[ngerman]{babel} -\usepackage[sfdefault]{cabin} -\usepackage[utf8]{inputenc} -\usepackage[a4paper,left=1cm,right=1cm,top=2cm,bottom=2.8cm,bindingoffset=0mm]{geometry} - -% Packages -\usepackage{fancyhdr} -\usepackage{lastpage} -\usepackage{graphicx} -\usepackage{longtable} -\usepackage{booktabs} -\usepackage{multirow} -\usepackage{color, colortbl} -\usepackage[colorlinks, linkcolor = black, citecolor = black, filecolor = black, urlcolor = black]{hyperref} - -\usepackage{ulem, xpatch} -\xpatchcmd{\sout} -{\bgroup} -{\bgroup\def\ULthickness{1.5pt}} -{}{} - -% 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, -grow to left by=0pt, -grow to right by=-3pt, -enlarge top by=3pt, -enlarge bottom by=3pt,coltext=white} - -% Define colors -\definecolor{ grey }{RGB}{208, 208, 208} -\definecolor{ darkgrey }{rgb}{0.6,0.6,0.6} -\definecolor{ white }{rgb}{1,1,1} -\definecolor{ green }{RGB}{76,175,80} -\definecolor{green}{RGB}{76,175,80} -\definecolor{ blue }{RGB}{41,7,249} -\definecolor{ black }{RGB}{0,0,0} -\definecolor{ purple }{RGB}{156, 39, 176} - -% Define header -\pagestyle{fancy} - -% Left header: logo -\lhead{\includegraphics[width=5cm]{% templatetag openbrace %}{{LOGO_FILENAME}}{% templatetag closebrace %}} - -% Define footer -\lfoot{Katharineum zu Lübeck} -\cfoot{\thepage}%\ von \pageref{LastPage}} -\rfoot{\small Umsetzung: © 2018--2019 by Computer-AG} -\rhead{\textbf{ -Vertretungen }\\ -Stand: {% now "j. F Y H:i" %}\\ -} - -% Define own commands -%% tightlist from pandoc is missing in default.latex -%% see https://tex.stackexchange.com/questions/257418/error-tightlist-converting-md-file-into-pdf-using-pandoc -\providecommand{\tightlist}{% - \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} - -\begin{document} diff --git a/aleksis/apps/chronos/templates/chronos/latex/hints.tex b/aleksis/apps/chronos/templates/chronos/latex/hints.tex deleted file mode 100644 index 6077fd4a..00000000 --- a/aleksis/apps/chronos/templates/chronos/latex/hints.tex +++ /dev/null @@ -1,15 +0,0 @@ -{% load martortags %} -{% if hints %} -\subsection*{\hspace{0.7em}Hinweise} -\vspace{-0.7em} -\begin{itemize} - \setlength\itemsep{0.1em} - {% for hint in hints %} - \normalsize - \item \small - {{ hint.classes_formatted }}{% if hint.teachers and hint.classes.all %}, {% endif %}{% if hint.teachers %}Lehrkräfte{% endif %}: - \normalsize -{{ hint.text_as_latex|safe }} -{% endfor %} -\end{itemize} -{% endif %} diff --git a/aleksis/apps/chronos/templates/chronos/latex/room.tex b/aleksis/apps/chronos/templates/chronos/latex/room.tex deleted file mode 100644 index 7b9b5678..00000000 --- a/aleksis/apps/chronos/templates/chronos/latex/room.tex +++ /dev/null @@ -1,15 +0,0 @@ -{% if not sub.is_event %}{% if sub.sub.type == 3 %} -{{ sub.sub.corridor.name }} -{% elif sub.sub.type == 1 or sub.sub.type == 2 %} -{% elif sub.sub.room_new and sub.sub.room_old %} -\sout{% templatetag openbrace %}{{ sub.sub.room_old.shortcode }}} -$\rightarrow$ -{{ 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 %}{% else %} -{% for room in sub.rooms %}{{ room.shortcode }}{% if not forloop.last %}, {% endif %}{% endfor %} -{% endif %} diff --git a/aleksis/apps/chronos/templates/chronos/latex/subject.tex b/aleksis/apps/chronos/templates/chronos/latex/subject.tex deleted file mode 100644 index 96b9d061..00000000 --- a/aleksis/apps/chronos/templates/chronos/latex/subject.tex +++ /dev/null @@ -1,14 +0,0 @@ -{% if sub.is_event %} -Veranstaltung -{% elif sub.sub.type == 3 %} -Aufsicht -{% elif not sub.sub.subject_new and not sub.sub.subject_old %} -{% elif sub.sub.type == 1 or sub.sub.type == 2 %} -\sout{% templatetag openbrace %}{{ sub.sub.subject_old.shortcode }}} -{% elif sub.sub.subject_new and sub.sub.subject_old %} -\sout{% templatetag openbrace %}{{ sub.sub.subject_old.shortcode }}} $\rightarrow$ \textbf { {{ sub.sub.subject_new.shortcode }} } -{% elif sub.sub.subject_new and not sub.sub.subject_old %} -{{ sub.sub.subject_new.shortcode }} -{% else %} -{{ sub.sub.subject_old.shortcode }} -{% endif %} diff --git a/aleksis/apps/chronos/templates/chronos/latex/substitutions.tex b/aleksis/apps/chronos/templates/chronos/latex/substitutions.tex deleted file mode 100644 index 2b3d21e3..00000000 --- a/aleksis/apps/chronos/templates/chronos/latex/substitutions.tex +++ /dev/null @@ -1,50 +0,0 @@ -{% load common %} -{% load tex %} - -\large -\subsubsection*{} - -\section*{\Huge Vertretungen {{ date|date:"l, j. F Y"}}} - -{% include "timetable/latex/hints.tex" %} - -{% if header_info.is_box_needed %} -\begin{tabular}{@{\hspace{-1em}}p{0.22\linewidth}p{0.73\linewidth}} -{% for row in header_info.rows %} - \textbf{ {{ row.0 }} } & {{ row.1 }} \\ -{% endfor %} -\end{tabular} -{% endif %} - -% Init table -{% set color_background = 1 %} -{% set last_classes = "" %} - -\def\arraystretch{1.1} -\begin{longtable}{p{20mm}p{10mm}p{30mm}p{25mm}p{30mm}p{45mm}} - \textbf{Klassen} & \textbf{Std.} & \textbf{Lehrer} & \textbf{Fach} & \textbf{Raum} & \textbf{Hinweis}\\\hline - \endhead - {% for sub in subs %} - {# Color groups of classes in grey/white #} - {% if last_classes != sub.classes %} - {% if color_background %}{% set color_background = 0 %} - {% else %}{% set color_background = 1 %} - {% endif %} - {% endif %} - {% set last_classes = sub.classes %} - {# Background color #} - {% if color_background %}\rowcolor{ grey }{% endif %} - {% with c=sub.color %} - {# Display classes #} - \color{ {{c}} }\textbf{ {{ sub.classes }} } & - {# Display lesson number #} - \color{ {{c}} } {{ sub.lesson }} & - \color{ {{c}} } {% include "timetable/latex/teacher.tex" %} & - \color{ {{c}} } {% include "timetable/latex/subject.tex" %} & - \color{ {{c}} } {% include "timetable/latex/room.tex" %} & - {# Display badge (for cancellations) #} {# Display notice and new line #} - {% if sub.badge %} \footnotesize\badge{ {{ sub.badge }} } {% endif %} - \color{ {{c}} } \large\textit{ {{sub.text|default:""|safe|texify|safe}} } \\ - {% endwith %} - {% endfor %} -\end{longtable} diff --git a/aleksis/apps/chronos/templates/chronos/latex/teacher.tex b/aleksis/apps/chronos/templates/chronos/latex/teacher.tex deleted file mode 100644 index 5320e069..00000000 --- a/aleksis/apps/chronos/templates/chronos/latex/teacher.tex +++ /dev/null @@ -1,13 +0,0 @@ -{% if not sub.is_event %}{% if sub.sub.type == 1 %} -\sout{% templatetag openbrace %}{{ sub.sub.teacher_old.shortcode }}} -{% elif sub.sub.teacher_new and sub.sub.teacher_old %} -\sout{% templatetag openbrace %}{{ sub.sub.teacher_old.shortcode }}} -$\rightarrow$ -{{ sub.sub.teacher_new.shortcode }} -{% elif sub.sub.teacher_new and not sub.sub.teacher_old %} -{{ sub.sub.teacher_new.shortcode }} -{% elif sub.sub.teacher_old %} -{{ sub.sub.teacher_old.shortcode }} -{% endif %}{% else %} -{% for teacher in sub.teachers %}{{ teacher.shortcode }}{% if not forloop.last %}, {% endif %}{% endfor %} -{% endif %} diff --git a/aleksis/apps/chronos/views.py b/aleksis/apps/chronos/views.py index 4f454cae..66ba1344 100644 --- a/aleksis/apps/chronos/views.py +++ b/aleksis/apps/chronos/views.py @@ -15,7 +15,7 @@ from aleksis.core.decorators import admin_required from aleksis.core.models import Person, Group from aleksis.core.util import messages -from .forms import LessonSubstitutionForm, SelectForm +from .forms import LessonSubstitutionForm from .models import LessonPeriod, LessonSubstitution, TimePeriod, Room from .tables import LessonsTable, SubstitutionsTable from .util import CalendarWeek -- GitLab