diff --git a/core/views/caves.py b/core/views/caves.py index f83ed1c..2fad12c 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -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}) - - return HttpResponseRedirect("/" + cave.url) + 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: