2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-05-18 20:42:21 +01:00

Added some test pages showing different ways pages could be edited. This probably wants removing soon

This commit is contained in:
Martin Green
2022-06-28 00:18:24 +01:00
parent 82fe350493
commit 2af88353f3
6 changed files with 192 additions and 3 deletions
+38 -1
View File
@@ -18,7 +18,7 @@ import troggle.settings as settings
from troggle.core.views import expo
from troggle.core.models.troggle import Expedition, DataIssue
from troggle.core.models.caves import CaveSlug, Cave, CaveAndEntrance, QM, EntranceSlug, Entrance, Area, SurvexStation, GetCaveLookup
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, EntranceForm, EntranceLetterForm
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, EntranceForm, EntranceLetterForm, CaveFormCodeMirrorPreview, CaveFormTextArea, CaveFormTinyMCE
from .auth import login_required_if_public
'''Manages the complex procedures to assemble a cave description out of the compnoents
@@ -297,6 +297,42 @@ def caveEntrance(request, slug):
else:
return render(request,'cave_entrances.html', {'cave': cave})
def test_edit_cave(request, editor = "codemirror"):
'''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
It does save the data into into the database directly, not by parsing the file.
It does NOT yet commit to the git repoSaving is not allowed
'''
form_type = {"codemirror": CaveForm, "codemirrorpreview": CaveFormCodeMirrorPreview, "textarea": CaveFormTextArea, "tinymce": CaveFormTinyMCE}[editor]
message = ""
try:
cave = Cave.objects.get(caveslug__slug = "1623-264")
except:
return render(request,'errors/badslug.html')
if request.POST:
form = form_type(request.POST, instance=cave)
ceFormSet = CaveAndEntranceFormSet(request.POST)
#versionControlForm = VersionControlCommentForm(request.POST)
if form.is_valid() and ceFormSet.is_valid():
pass
else:
message = f'! POST data is INVALID {cave}'
print(message)
else:
form = form_type(instance=cave)
ceFormSet = CaveAndEntranceFormSet(queryset=cave.caveandentrance_set.all())
#versionControlForm = VersionControlCommentForm()
return render(request,
'editcave.html',
{'form': form, 'cave': cave, 'message': message,
'caveAndEntranceFormSet': ceFormSet,
'editor': editor,
#'versionControlForm': versionControlForm
})
@login_required_if_public
def edit_cave(request, slug=None):
'''This is the form that edits all the cave data and writes out an XML file in the :expoweb: repo folder
@@ -305,6 +341,7 @@ def edit_cave(request, slug=None):
It does save the data into into the database directly, not by parsing the file.
It does NOT yet commit to the git repo
'''
message = ""
if slug is not None:
try: