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

If a cave is made with no entrances, redirect to a new entrance form for the cave

This commit is contained in:
Martin Green 2023-04-30 21:42:03 +01:00
parent c7b3e8aff0
commit 2ee63a9804

View File

@ -6,7 +6,7 @@ from pathlib import Path
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.http import HttpResponse, HttpResponseNotFound, HttpResponseRedirect
from django.shortcuts import render
from django.urls import NoReverseMatch
from django.urls import NoReverseMatch, reverse
import troggle.settings as settings
from troggle.core.forms import CaveAndEntranceFormSet, CaveForm, EntranceForm, EntranceLetterForm
@ -373,8 +373,10 @@ def edit_cave(request, path="", slug=None):
except subprocess.SubprocessError:
message = f"CANNOT git on server for this file {cave.filename}. Edits may not be committed.\nAsk a nerd to fix this."
return render(request, "errors/generic.html", {"message": message})
if cave.entrances().count() > 0:
return HttpResponseRedirect("/" + cave.url)
else:
return HttpResponseRedirect(reverse("newentrance", args = [cave.url_parent(), cave.slug()]))
else:
if slug is not None: