summaryrefslogtreecommitdiffstats
path: root/core/views/caves.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-04-22 01:24:32 +0100
committerPhilip Sargent <philip.sargent@gmail.com>2023-04-22 01:24:32 +0100
commit2ed66fe3d0c24ba993425947ee7cd0986ecba83c (patch)
treefe188871223eac09d30725f53b9015a4875cf609 /core/views/caves.py
parent116cfc7c6e5da0522ce301a89386b37efac5dfe5 (diff)
downloadtroggle-2ed66fe3d0c24ba993425947ee7cd0986ecba83c.tar.gz
troggle-2ed66fe3d0c24ba993425947ee7cd0986ecba83c.tar.bz2
troggle-2ed66fe3d0c24ba993425947ee7cd0986ecba83c.zip
edit cave reads from HTML file not just db
Diffstat (limited to 'core/views/caves.py')
-rw-r--r--core/views/caves.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/core/views/caves.py b/core/views/caves.py
index 7a3818c..07ea315 100644
--- a/core/views/caves.py
+++ b/core/views/caves.py
@@ -14,6 +14,9 @@ from troggle.core.models.caves import Cave, CaveAndEntrance, Entrance, GetCaveLo
from troggle.core.models.logbooks import CaveSlug, QM
from troggle.core.utils import write_and_commit
from troggle.core.views import expo
+from troggle.settings import CAVEDESCRIPTIONS, ENTRANCEDESCRIPTIONS
+from troggle.parsers.caves import readcave, readentrance
+
from .auth import login_required_if_public
@@ -333,7 +336,7 @@ def edit_cave(request, path="", slug=None):
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.
+ It saves the data into into the database and into the html file, which it then commits to git.
"""
message = ""
if slug is not None:
@@ -373,7 +376,7 @@ def edit_cave(request, path="", slug=None):
ceinst.save()
try:
cave_file = cave.file_output()
- print(cave_file)
+ # print(cave_file)
write_and_commit([cave_file], f"Online edit of {cave}")
# leave other exceptions unhandled so that they bubble up to user interface
except PermissionError:
@@ -388,6 +391,10 @@ def edit_cave(request, path="", slug=None):
message = f"! POST data is INVALID {cave}"
print(message)
else:
+ # re-read cave data from file.
+ filename = str(cave.slug() +".html")
+ readcave(filename, cave=cave)
+
form = CaveForm(instance=cave)
ceFormSet = CaveAndEntranceFormSet(queryset=cave.caveandentrance_set.all())