mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 16:51:54 +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:
|
except:
|
||||||
return render(request, "errors/badslug.html", {"badslug": f"for entrance {entslug} - from edit_entrance()"})
|
return render(request, "errors/badslug.html", {"badslug": f"for entrance {entslug} - from edit_entrance()"})
|
||||||
else:
|
else:
|
||||||
|
# a new entrance on a cave
|
||||||
entrance = None
|
entrance = None
|
||||||
|
|
||||||
if entslug:
|
if entslug:
|
||||||
@ -452,23 +453,22 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
|
|||||||
if caveAndEntrance.entranceletter == "" and cave.entrances().count() > 0 :
|
if caveAndEntrance.entranceletter == "" and cave.entrances().count() > 0 :
|
||||||
# this should not be blank on a multiple-entrance cave
|
# this should not be blank on a multiple-entrance cave
|
||||||
# but it doesn't trigger the entrnce letter form unless entletter has a value
|
# but it doesn't trigger the entrnce letter form unless entletter has a value
|
||||||
|
|
||||||
entlettereditable = True
|
entlettereditable = True
|
||||||
|
|
||||||
print(f"{entlettereditable=}")
|
print(f"{entlettereditable=}")
|
||||||
|
|
||||||
if request.POST:
|
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)
|
form = EntranceForm(request.POST, instance=entrance)
|
||||||
entletter = EntranceLetterForm(request.POST, instance=caveAndEntrance)
|
entletterform = EntranceLetterForm(request.POST, instance=caveAndEntrance)
|
||||||
if form.is_valid() and entletter.is_valid():
|
if form.is_valid() and entletterform.is_valid():
|
||||||
entrance = form.save(commit=False)
|
entrance = form.save(commit=False)
|
||||||
entranceletter = entletter.save(commit=False)
|
ce = entletterform.save(commit=False)
|
||||||
print(f"- POST {caveslug=} {entslug=} {entranceletter=} {entletter.cleaned_data['entranceletter']=} {path=}")
|
print(f"- POST {caveslug=} {entslug=} {ce=} {entletterform.cleaned_data['entranceletter']=} {path=}")
|
||||||
if entslug is None:
|
if entslug is None:
|
||||||
if entletter.cleaned_data["entranceletter"]:
|
if entletterform.cleaned_data["entranceletter"]:
|
||||||
slugname = cave.slug() + entletter.cleaned_data["entranceletter"]
|
slugname = cave.slug() + entletterform.cleaned_data["entranceletter"]
|
||||||
print(f"- POST letter {entletter.cleaned_data['entranceletter']=}")
|
print(f"- POST letter {entletterform.cleaned_data['entranceletter']=}")
|
||||||
else:
|
else:
|
||||||
slugname = cave.slug()
|
slugname = cave.slug()
|
||||||
entrance.slug = slugname
|
entrance.slug = slugname
|
||||||
@ -478,14 +478,23 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
|
|||||||
entrance.slug = entslug
|
entrance.slug = entslug
|
||||||
entrance.cached_primary_slug = entslug
|
entrance.cached_primary_slug = entslug
|
||||||
entrance.filename = entslug + ".html"
|
entrance.filename = entslug + ".html"
|
||||||
entrance.save()
|
try:
|
||||||
entranceletter.entrance = entrance
|
entrance.save()
|
||||||
entranceletter.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()
|
entrance_file = entrance.file_output()
|
||||||
cave_file = cave.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}")
|
write_and_commit([entrance_file, cave_file], f"Online edit of entrance {entrance.slug}")
|
||||||
return HttpResponseRedirect("/" + cave.url)
|
return HttpResponseRedirect("/" + cave.url)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user