2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-14 21:17:11 +00:00

Ongoing work to remove SurvexDirectory as a concept

This commit is contained in:
2023-09-05 23:14:48 +03:00
parent 8c721e905a
commit cc9f425fb5
4 changed files with 41 additions and 22 deletions

View File

@@ -1293,7 +1293,7 @@ class LoadingSurvex:
#try again
cave = IdentifyCave(headpath)
if cave:
newdirectory.cave = cave
# newdirectory.cave = cave # turns uout to be never used
newfile.cave = cave
# print(f"\n - New directory '{newdirectory}' for cave '{cave}'",file=sys.stderr)
@@ -2351,7 +2351,8 @@ def display_contents(blocks):
sfs = SurvexFile.objects.filter(survexblock=b)
for sf in sfs:
print(f" SF {sf}")
print(f" SD {sf.survexdirectory} {sf.survexdirectory.cave}")
# print(f" SD {sf.survexdirectory} {sf.survexdirectory.cave}")
print(f" SD {sf.survexdirectory} {sf.survexdirectory.path}")
ws = Wallet.objects.filter(survexblock=b)
for w in ws:
@@ -2499,7 +2500,8 @@ def MakeSurvexFileRoot():
fileroot = SurvexFile(path=settings.SURVEX_TOPNAME, cave=None)
fileroot.save()
directoryroot = SurvexDirectory(path=settings.SURVEX_DATA, cave=smk[0], primarysurvexfile=fileroot)
#directoryroot = SurvexDirectory(path=settings.SURVEX_DATA, cave=smk[0], primarysurvexfile=fileroot)
directoryroot = SurvexDirectory(path=settings.SURVEX_DATA, primarysurvexfile=fileroot)
# MariaDB doesn't like this hack. Complains about non-null cave_id EVEN THOUGH our model file says this is OK:
# cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.SET_NULL)
directoryroot.save()
@@ -2526,13 +2528,13 @@ def MakeFileRoot(fn):
fileroot.survexdirectory = None
if cave:
# But setting the SurvexDirectory does work !
# The fluffy stuff is because of errors in the original setting of survex directories
# which needs to be cleaned up..
for sd in cave.survexdirectory_set.filter(cave=cave):
if f"{sd.primarysurvexfile}".replace("caves-","").startswith(f"{sd.cave}"[:4]):
fileroot.survexdirectory = sd
# if cave:
# # But setting the SurvexDirectory does work !
# # The fluffy stuff is because of errors in the original setting of survex directories
# # which needs to be cleaned up..
# for sd in cave.survexdirectory_set.filter(cave=cave):
# if f"{sd.primarysurvexfile}".replace("caves-","").startswith(f"{sd.cave}"[:4]):
# fileroot.survexdirectory = sd
fileroot.save()
fileroot.cave = cave
print(f" - new fileroot {type(fileroot)} for {fn} with cave {cave} - {fileroot}")