diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-09-10 15:42:36 +0300 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-09-10 15:42:36 +0300 |
commit | ab79a43afa3b86181c3eaf7c327d54a78c18a8f4 (patch) | |
tree | d4a28808ec1d59c4aacadbdba1877194b673db58 /core/views/survex.py | |
parent | ad272fab3b313605f1c9e747a11a1b0d0d5a5473 (diff) | |
download | troggle-ab79a43afa3b86181c3eaf7c327d54a78c18a8f4.tar.gz troggle-ab79a43afa3b86181c3eaf7c327d54a78c18a8f4.tar.bz2 troggle-ab79a43afa3b86181c3eaf7c327d54a78c18a8f4.zip |
Removed class Area, use Cave.areacode Cave.subarea
Diffstat (limited to 'core/views/survex.py')
-rw-r--r-- | core/views/survex.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/core/views/survex.py b/core/views/survex.py index a69c5d3..b00aed0 100644 --- a/core/views/survex.py +++ b/core/views/survex.py @@ -574,15 +574,15 @@ def survexcaveslist(request): subdircaves = [] fnumlist = [] - for area in ["1623", "1626", "1624", "1627"]: - cavesdir = get_survexareapath(area) - arealist = sorted([(area, -int(re.match(r"\d*", f).group(0) or "0"), f) for f in os.listdir(cavesdir)]) + for areacode in ["1623", "1626", "1624", "1627"]: + cavesdir = get_survexareapath(areacode) + arealist = sorted([(areacode, -int(re.match(r"\d*", f).group(0) or "0"), f) for f in os.listdir(cavesdir)]) fnumlist += arealist # print(fnumlist) # go through the list and identify the contents of each cave directory - for area, num, cavedir in fnumlist: + for areacode, num, cavedir in fnumlist: # these have sub dirs /cucc/ /arge/ /old/ but that is no reason to hide them in this webpage # so these are now treated the same as 142 and 113 which also have a /cucc/ sub dir @@ -593,18 +593,17 @@ def survexcaveslist(request): # which usually but not always true. e.g. caves-1623/78/allkaese.svx not caves-1623/78/78.svx # which is why we now also pass through the cavedir - # Still fails for loutitohoehle etc even though this is set correctly when the pending cave is created - cavesdir = get_survexareapath(area) + cavesdir = get_survexareapath(areacode) gcavedir = os.path.join(cavesdir, cavedir) if os.path.isdir(gcavedir) and cavedir[0] != ".": subdirs, subsvx = identifycavedircontents(gcavedir) check_cave_registered( - area, cavedir + areacode, cavedir ) # should do this only once per database load or it will be slow survdirobj = [] for lsubsvx in subsvx: - survdirobj.append(("caves-" + area + "/" + cavedir + "/" + lsubsvx, lsubsvx)) + survdirobj.append(("caves-" + areacode + "/" + cavedir + "/" + lsubsvx, lsubsvx)) # caves with subdirectories if subdirs: @@ -614,7 +613,7 @@ def survexcaveslist(request): # assert not dsubdirs # handle case of empty sub directory lsurvdirobj = [] for lsubsvx in dsubsvx: - lsurvdirobj.append(("caves-" + area + "/" + cavedir + "/" + subdir + "/" + lsubsvx, lsubsvx)) + lsurvdirobj.append(("caves-" + areacode + "/" + cavedir + "/" + subdir + "/" + lsubsvx, lsubsvx)) if len(dsubsvx) >= 1: subsurvdirs.append( (subdir, lsurvdirobj[0], lsurvdirobj[0:]) @@ -683,7 +682,7 @@ def survexcavesingle(request, cave_shortname): else: return render(request, "errors/svxcaves404.html", {"settings": settings, "cave": cave_shortname}) -def check_cave_registered(area, survex_cave): +def check_cave_registered(areacode, survex_cave): """Checks whether a cave has been properly registered when it is found in the Loser repo This should really be called by databaseReset not here in a view Currently Caves are only registered if they are listed in :expoweb: settings.CAVEDESCRIPTIONS @@ -699,7 +698,7 @@ def check_cave_registered(area, survex_cave): except MultipleObjectsReturned: caves = Cave.objects.filter(kataster_number=survex_cave) for c in caves: - if str(c) == area + "-" + survex_cave: + if str(c) == areacode + "-" + survex_cave: return str(c) # just get the first that matches return None # many returned but none in correct area |