diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2022-12-21 02:05:26 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2022-12-21 02:05:26 +0000 |
commit | ec040824f632ca31e074fdba4dc535a10785ab75 (patch) | |
tree | 6f5a6a7125dd08d77eaeb0c05ce43944e3c46c6c /core/views/other.py | |
parent | 517da57a0cecf3a8c50cea72c6df3690c506e08b (diff) | |
download | troggle-ec040824f632ca31e074fdba4dc535a10785ab75.tar.gz troggle-ec040824f632ca31e074fdba4dc535a10785ab75.tar.bz2 troggle-ec040824f632ca31e074fdba4dc535a10785ab75.zip |
fix frontmatter/endmatter
Diffstat (limited to 'core/views/other.py')
-rw-r--r-- | core/views/other.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/core/views/other.py b/core/views/other.py index b590f21..167e0b2 100644 --- a/core/views/other.py +++ b/core/views/other.py @@ -181,7 +181,16 @@ def exportlogbook(request,year=None,extension=None): response['Content-Disposition'] = 'attachment; filename='+filename t=loader.get_template(template) logbookfile = (t.render({'logbook_entries':logbook_entries})) - + + endpath = Path(settings.EXPOWEB, "years", year, "endmatter.html") + endmatter = "" + if endpath.is_file(): + try: + with open(endpath,"r") as end: + endmatter = end.read() + except: + print(" ! Very Bad Error opening " + endpath) + frontpath = Path(settings.EXPOWEB, "years", year, "frontmatter.html") if frontpath.is_file(): try: @@ -189,9 +198,9 @@ def exportlogbook(request,year=None,extension=None): frontmatter = front.read() except: print(" ! Very Bad Error opening " + frontpath) - logbookfile = re.sub(r"<body>", "<body>\n"+frontmatter , logbookfile) + logbookfile = re.sub(r"<body>", "<body>\n"+frontmatter+endmatter , logbookfile) else: - logbookfile = re.sub(r"<body>", f"<body>\n<h1>Expo {year}</h1>\n", logbookfile) + logbookfile = re.sub(r"<body>", f"<body>\n<h1>Expo {year}</h1>\n"+endmatter, logbookfile) dir = Path(settings.EXPOWEB) / "years" / year |