From 63599cb27ad6cfe60b71e3f565ac286cf4f96026 Mon Sep 17 00:00:00 2001 From: Martin Green Date: Wed, 5 Jul 2023 18:22:08 +0100 Subject: [PATCH] Removed ability to add other caves entrances to a cave. --- core/views/caves.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/core/views/caves.py b/core/views/caves.py index 187517c..82ab5d2 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -372,8 +372,8 @@ def edit_cave(request, path="", slug=None): cave = Cave() if request.POST: form = CaveForm(request.POST, instance=cave) - ceFormSet = CaveAndEntranceFormSet(request.POST) - if form.is_valid() and ceFormSet.is_valid(): + #ceFormSet = CaveAndEntranceFormSet(request.POST) + if form.is_valid(): # and ceFormSet.is_valid(): # print(f'! POST is valid. {cave}') cave = form.save(commit=False) if not cave.filename: @@ -385,10 +385,10 @@ def edit_cave(request, path="", slug=None): if slug is None: cs = CaveSlug(cave=cave, slug=cave.reference(), primary=True) cs.save() - ceinsts = ceFormSet.save(commit=False) - for ceinst in ceinsts: - ceinst.cave = cave - ceinst.save() + #ceinsts = ceFormSet.save(commit=False) + #for ceinst in ceinsts: + # ceinst.cave = cave + # ceinst.save() try: cave_file = cave.file_output() write_and_commit([cave_file], f"Online edit of cave {cave}") @@ -407,13 +407,14 @@ def edit_cave(request, path="", slug=None): else: if slug is not None: # re-read cave data from file. - read_cave(cave.filename, cave=cave) + if cave.filename: + read_cave(cave.filename, cave=cave) form = CaveForm(instance=cave, initial={'cave_slug': cave.slug()}) - ceFormSet = CaveAndEntranceFormSet(queryset=cave.caveandentrance_set.all()) + #ceFormSet = CaveAndEntranceFormSet(queryset=cave.caveandentrance_set.all()) else: form = CaveForm() - ceFormSet = CaveAndEntranceFormSet(queryset=CaveAndEntrance.objects.none()) + #ceFormSet = CaveAndEntranceFormSet(queryset=CaveAndEntrance.objects.none()) return render( request, @@ -422,7 +423,7 @@ def edit_cave(request, path="", slug=None): "form": form, "cave": cave, "message": message, - "caveAndEntranceFormSet": ceFormSet, + #"caveAndEntranceFormSet": ceFormSet, "path": path + "/", }, )