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

allow editing ent letter if blank on many ent caves

This commit is contained in:
Philip Sargent 2023-08-04 09:29:25 +03:00
parent bed663a031
commit 2c509d085e
2 changed files with 14 additions and 8 deletions

View File

@ -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 + "/",
},

View File

@ -18,11 +18,11 @@ so the Easting/Northing fields will be blank.
</ul>
{% if entlettereditable %}
<table>{{ entletter }}</table>
<table>{{ entletterform }}</table>
{% else %}
<table><tr><th>Entrance Letter</th><td>{{ entletter }}</td></table>
{% endif %}
<table>{{ form }}</table>
<table>{{ entform }}</table>
<p><input type="submit" value="Submit" /></p>
</form>