diff options
Diffstat (limited to 'core/views/caves.py')
-rw-r--r-- | core/views/caves.py | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/core/views/caves.py b/core/views/caves.py index 8df801b..bbc2750 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -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: |