diff --git a/parsers/cavetab.py b/parsers/cavetab.py index e133ca8..d76a280 100644 --- a/parsers/cavetab.py +++ b/parsers/cavetab.py @@ -55,7 +55,7 @@ Findability = 44 FindabilityComment = 45 def LoadCaveTab(): - + cavetab = open(os.path.join(settings.EXPOWEB, "noinfo", "CAVETAB2.CSV"),'rU') caveReader = csv.reader(cavetab) caveReader.next() # Strip out column headers @@ -69,7 +69,7 @@ def LoadCaveTab(): logging.info("Added area "+str(newArea.short_name)+"\n") area1626 = models.Area.objects.filter(short_name = '1626')[0] area1623 = models.Area.objects.filter(short_name = '1623')[0] - + counter=0 for line in caveReader : if line[Area] == 'nonexistent': @@ -82,11 +82,11 @@ def LoadCaveTab(): def addToArgs(CSVname, modelName): if line[CSVname]: args[modelName] = line[CSVname] - + def addToDefaultArgs(CSVname, modelName): #This has to do with the non-destructive import. These arguments will be passed as the "default" dictionary in a get_or_create if line[CSVname]: defaultArgs[modelName] = line[CSVname] - + # The attributes added using "addToArgs" will be used to look up an existing cave. Those added using "addToDefaultArgs" will not. addToArgs(KatasterNumber, "kataster_number") addToDefaultArgs(KatStatusCode, "kataster_code") @@ -121,7 +121,6 @@ def LoadCaveTab(): if line[header]: addToDefaultArgs(header,"description_file") break - #The following checks if this cave is non-public i.e. we don't have rights to display it online. #Noinfo was the name of the old password protected directory, so if it has that then we will @@ -148,7 +147,7 @@ def LoadCaveTab(): newCave.area.add(area1623) newCave.save() - + logging.info("Added area "+line[Area]+" to cave "+str(newCave)+"\n") if created and line[UnofficialName]: @@ -156,13 +155,13 @@ def LoadCaveTab(): newUnofficialName.save() logging.info("Added unofficial name "+str(newUnofficialName)+" to cave "+str(newCave)+"\n") - + if created and line[MultipleEntrances] == '' or \ line[MultipleEntrances] == 'entrance' or \ line[MultipleEntrances] == 'last entrance': args = {} - + if line[Entrances]: entrance_letter = line[Entrances] else: @@ -223,13 +222,14 @@ def LoadCaveTab(): logging.info("Added entrance "+str(newEntrance)+"\n") - + newCaveAndEntrance = models.CaveAndEntrance(cave = newCave, entrance = newEntrance, entrance_letter = entrance_letter) newCaveAndEntrance.save() - + logging.info("Added CaveAndEntrance "+str(newCaveAndEntrance)+"\n") - f = flatpages.models.EntranceRedirect(originalURL = line[AutogenFile], entrance = newEntrance) - f.save() + if line[AutogenFile] != "": + f = flatpages.models.EntranceRedirect(originalURL = line[AutogenFile], entrance = newEntrance) + f.save() # lookup function modelled on GetPersonExpeditionNameLookup @@ -245,9 +245,9 @@ def GetCaveLookup(): Gcavelookup[cave.kataster_number] = cave if cave.unofficial_number: Gcavelookup[cave.unofficial_number] = cave - + Gcavelookup["tunnocks"] = Gcavelookup["258"] Gcavelookup["hauchhole"] = Gcavelookup["234"] return Gcavelookup - - + + diff --git a/urls.py b/urls.py index 67c50ac..ea0ce0a 100644 --- a/urls.py +++ b/urls.py @@ -17,7 +17,7 @@ admin.autodiscover() actualurlpatterns = patterns('', - url(r'^$', views_other.frontpage, name="frontpage"), + url(r'^troggle$', views_other.frontpage, name="frontpage"), url(r'^todo/$', views_other.todo, name="todo"), url(r'^caves/?$', views_caves.caveindex, name="caveindex"),