2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11: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 : 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
entlettereditable = True entlettereditable = True
print(f"{entlettereditable=}") print(f"{entlettereditable=}")
@ -497,22 +499,26 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
form = EntranceForm(instance=entrance) form = EntranceForm(instance=entrance)
if entslug is None: if entslug is None:
entletter = EntranceLetterForm() entletterform = EntranceLetterForm()
print(f" Getting entletter from EntranceLetterForm") # print(f" Getting entletter from EntranceLetterForm")
else: else:
entletter = caveAndEntrance.entranceletter entletter = caveAndEntrance.entranceletter
print(f"{entletter=}") if entletter == "":
entletterform = EntranceLetterForm()
print(f" Blank value: getting entletter from EntranceLetterForm")
print(f"{entletter=} {entletterform=}")
else: else:
form = EntranceForm() entform = EntranceForm()
entletter = EntranceLetterForm() entletterform = EntranceLetterForm()
return render( return render(
request, request,
"editentrance.html", "editentrance.html",
{ {
"form": form, "entform": form,
"cave": cave, "cave": cave,
"entletter": entletter, "entletter": entletter,
"entletterform": entletterform,
"entlettereditable": entlettereditable, "entlettereditable": entlettereditable,
"path": path + "/", "path": path + "/",
}, },

View File

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