fix missing slug field in pending caves

This commit is contained in:
Philip Sargent
2021-04-03 00:34:34 +01:00
parent 912e447200
commit 8707e4a819
2 changed files with 20 additions and 8 deletions

View File

@@ -24,13 +24,14 @@ def readcaves():
print (" - Setting pending caves")
# Do this first, so that these empty entries are overwritten as they get properly created.
# For those caves which do not have XML files even though they exist and have surveys
# also needs to be done *before* entrances so that the entrance-cave links work properly.
forgotten = ["2007-04", "2007-05", "2007-06", "2007-07", "2007-12", "2009-01", "2009-02",
pending = ["2007-04", "2007-05", "2007-06", "2007-07", "2007-12", "2009-01", "2009-02",
"2010-06", "2010-07", "2012-ns-01", "2012-ns-02", "2010-04", "2012-ns-05", "2012-ns-06",
"2012-ns-07", "2012-ns-08", "2012-ns-12", "2012-ns-14", "2012-ns-15", "2014-bl888",
"2018-pf-01", "2018-pf-02", "haldenloch", "gruenstein"]
for k in forgotten:
for k in pending:
try:
cave = models_caves.Cave(
unofficial_number = k,
@@ -44,8 +45,19 @@ def readcaves():
message = " ! {:11s} {}".format(cave.unofficial_number, cave.underground_description)
DataIssue.objects.create(parser='caves', message=message)
print(message)
try: # Now create a slug ID
cs = models_caves.CaveSlug.objects.update_or_create(cave = cave,
slug = "PENDING-" + k,
primary = False)
except:
message = " ! {:11s} {} PENDING cave slug create failure".format(k)
DataIssue.objects.create(parser='caves', message=message)
print(message)
else:
print("Failed to create cave {} ".format(k))
except:
message = " ! Error. Cannot create pending cave, pending-id:{}".format(k)
DataIssue.objects.create(parser='caves', message=message)