2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

Removed ability to add other caves entrances to a cave.

This commit is contained in:
Martin Green 2023-07-05 18:22:08 +01:00
parent a0fcb78e95
commit 63599cb27a

View File

@ -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 + "/",
},
)