summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2022-10-12 22:09:58 +0300
committerPhilip Sargent <philip.sargent@klebos.com>2022-10-12 22:09:58 +0300
commitb81b4ef2ef8c96bfac10a3e8a0529a069ef9a605 (patch)
tree055e69daded8a79349843ba43ed14322f72e5536 /core
parent52c0ab213a6346f3ca5028d13ddbe11aa75aff8d (diff)
downloadtroggle-b81b4ef2ef8c96bfac10a3e8a0529a069ef9a605.tar.gz
troggle-b81b4ef2ef8c96bfac10a3e8a0529a069ef9a605.tar.bz2
troggle-b81b4ef2ef8c96bfac10a3e8a0529a069ef9a605.zip
Add date of update to the generated html file
Diffstat (limited to 'core')
-rw-r--r--core/models/caves.py16
-rw-r--r--core/views/caves.py3
2 files changed, 13 insertions, 6 deletions
diff --git a/core/models/caves.py b/core/models/caves.py
index 2494a4e..016f92e 100644
--- a/core/models/caves.py
+++ b/core/models/caves.py
@@ -5,6 +5,7 @@ import re
import json
import subprocess
import operator
+from datetime import datetime, timezone
from collections import defaultdict
from pathlib import Path
@@ -235,8 +236,9 @@ class Cave(TroggleModel):
filepath = os.path.join(settings.CAVEDESCRIPTIONS, self.filename)
t = loader.get_template('dataformat/cave.xml')
- #c = Context({'cave': self})
- c = dict({'cave': self})
+ now = datetime.now(timezone.utc)
+ print(now)
+ c = dict({'cave': self, 'date': now})
u = t.render(c)
writetrogglefile(filepath, u)
return
@@ -245,8 +247,8 @@ class Cave(TroggleModel):
filepath = Path(os.path.join(settings.CAVEDESCRIPTIONS, self.filename))
t = loader.get_template('dataformat/cave.xml')
- #c = Context({'cave': self})
- c = dict({'cave': self})
+ now = datetime.now(timezone.utc)
+ c = dict({'cave': self, 'date': now})
content = t.render(c)
return (filepath, content, "utf8")
@@ -422,7 +424,8 @@ class Entrance(TroggleModel):
filepath = Path(os.path.join(settings.ENTRANCEDESCRIPTIONS, self.filename))
t = loader.get_template('dataformat/entrance.xml')
- c = dict({'entrance': self})
+ now = datetime.now(timezone.utc)
+ c = dict({'entrance': self, 'date': now})
content = t.render(c)
return (filepath, content, "utf8")
@@ -430,7 +433,8 @@ class Entrance(TroggleModel):
filepath = os.path.join(settings.ENTRANCEDESCRIPTIONS, self.filename)
t = loader.get_template('dataformat/entrance.xml')
- c = dict({'entrance': self})
+ now = datetime.now(timezone.utc)
+ c = dict({'entrance': self, 'date': now})
u = t.render(c)
writetrogglefile(filepath, u)
return
diff --git a/core/views/caves.py b/core/views/caves.py
index acd75a6..fe85949 100644
--- a/core/views/caves.py
+++ b/core/views/caves.py
@@ -301,6 +301,7 @@ def caveEntrance(request, slug):
def edit_cave(request, path = "", slug=None):
'''This is the form that edits all the cave data and writes out an XML file in the :expoweb: repo folder
The format for the file being saved is in templates/dataformat/cave.xml
+ Warning. This uses Django deep magic.
It does save the data into into the database directly, not by parsing the file.
'''
@@ -343,6 +344,7 @@ def edit_cave(request, path = "", slug=None):
ceinst.save()
try:
cave_file = cave.file_output()
+ print(cave_file)
write_and_commit([cave_file], "Online edit of %s" % cave)
# leave other exceptions unhandled so that they bubble up to user interface
except PermissionError:
@@ -373,6 +375,7 @@ def edit_entrance(request, path = "", caveslug=None, slug=None):
'''This is the form that edits the entrance data for a single entrance and writes out
an XML file in the :expoweb: repo folder
The format for the file being saved is in templates/dataformat/entrance.xml
+ Warning. This uses Django deep magic.
It does save the data into into the database directly, not by parsing the file.
'''