mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-15 08:27:10 +00:00
SurvexDirectory removed from active code
This commit is contained in:
@@ -10,7 +10,7 @@ from pathlib import Path
|
||||
import troggle.settings as settings
|
||||
from troggle.core.models.caves import Cave, Entrance, GetCaveLookup
|
||||
from troggle.core.models.logbooks import QM
|
||||
from troggle.core.models.survex import SurvexBlock, SurvexDirectory, SurvexFile, SurvexPersonRole, SurvexStation
|
||||
from troggle.core.models.survex import SurvexBlock, SurvexFile, SurvexPersonRole, SurvexStation
|
||||
from troggle.core.models.wallets import Wallet
|
||||
from troggle.core.models.troggle import DataIssue, Expedition
|
||||
from troggle.core.utils import chaosmonkey, get_process_memory
|
||||
@@ -2137,7 +2137,8 @@ def FindAndLoadSurvex(survexblockroot):
|
||||
svx_scan = LoadingSurvex()
|
||||
svx_scan.callcount = 0
|
||||
svx_scan.depthinclude = 0
|
||||
fullpathtotop = os.path.join(survexfileroot.survexdirectory.path, survexfileroot.path)
|
||||
#fullpathtotop = os.path.join(survexfileroot.survexdirectory.path, survexfileroot.path)
|
||||
fullpathtotop = str(Path(survexfileroot.path).parent / survexfileroot.path)
|
||||
|
||||
print(f" - RunSurvexIfNeeded cavern on '{fullpathtotop}'", file=sys.stderr)
|
||||
svx_scan.RunSurvexIfNeeded(fullpathtotop, fullpathtotop)
|
||||
@@ -2254,7 +2255,7 @@ def FindAndLoadSurvex(survexblockroot):
|
||||
omit_scan = LoadingSurvex()
|
||||
omit_scan.callcount = 0
|
||||
omit_scan.depthinclude = 0
|
||||
fullpathtotop = os.path.join(survexfileroot.survexdirectory.path, UNSEENS)
|
||||
fullpathtotop = str(Path(settings.SURVEX_DATA, UNSEENS))
|
||||
|
||||
# copy the list to prime the next pass through the files
|
||||
omit_scan.svxfileslist = svx_scan.svxfileslist[:]
|
||||
@@ -2363,7 +2364,7 @@ def display_contents(blocks):
|
||||
for sf in sfs:
|
||||
print(f" SF {sf}")
|
||||
# print(f" SD {sf.survexdirectory} {sf.survexdirectory.cave}")
|
||||
print(f" SD {sf.survexdirectory} {sf.survexdirectory.path}")
|
||||
#print(f" SD {sf.survexdirectory} {sf.survexdirectory.path}")
|
||||
|
||||
ws = Wallet.objects.filter(survexblock=b)
|
||||
for w in ws:
|
||||
@@ -2511,12 +2512,12 @@ def MakeSurvexFileRoot():
|
||||
|
||||
fileroot = SurvexFile(path=settings.SURVEX_TOPNAME, cave=None)
|
||||
fileroot.save()
|
||||
directoryroot = SurvexDirectory(path=settings.SURVEX_DATA, 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()
|
||||
fileroot.survexdirectory = directoryroot # i.e. SURVEX_DATA/SURVEX_TOPNAME
|
||||
fileroot.save() # mutually dependent objects need a double-save like this
|
||||
#directoryroot.save()
|
||||
#fileroot.survexdirectory = directoryroot # i.e. SURVEX_DATA/SURVEX_TOPNAME
|
||||
#fileroot.save() # mutually dependent objects need a double-save like this
|
||||
return fileroot
|
||||
|
||||
|
||||
@@ -2532,10 +2533,10 @@ def MakeFileRoot(fn):
|
||||
print(f" - Making/finding a new root survexfile for this import: {fn}")
|
||||
|
||||
fileroot = SurvexFile(path=fn, cave=cave)
|
||||
try:
|
||||
fileroot.survexdirectory = SurvexDirectory.objects.get(id=1) # default
|
||||
except:
|
||||
fileroot.survexdirectory = None
|
||||
# try:
|
||||
# fileroot.survexdirectory = SurvexDirectory.objects.get(id=1) # default
|
||||
# except:
|
||||
# fileroot.survexdirectory = None
|
||||
|
||||
|
||||
# if cave:
|
||||
@@ -2566,7 +2567,6 @@ def LoadSurvexBlocks():
|
||||
# https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.on_delete
|
||||
SurvexBlock.objects.all().delete()
|
||||
SurvexFile.objects.all().delete()
|
||||
SurvexDirectory.objects.all().delete()
|
||||
SurvexPersonRole.objects.all().delete()
|
||||
SurvexStation.objects.all().delete()
|
||||
mem1 = get_process_memory()
|
||||
|
||||
Reference in New Issue
Block a user