From 018330a82ed276c3f68146493605fc694848688c Mon Sep 17 00:00:00 2001
From: Frank Poetzsch-Heffter <p-h@katharineum.de>
Date: Sat, 5 Oct 2019 11:37:49 +0200
Subject: [PATCH] page numbering, comment out pdf-merging, sorting absence
 teachers

---
 biscuit/apps/chronos/pdf.py   |  4 ++++
 biscuit/apps/chronos/views.py | 37 +++++++++++++++++------------------
 2 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/biscuit/apps/chronos/pdf.py b/biscuit/apps/chronos/pdf.py
index 3b921bb1..255b99f7 100644
--- a/biscuit/apps/chronos/pdf.py
+++ b/biscuit/apps/chronos/pdf.py
@@ -22,6 +22,10 @@ def generate_pdf(tex, filename):
     bash_command = "pdflatex -halt-on-error -output-directory {} {}.tex".format(os.path.join(BASE_DIR, "latex"),
                                                                                 os.path.join(BASE_DIR, "latex",
                                                                                              filename))
+    # Execute two times to get number of last page
+    process = subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
+    output = process.communicate()[0]
+    del output
     process = subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
     output = process.communicate()[0]
     del output
diff --git a/biscuit/apps/chronos/views.py b/biscuit/apps/chronos/views.py
index c13d8117..b0a7b6be 100755
--- a/biscuit/apps/chronos/views.py
+++ b/biscuit/apps/chronos/views.py
@@ -337,28 +337,27 @@ def sub_pdf(request, plan_date=None):
         tex += generate_class_tex_body(sub_table, date, header_info, hints)
 
     tex += "\end{document}"
-    print(tex)
     # Generate PDF
     generate_pdf(tex, "aktuell")
 
-    # Merge PDFs
-    try:
-        merger = PdfFileMerger()
-        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 aktuell.pdf
-        output = open(os.path.join(BASE_DIR, "latex", "aktuell.pdf"), "wb")
-        merger.write(output)
-        output.close()
-
-        # Register successful merge in debugging tool
-        register_return_0("merge_class", "pypdf2")
-    except Exception:
-        # Register exception in debugging tool
-        register_traceback("merge_class", "pypdf2")
+    # # Merge PDFs
+    # try:
+    #     merger = PdfFileMerger()
+    #     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 aktuell.pdf
+    #     output = open(os.path.join(BASE_DIR, "latex", "aktuell.pdf"), "wb")
+    #     merger.write(output)
+    #     output.close()
+    #
+    #     # Register successful merge in debugging tool
+    #     register_return_0("merge_class", "pypdf2")
+    # except Exception:
+    #     # Register exception in debugging tool
+    #     register_traceback("merge_class", "pypdf2")
 
     # Read and response PDF
     file = open(os.path.join(BASE_DIR, "latex", "aktuell.pdf"), "rb")
-- 
GitLab