diff --git a/core/models/caves.py b/core/models/caves.py index 8f3e54d..92255bb 100644 --- a/core/models/caves.py +++ b/core/models/caves.py @@ -44,7 +44,7 @@ class Area(TroggleModel): short_name = models.CharField(max_length=100) name = models.CharField(max_length=200, blank=True, null=True) description = models.TextField(blank=True, null=True) - parent = models.ForeignKey('Area', blank=True, null=True, on_delete=models.SET_NULL) + super = models.ForeignKey('Area', blank=True, null=True, on_delete=models.SET_NULL) def __str__(self): if self.parent: @@ -231,9 +231,9 @@ class Cave(TroggleModel): areas = self.area.all() lowestareas = list(areas) for area in areas: - if area.parent in areas: + if area.super in areas: try: - lowestareas.remove(area.parent) + lowestareas.remove(area.super) except: pass return lowestareas[0] diff --git a/parsers/caves.py b/parsers/caves.py index 91efc96..e9be47b 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -187,10 +187,10 @@ def readcaves(): print(" - Creating Areas 1623 and 1626") # This crashes on the server with MariaDB even though a null parent is explicitly allowed. - area_1623= Area.objects.create(short_name = "1623", parent=None) + area_1623= Area.objects.create(short_name = "1623", super=None) print(" - Saving Area 1623") area_1623.save() - area_1626= Area.objects.create(short_name = "1626", parent=None) + area_1626= Area.objects.create(short_name = "1626", super=None) print(" - Saving Area 1626") area_1626.save() @@ -402,7 +402,7 @@ def readcave(filename): if area: newArea = area[0] else: - newArea = Area(short_name = area_slug, parent = Area.objects.get(short_name = "1623")) + newArea = Area(short_name = area_slug, super = Area.objects.get(short_name = "1623")) newArea.save() areas_xslug[area_slug] = newArea c.area.add(newArea) diff --git a/parsers/survex.py b/parsers/survex.py index e5d30e9..e5b2867 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -75,7 +75,7 @@ class MapLocations(object): try: areaName = k.getArea().short_name except: - message = " ! Failed to get Area on cave '{}' linked to Entrance:{} from:{} best:{}".format(cave, ent.name, ent.filename, ent.best_station()) + message = " ! Failed to get Area on cave '{}' linked to Entrance:{} from:{} best:{}".format(k, ent.name, ent.filename, ent.best_station()) DataIssue.objects.create(parser='entrances', message=message) print(message) raise