fix bug in Area creation

This commit is contained in:
Philip Sargent 2022-07-08 22:19:07 +03:00
parent ca5586fc42
commit 9803ebe2e8

View File

@ -102,7 +102,7 @@ def do_pending_cave(k, url, area_1623):
notes = default_note) notes = default_note)
if cave: if cave:
cave.save() # must save to have id before foreign keys work. This is also a ManyToMany key. cave.save() # must save to have id before foreign keys work. This is also a ManyToMany key.
cave.area.add(area_1623[0]) cave.area.add(area_1623)
cave.save() cave.save()
message = f" ! {k:12} {cave.underground_description}" message = f" ! {k:12} {cave.underground_description}"
DataIssue.objects.create(parser='caves', message=message, url=url) DataIssue.objects.create(parser='caves', message=message, url=url)
@ -158,11 +158,10 @@ def readcaves():
DataIssue.objects.filter(parser='caves ok').delete() DataIssue.objects.filter(parser='caves ok').delete()
DataIssue.objects.filter(parser='entrances').delete() DataIssue.objects.filter(parser='entrances').delete()
area_1623 = Area.objects.update_or_create(short_name = "1623", parent = None) area_1623, state = Area.objects.update_or_create(short_name = "1623", parent = None)
# This seems to return a tuple, not a single object! i.e. (<Area: 1623>, True) # This seems to return a tuple, not a single object! i.e. (<Area: 1623>, True)
#print(f' ! - READ CAVES: {area_1623}') #print(f' ! - READ CAVES: {area_1623}')
area_1626, state = Area.objects.update_or_create(short_name = "1626", parent = None)
area_1626 = Area.objects.update_or_create(short_name = "1626", parent = None)
print (" - Setting pending caves") print (" - Setting pending caves")
# Do this first, so that these empty entries are overwritten as they get properly created. # Do this first, so that these empty entries are overwritten as they get properly created.