Browse Source

Fix Typo in Printout

bernhardbuhl 3 years ago
parent
commit
b654e78606
1 changed files with 4 additions and 56 deletions
  1. 4 56
      AntragDrucken.py

+ 4 - 56
AntragDrucken.py

@@ -3,7 +3,7 @@ from antrag import SampleAntrag as Antrag
 from pathlib import Path
 from os import getcwd
 from dataclasses import dataclass
-import json
+
 
 @dataclass
 class Field:
@@ -15,15 +15,13 @@ class Field:
     kurzbeschreibung: str
 
 
-
-class AntragDrucken():
+class AntragDrucken:
 
     def __init__(self, antrag: Antrag):
         self.antrag = antrag
-        self.pathAndFileName:Path = Path()
+        self.pathAndFileName: Path = Path()
         self.activityFields = []
 
-
     def executeActivity(self) -> bool:
         # Build field-list for printout
         for fieldGroup in self.antrag.instance["field_groups"]:
@@ -52,7 +50,7 @@ class AntragDrucken():
         </head>
         <body>
         <font face="arial">
-        <p align="center"><font face="arial" size="20">Prämienindikation "$(Produktname)"</font></p>
+        <p align="center"><font face="arial" size="20">Premium indication "$(Produktname)"</font></p>
         <p align="center"><font face="arial" size="6">$(Datum)</font></p>
         <br>
         <p><font face="arial" size="9">Thank you for your interest in $(Produktname).
@@ -118,7 +116,6 @@ Based on the given parameters we are happy to provide a premium indication as fo
 
         html = html_start + html + html_end
 
-        # html = self._replaceVariable(html)
         html = html.replace("€", "EURO")
         self.outputPDFfromHTML(html)
         # self.writePDFfromHTML(html)
@@ -140,52 +137,3 @@ Based on the given parameters we are happy to provide a premium indication as fo
             self.pathAndFileName.parent.mkdir(parents=False)
 
         pdf.output(str(self.pathAndFileName))
-
-    # Moved from Activity class in fasifu.
-    def _replaceVariable(self, expression):
-        if not "$(" in expression:
-            return expression
-
-        antrag = self.antrag
-
-        while "$(" in expression:
-            if expression[0:2] == "$(":
-                left_part = ""
-            else:
-                left_part = expression.split("$(")[0]
-
-            center = expression[len(left_part) + 2:]
-            center = center.split(")")[0]
-
-            try:
-                right_part = expression[len(left_part) + len(center) + 3:]
-            except Exception:
-                right_part = ""
-
-            # Left = part of payload before $( starts
-            # right_part = part of payload after $(variable) ends
-            # center = the <variable>-part inside $(<variable>)
-
-            # center might be polizze.polizzenNummer or self.wirksamkeitsdatum
-            if "." in center:
-                lClassForAttribute = locals().get(center.split(".")[0])
-                center = center.split(".")[1]
-                try:
-                    centerValue = getattr(lClassForAttribute, center)
-                except Exception as e:
-                    raise BaseException("Fehler in _replaceVariable. Guckst Du Logs.")
-            else:
-                lClassForAttribute = self
-                try:
-                    lField = lClassForAttribute.activityFields.getField(name=center)
-                    if lField.valueChosenOrEnteredTech:
-                        centerValue = lField.valueChosenOrEnteredTech
-                    else:
-                        centerValue = lField.valueChosenOrEntered
-                except:
-                    centerValue = getattr(lClassForAttribute, center)
-
-            expression = "".join([left_part, str(centerValue), right_part])
-
-        return expression
-