From 2c509d085effdfca58eafd1bf9bbd5a99bec56f3 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Fri, 4 Aug 2023 09:29:25 +0300 Subject: [PATCH] allow editing ent letter if blank on many ent caves --- core/views/caves.py | 18 ++++++++++++------ templates/editentrance.html | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/core/views/caves.py b/core/views/caves.py index be4278a..4a148a1 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -451,6 +451,8 @@ 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=}") @@ -497,22 +499,26 @@ def edit_entrance(request, path="", caveslug=None, entslug=None): form = EntranceForm(instance=entrance) if entslug is None: - entletter = EntranceLetterForm() - print(f" Getting entletter from EntranceLetterForm") + entletterform = EntranceLetterForm() + # print(f" Getting entletter from EntranceLetterForm") else: entletter = caveAndEntrance.entranceletter - print(f"{entletter=}") + if entletter == "": + entletterform = EntranceLetterForm() + print(f" Blank value: getting entletter from EntranceLetterForm") + print(f"{entletter=} {entletterform=}") else: - form = EntranceForm() - entletter = EntranceLetterForm() + entform = EntranceForm() + entletterform = EntranceLetterForm() return render( request, "editentrance.html", { - "form": form, + "entform": form, "cave": cave, "entletter": entletter, + "entletterform": entletterform, "entlettereditable": entlettereditable, "path": path + "/", }, diff --git a/templates/editentrance.html b/templates/editentrance.html index 589c7da..c07235d 100644 --- a/templates/editentrance.html +++ b/templates/editentrance.html @@ -18,11 +18,11 @@ so the Easting/Northing fields will be blank. {% if entlettereditable %} - {{ entletter }}
+ {{ entletterform }}
{% else %}
Entrance Letter{{ entletter }}
{% endif %} - {{ form }}
+ {{ entform }}