diff options
Diffstat (limited to 'core/views/survex.py')
-rw-r--r-- | core/views/survex.py | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/core/views/survex.py b/core/views/survex.py index 10ebbd0..d916e56 100644 --- a/core/views/survex.py +++ b/core/views/survex.py @@ -30,13 +30,12 @@ but also displays data on a cave or caves when there is ambiguity todo = """- survexcavesingle is not properly producing any result for Homecoming, 1626-359, 2018-dm-07 even though there are dozens of surveys. -- REFACTOR the very impenetrable code for scanningsubdirectories, replace with modern python pathlib - - filter out the non-public caves from display UNLESS LOGGED IN - Never actual uses the object for the survexfile, works entirely from the filepath! Make it check and validate -- the primary survex file in each cave directory should be in a configuration, not buried in the code... +- the primary survex file in each cave directory should be in a configuration? not buried in the code + and implicit in the order of *import statements ? - Save and re-parse an edited survexfile which already exists in the db, and update all its dependencies (work in progress) @@ -145,7 +144,7 @@ def get_survexfile(filename): print("BUG - to be fixed in the survex parser - not critical..") print(f"Number of SurvexFile objects found: {len(refs)}") for s in refs: - print (s.path, s.survexdirectory, s.cave) + print (s.path, s.primary, s.cave) # print(type(survexfile), filename) return survexfile @@ -369,6 +368,7 @@ def svx(request, survex_file): # collect all the survex blocks which actually have a valid date if svxfile: + #dirparent = Path(svxfile.primary.path).parent has_3d = (Path(SVXPATH) / Path(survex_file + ".3d")).is_file() try: svxblocks = svxfile.survexblock_set.filter(date__isnull=False).order_by('date') @@ -405,6 +405,7 @@ def svx(request, survex_file): "logmessage": logmessage, "form": form, "events": events, + #"dirparent": dirparent, } if outputtype == "ajax": # used by CodeMirror ajax I think @@ -649,7 +650,7 @@ def survexcaveslist(request): def survexdir(request): """report on all the SurvexDirectory objects We are trying to find out how mismatches have crept in. - and whether the whole SUrvexDirectory class is actually redundant + and whether the whole SurvexDirectory class is actually redundant as the info it holds is always embedded in the survexFile path directories """ @@ -665,28 +666,28 @@ def survexdir(request): survexfiles = SurvexFile.objects.all().order_by("cave") for f in survexfiles: - f.matchbad = True - if f"{f.path}".startswith(str(f.survexdirectory.path)): - f.matchbad = False - f.primarybad = True - if f.primary: - f.pathparent = Path(f.primary.path).parent - if str(f.survexdirectory.path) == str(f.pathparent): - f.primarybad = False + if f.survexdirectory: + f.matchbad = True + if f"{f.path}".startswith(str(f.survexdirectory.path)): + f.matchbad = False + f.primarybad = True + if f.primary: + f.pathparent = Path(f.primary.path).parent + if str(f.survexdirectory.path) == str(f.pathparent): + f.primarybad = False f.pathbad = True if Path(settings.SURVEX_DATA, f"{f.path}.svx").is_file(): f.pathbad = False return render(request, "survexdir.html", {"survexdirs": sds, "survexfiles": survexfiles}) -def get_directories(cave): +def get_primaries(cave): sds = [] sfs = cave.survexfile_set.all() for sf in sfs: - sds.append(sf.survexdirectory) + sp = sf.primary # survexfile object + sds.append(sp) return list(set(sds)) - - def survexcavesingle(request, cave_shortname): """parsing all the survex files of a single cave and showing that it's consistent and can find all the files and people. @@ -696,7 +697,7 @@ def survexcavesingle(request, cave_shortname): if cave_shortname in Gcavelookup: cave = Gcavelookup[cave_shortname] # print(f"survexcavesingle {cave_shortname=} => {cave=}") - cave.sds = get_directories(cave) + cave.sds = get_primaries(cave) return render(request, "svxcaves.html", {"settings": settings, "caves": [cave]}) else: # not a cave or an ambiguous short name, e.g. "122" @@ -708,7 +709,7 @@ def survexcavesingle(request, cave_shortname): if len(caves) > 0: # print(f"many {cave_shortname=} => {caves=}") for cave in caves: - cave.sds = get_directories(cave) + cave.sds = get_primaries(cave) # print(f"many {cave=} => {cave.sds=}") return render(request, "svxcaves.html", {"settings": settings, "caves": caves}) else: |