diff --git a/core/views/caves.py b/core/views/caves.py index 445d6c6..be4278a 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -442,13 +442,19 @@ def edit_entrance(request, path="", caveslug=None, entslug=None): entrance = None if entslug: - print(f"{caveslug=} {entslug=} {path=}") + print(f"{caveslug=} {entslug=} {path=} number of ents:{cave.entrances().count()}") caveAndEntrance = CaveAndEntrance.objects.get(entrance=entrance, cave=cave) - entlettereditable = False + entlettereditable = False else: caveAndEntrance = CaveAndEntrance(cave=cave, entrance=Entrance()) entlettereditable = True - + + if caveAndEntrance.entranceletter == "" and cave.entrances().count() > 0 : + # this should not be blank on a multiple-entrance cave + entlettereditable = True + + print(f"{entlettereditable=}") + if request.POST: print(f"Online edit of entrance {entrance.slug}") form = EntranceForm(request.POST, instance=entrance) diff --git a/parsers/caves.py b/parsers/caves.py index 08c336c..9740d1f 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -1,5 +1,6 @@ import os import re +import string from pathlib import Path @@ -511,7 +512,9 @@ def read_cave(filename, cave=None): if len(entrances) > 1 and letter =="": # user error, but we can recover letter = eslug[-1].lower() - message = f"- Warning - duplicate entrance or empty 'letter' field for '{eslug}' in cave '{cave}', setting to {letter}." + if letter.lower() not in list(string.ascii_lowercase): + letter = "x" + message = f"- Warning - Empty 'letter' field for '{eslug}' in multiple-entrance cave '{cave}', setting to {letter}." DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.area}/{cave.area}-{cave.url}_cave_edit/") print(message)