diff --git a/parsers/caves.py b/parsers/caves.py index 7f93cb3..4a4584c 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -920,7 +920,8 @@ def read_cave(filename, mvf=None, cave=None): slug = check_slug(cave.areacode, cave.kataster_number, cave.unofficial_number, cave.url) #NB cave.slug is not a field on Cave - # Thsi whole way of doing entrances can be replaced by simply knowing the entrance_data filename what the cave is. to do. + # Thsi whole way of doing entrances can be replaced by simply knowing the entrance_data filename what the cave is. TO DO. + # This also fails if there are more entance_data files for a cave tahn the cave_data file knows about. entrances = getXML(cavecontents, "entrance", context=context) #do_entrances() if not entrances or len(entrances) < 1: @@ -1015,6 +1016,15 @@ def readcaves(): if filename.endswith(".html"): read_cave(filename, mvf) + # check entrances all have caves associated with them + for e in Entrance.objects.all(): + if not e.firstcave(): + message = f' ! No cave associated with entrance {e.slug} in {ENTRANCEDESCRIPTIONS}/{e.filename}. Deleting the Entrance object.' + DataIssue.objects.create(parser="entrances", message=message, url=f"/{e.slug}") + print(message) + e.delete() + + print(" - Setting up all the variously useful alias names") GetCaveLookup()