mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
debugging entrance creation, single ent works
This commit is contained in:
parent
1375b34cbe
commit
51298786c3
@ -439,6 +439,7 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
|
||||
except:
|
||||
return render(request, "errors/badslug.html", {"badslug": f"for entrance {entslug} - from edit_entrance()"})
|
||||
else:
|
||||
# a new entrance on a cave
|
||||
entrance = None
|
||||
|
||||
if entslug:
|
||||
@ -452,23 +453,22 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
|
||||
if caveAndEntrance.entranceletter == "" and cave.entrances().count() > 0 :
|
||||
# this should not be blank on a multiple-entrance cave
|
||||
# but it doesn't trigger the entrnce letter form unless entletter has a value
|
||||
|
||||
entlettereditable = True
|
||||
|
||||
print(f"{entlettereditable=}")
|
||||
|
||||
if request.POST:
|
||||
print(f"Online edit of entrance {entrance.slug}")
|
||||
print(f"POST Online edit of entrance: '{entrance}' where {cave=}")
|
||||
form = EntranceForm(request.POST, instance=entrance)
|
||||
entletter = EntranceLetterForm(request.POST, instance=caveAndEntrance)
|
||||
if form.is_valid() and entletter.is_valid():
|
||||
entletterform = EntranceLetterForm(request.POST, instance=caveAndEntrance)
|
||||
if form.is_valid() and entletterform.is_valid():
|
||||
entrance = form.save(commit=False)
|
||||
entranceletter = entletter.save(commit=False)
|
||||
print(f"- POST {caveslug=} {entslug=} {entranceletter=} {entletter.cleaned_data['entranceletter']=} {path=}")
|
||||
ce = entletterform.save(commit=False)
|
||||
print(f"- POST {caveslug=} {entslug=} {ce=} {entletterform.cleaned_data['entranceletter']=} {path=}")
|
||||
if entslug is None:
|
||||
if entletter.cleaned_data["entranceletter"]:
|
||||
slugname = cave.slug() + entletter.cleaned_data["entranceletter"]
|
||||
print(f"- POST letter {entletter.cleaned_data['entranceletter']=}")
|
||||
if entletterform.cleaned_data["entranceletter"]:
|
||||
slugname = cave.slug() + entletterform.cleaned_data["entranceletter"]
|
||||
print(f"- POST letter {entletterform.cleaned_data['entranceletter']=}")
|
||||
else:
|
||||
slugname = cave.slug()
|
||||
entrance.slug = slugname
|
||||
@ -478,14 +478,23 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
|
||||
entrance.slug = entslug
|
||||
entrance.cached_primary_slug = entslug
|
||||
entrance.filename = entslug + ".html"
|
||||
entrance.save()
|
||||
entranceletter.entrance = entrance
|
||||
entranceletter.save()
|
||||
try:
|
||||
entrance.save()
|
||||
except:
|
||||
# fails with uniqueness constraint failure. Which is on CaveAndEntrance, not just on entrance, which is bizarre.
|
||||
print(f"SAVE EXCEPTION FAIL {entrance=}")
|
||||
print(f"CAVE {cave}")
|
||||
for ce in cave.entrances():
|
||||
print(f"CAVE:{ce.cave} - ENT:{ce.entrance} - LETTER:'{ce.entranceletter}'")
|
||||
raise
|
||||
ce.entrance = entrance
|
||||
ce.save()
|
||||
|
||||
entrance_file = entrance.file_output()
|
||||
cave_file = cave.file_output()
|
||||
|
||||
print(f"- POST WRITE letter {entranceletter}")
|
||||
|
||||
print(f"- POST WRITE letter: '{ce}' {entrance=}")
|
||||
write_and_commit([entrance_file, cave_file], f"Online edit of entrance {entrance.slug}")
|
||||
return HttpResponseRedirect("/" + cave.url)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user