diff --git a/generate.py b/generate.py index e5f6bda..0e56d86 100755 --- a/generate.py +++ b/generate.py @@ -59,6 +59,9 @@ class Top: else: raise ValueError("One of title or message is needed") + if self.body is None: + self.body = "" + def __repr__(self): return "" @@ -92,12 +95,18 @@ def weekday(indate): return WEEKDAYS[indate.weekday()] def prototop(top): + result = "" + if "protostub" in dir(top) and top.protostub: - return j2env.from_string(top.protostub).render(context, top=top) + result = j2env.from_string(top.protostub).render(context, top=top) elif top.body: - return j2env.from_string(top.body).render(context) - else: - return None + result = j2env.from_string(top.body).render(context) + + for search,replace in config["protoreplace"].items(): + result = result.replace(search, replace) + + return result + def conf2top(top): sender = None diff --git a/prepare_protocol.sh b/prepare_protocol.sh index 35ca39b..9f38ca4 100755 --- a/prepare_protocol.sh +++ b/prepare_protocol.sh @@ -1,5 +1,11 @@ #!/bin/bash + +echo Reading old protocols ./read_db.sh +echo Getting E-Mail +./read_topmails.py ./read_ubmails.py +echo Generating + ./generate.py --proto > ~/fsmi/protokolle/$(date +%Y-%m-%d) diff --git a/templates/fsr_protokoll.j2 b/templates/fsr_protokoll.j2 index e4f2269..a6d94c9 100644 --- a/templates/fsr_protokoll.j2 +++ b/templates/fsr_protokoll.j2 @@ -16,9 +16,8 @@ {% for top in to %} = {{top.title}} = -{%if top.sender%}Eingereicht von: {{top.sender}} -{%endif%}{{top|prototop}} +{{top|prototop}} {% endfor %} [[Kategorie:Protokoll]]