diff --git a/core/admin.py b/core/admin.py
index 1d8201f..43aa744 100644
--- a/core/admin.py
+++ b/core/admin.py
@@ -8,7 +8,6 @@ from troggle.core.models.survex import (
DrawingFile,
SingleScan,
SurvexBlock,
- SurvexDirectory,
SurvexFile,
SurvexPersonRole,
SurvexStation,
@@ -120,11 +119,11 @@ class SurvexFileAdmin(TroggleModelAdmin):
search_fields = ("path",)
-class SurvexDirectoryAdmin(TroggleModelAdmin):
- search_fields = (
- "path",
- "survexdirectory",
- )
+# class SurvexDirectoryAdmin(TroggleModelAdmin):
+ # search_fields = (
+ # "path",
+ # "survexdirectory",
+ # )
class DrawingFileAdmin(TroggleModelAdmin):
@@ -145,7 +144,7 @@ admin.site.register(DrawingFile, DrawingFileAdmin)
admin.site.register(Expedition)
admin.site.register(Person, PersonAdmin)
admin.site.register(SurvexPersonRole)
-admin.site.register(SurvexDirectory, SurvexDirectoryAdmin)
+#admin.site.register(SurvexDirectory, SurvexDirectoryAdmin)
admin.site.register(SurvexFile, SurvexFileAdmin)
admin.site.register(SurvexStation, SurvexStationAdmin)
admin.site.register(PersonExpedition, PersonExpeditionAdmin)
diff --git a/core/models/survex.py b/core/models/survex.py
index 2ca7412..84255d7 100644
--- a/core/models/survex.py
+++ b/core/models/survex.py
@@ -11,33 +11,33 @@ from django.urls import reverse
# from troggle.core.models.troggle import DataIssue # circular import. Hmm
-class SurvexDirectory(models.Model):
- """This relates a survexfile (identified by path) to the primary SurvexFile
- which is the 'head' of the survex tree for that cave.
- Surely this could just be a property of Cave ? No. Several subdirectories
- all relate to the same Cave.
+# class SurvexDirectory(models.Model):
+ # """This relates a survexfile (identified by path) to the primary SurvexFile
+ # which is the 'head' of the survex tree for that cave.
+ # Surely this could just be a property of Cave ? No. Several subdirectories
+ # all relate to the same Cave.
- But it *could* be a property of SurvexFile
- """
- path = models.CharField(max_length=200)
- primarysurvexfile = models.ForeignKey(
- "SurvexFile", related_name="primarysurvexfile", blank=True, null=True, on_delete=models.SET_NULL
- )
+ # But it *could* be a property of SurvexFile
+ # """
+ # path = models.CharField(max_length=200)
+ # primarysurvexfile = models.ForeignKey(
+ # "SurvexFile", related_name="primarysurvexfile", blank=True, null=True, on_delete=models.SET_NULL
+ # )
- class Meta:
- ordering = ("id",)
- verbose_name_plural = "Survex directories"
+ # class Meta:
+ # ordering = ("id",)
+ # verbose_name_plural = "Survex directories"
- def contents(self):
- return "[SvxDir:" + str(self.path) + " | Primary svx:" + str(self.primarysurvexfile.path) + ".svx ]"
+ # def contents(self):
+ # return "[SvxDir:" + str(self.path) + " | Primary svx:" + str(self.primarysurvexfile.path) + ".svx ]"
- def __str__(self):
- return "[SvxDir:" + str(self.path)+ "]"
+ # def __str__(self):
+ # return "[SvxDir:" + str(self.path)+ "]"
class SurvexFile(models.Model):
path = models.CharField(max_length=200)
- survexdirectory = models.ForeignKey("SurvexDirectory", blank=True, null=True, on_delete=models.SET_NULL)
+ #survexdirectory = models.ForeignKey("SurvexDirectory", blank=True, null=True, on_delete=models.SET_NULL)
primary = models.ForeignKey(
"SurvexFile", related_name="primarysurvex", blank=True, null=True, on_delete=models.SET_NULL
)
@@ -56,18 +56,18 @@ class SurvexFile(models.Model):
fname = Path(settings.SURVEX_DATA, self.path + ".svx")
return fname.is_file()
- def SetDirectory(self):
- dirpath = os.path.split(self.path)[0]
- # pointless search every time we import a survex file if we know there are no duplicates..
- # don't use this for initial import.
- survexdirectorylist = SurvexDirectory.objects.filter(cave=self.cave, path=dirpath)
- if survexdirectorylist:
- self.survexdirectory = survexdirectorylist[0]
- else:
- survexdirectory = SurvexDirectory(path=dirpath, cave=self.cave, primarysurvexfile=self)
- survexdirectory.save()
- self.survexdirectory = survexdirectory
- self.save()
+ # def SetDirectory(self):
+ # dirpath = os.path.split(self.path)[0]
+ # # pointless search every time we import a survex file if we know there are no duplicates..
+ # # don't use this for initial import.
+ # survexdirectorylist = SurvexDirectory.objects.filter(cave=self.cave, path=dirpath)
+ # if survexdirectorylist:
+ # self.survexdirectory = survexdirectorylist[0]
+ # else:
+ # survexdirectory = SurvexDirectory(path=dirpath, cave=self.cave, primarysurvexfile=self)
+ # survexdirectory.save()
+ # self.survexdirectory = survexdirectory
+ # self.save()
# Don't change from the default as that breaks troggle webpages and internal referencing!
# def __str__(self):
diff --git a/core/views/survex.py b/core/views/survex.py
index d916e56..7267414 100644
--- a/core/views/survex.py
+++ b/core/views/survex.py
@@ -18,7 +18,7 @@ from django.views.decorators.csrf import ensure_csrf_cookie
import troggle.settings as settings
from troggle.core.models.logbooks import LogbookEntry
from troggle.core.models.caves import Cave, GetCaveLookup
-from troggle.core.models.survex import SurvexFile, SurvexBlock, SurvexDirectory
+from troggle.core.models.survex import SurvexFile, SurvexBlock #, SurvexDirectory
from troggle.core.models.wallets import Wallet
from troggle.core.utils import only_commit
from troggle.parsers.survex import parse_one_file
@@ -654,27 +654,19 @@ def survexdir(request):
as the info it holds is always embedded in the survexFile path directories
"""
- sds = SurvexDirectory.objects.all() #.order_by("cave")
- for sd in sds:
- sd.matchbad = True
- if f"{sd.primarysurvexfile}".startswith(str(sd.path)):
- sd.matchbad = False
+ # sds = SurvexDirectory.objects.all() #.order_by("cave")
+ sds ={}
+ # for sd in sds:
+ # sd.matchbad = True
+ # if f"{sd.primarysurvexfile}".startswith(str(sd.path)):
+ # sd.matchbad = False
- sd.pathbad = True
- if Path(settings.SURVEX_DATA, f"{sd.primarysurvexfile}.svx").is_file():
- sd.pathbad = False
+ # sd.pathbad = True
+ # if Path(settings.SURVEX_DATA, f"{sd.primarysurvexfile}.svx").is_file():
+ # sd.pathbad = False
survexfiles = SurvexFile.objects.all().order_by("cave")
for f in survexfiles:
- 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
diff --git a/core/views/wallets_edit.py b/core/views/wallets_edit.py
index 580c6c1..9f9d02d 100644
--- a/core/views/wallets_edit.py
+++ b/core/views/wallets_edit.py
@@ -163,7 +163,7 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
# can happen if connecting a wallet to a survex file.. i think..
QSsvxfiles = SurvexFile.objects.filter(path=sxpath)
for s in QSsvxfiles:
- print(s.path, s.cave, s.survexdirectory)
+ print(s.path, s.cave, s.primary)
# QSsvxfiles[0] # dont' know how this happened, fix later..
except:
file_complaint = (
diff --git a/parsers/locations.py b/parsers/locations.py
index 8299a28..e2190c8 100644
--- a/parsers/locations.py
+++ b/parsers/locations.py
@@ -11,7 +11,7 @@ from pathlib import Path
import troggle.settings as settings
from troggle.core.models.caves import Cave, Entrance
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
diff --git a/parsers/survex.py b/parsers/survex.py
index e802a79..2339fbc 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -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()
diff --git a/templates/svxfile.html b/templates/svxfile.html
index 7d6dc14..8121c45 100644
--- a/templates/svxfile.html
+++ b/templates/svxfile.html
@@ -81,8 +81,8 @@ LOGMESSAGES
{% endif %}
underground survey length: {{svxlength|floatformat:2}} metres
-parent survex file {{survexfile.cave.survex_file}} for this cave
-survex directory {{survexfile.primary}}
+cave primary survexfile {{survexfile.cave.survex_file}}
+directory primary survexfile {{survexfile.primary}}
{% for sb in svxblocks %}
block {{sb}} has parent block {{sb.parent}}
{% empty %}