mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-02-18 05:00:13 +00:00
SurvexDirectory removed from active code
This commit is contained in:
parent
1ddb8248df
commit
69340db438
@ -8,7 +8,6 @@ from troggle.core.models.survex import (
|
|||||||
DrawingFile,
|
DrawingFile,
|
||||||
SingleScan,
|
SingleScan,
|
||||||
SurvexBlock,
|
SurvexBlock,
|
||||||
SurvexDirectory,
|
|
||||||
SurvexFile,
|
SurvexFile,
|
||||||
SurvexPersonRole,
|
SurvexPersonRole,
|
||||||
SurvexStation,
|
SurvexStation,
|
||||||
@ -120,11 +119,11 @@ class SurvexFileAdmin(TroggleModelAdmin):
|
|||||||
search_fields = ("path",)
|
search_fields = ("path",)
|
||||||
|
|
||||||
|
|
||||||
class SurvexDirectoryAdmin(TroggleModelAdmin):
|
# class SurvexDirectoryAdmin(TroggleModelAdmin):
|
||||||
search_fields = (
|
# search_fields = (
|
||||||
"path",
|
# "path",
|
||||||
"survexdirectory",
|
# "survexdirectory",
|
||||||
)
|
# )
|
||||||
|
|
||||||
|
|
||||||
class DrawingFileAdmin(TroggleModelAdmin):
|
class DrawingFileAdmin(TroggleModelAdmin):
|
||||||
@ -145,7 +144,7 @@ admin.site.register(DrawingFile, DrawingFileAdmin)
|
|||||||
admin.site.register(Expedition)
|
admin.site.register(Expedition)
|
||||||
admin.site.register(Person, PersonAdmin)
|
admin.site.register(Person, PersonAdmin)
|
||||||
admin.site.register(SurvexPersonRole)
|
admin.site.register(SurvexPersonRole)
|
||||||
admin.site.register(SurvexDirectory, SurvexDirectoryAdmin)
|
#admin.site.register(SurvexDirectory, SurvexDirectoryAdmin)
|
||||||
admin.site.register(SurvexFile, SurvexFileAdmin)
|
admin.site.register(SurvexFile, SurvexFileAdmin)
|
||||||
admin.site.register(SurvexStation, SurvexStationAdmin)
|
admin.site.register(SurvexStation, SurvexStationAdmin)
|
||||||
admin.site.register(PersonExpedition, PersonExpeditionAdmin)
|
admin.site.register(PersonExpedition, PersonExpeditionAdmin)
|
||||||
|
@ -11,33 +11,33 @@ from django.urls import reverse
|
|||||||
# from troggle.core.models.troggle import DataIssue # circular import. Hmm
|
# from troggle.core.models.troggle import DataIssue # circular import. Hmm
|
||||||
|
|
||||||
|
|
||||||
class SurvexDirectory(models.Model):
|
# class SurvexDirectory(models.Model):
|
||||||
"""This relates a survexfile (identified by path) to the primary SurvexFile
|
# """This relates a survexfile (identified by path) to the primary SurvexFile
|
||||||
which is the 'head' of the survex tree for that cave.
|
# which is the 'head' of the survex tree for that cave.
|
||||||
Surely this could just be a property of Cave ? No. Several subdirectories
|
# Surely this could just be a property of Cave ? No. Several subdirectories
|
||||||
all relate to the same Cave.
|
# all relate to the same Cave.
|
||||||
|
|
||||||
But it *could* be a property of SurvexFile
|
# But it *could* be a property of SurvexFile
|
||||||
"""
|
# """
|
||||||
path = models.CharField(max_length=200)
|
# path = models.CharField(max_length=200)
|
||||||
primarysurvexfile = models.ForeignKey(
|
# primarysurvexfile = models.ForeignKey(
|
||||||
"SurvexFile", related_name="primarysurvexfile", blank=True, null=True, on_delete=models.SET_NULL
|
# "SurvexFile", related_name="primarysurvexfile", blank=True, null=True, on_delete=models.SET_NULL
|
||||||
)
|
# )
|
||||||
|
|
||||||
class Meta:
|
# class Meta:
|
||||||
ordering = ("id",)
|
# ordering = ("id",)
|
||||||
verbose_name_plural = "Survex directories"
|
# verbose_name_plural = "Survex directories"
|
||||||
|
|
||||||
def contents(self):
|
# def contents(self):
|
||||||
return "[SvxDir:" + str(self.path) + " | Primary svx:" + str(self.primarysurvexfile.path) + ".svx ]"
|
# return "[SvxDir:" + str(self.path) + " | Primary svx:" + str(self.primarysurvexfile.path) + ".svx ]"
|
||||||
|
|
||||||
def __str__(self):
|
# def __str__(self):
|
||||||
return "[SvxDir:" + str(self.path)+ "]"
|
# return "[SvxDir:" + str(self.path)+ "]"
|
||||||
|
|
||||||
|
|
||||||
class SurvexFile(models.Model):
|
class SurvexFile(models.Model):
|
||||||
path = models.CharField(max_length=200)
|
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(
|
primary = models.ForeignKey(
|
||||||
"SurvexFile", related_name="primarysurvex", blank=True, null=True, on_delete=models.SET_NULL
|
"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")
|
fname = Path(settings.SURVEX_DATA, self.path + ".svx")
|
||||||
return fname.is_file()
|
return fname.is_file()
|
||||||
|
|
||||||
def SetDirectory(self):
|
# def SetDirectory(self):
|
||||||
dirpath = os.path.split(self.path)[0]
|
# dirpath = os.path.split(self.path)[0]
|
||||||
# pointless search every time we import a survex file if we know there are no duplicates..
|
# # pointless search every time we import a survex file if we know there are no duplicates..
|
||||||
# don't use this for initial import.
|
# # don't use this for initial import.
|
||||||
survexdirectorylist = SurvexDirectory.objects.filter(cave=self.cave, path=dirpath)
|
# survexdirectorylist = SurvexDirectory.objects.filter(cave=self.cave, path=dirpath)
|
||||||
if survexdirectorylist:
|
# if survexdirectorylist:
|
||||||
self.survexdirectory = survexdirectorylist[0]
|
# self.survexdirectory = survexdirectorylist[0]
|
||||||
else:
|
# else:
|
||||||
survexdirectory = SurvexDirectory(path=dirpath, cave=self.cave, primarysurvexfile=self)
|
# survexdirectory = SurvexDirectory(path=dirpath, cave=self.cave, primarysurvexfile=self)
|
||||||
survexdirectory.save()
|
# survexdirectory.save()
|
||||||
self.survexdirectory = survexdirectory
|
# self.survexdirectory = survexdirectory
|
||||||
self.save()
|
# self.save()
|
||||||
|
|
||||||
# Don't change from the default as that breaks troggle webpages and internal referencing!
|
# Don't change from the default as that breaks troggle webpages and internal referencing!
|
||||||
# def __str__(self):
|
# def __str__(self):
|
||||||
|
@ -18,7 +18,7 @@ from django.views.decorators.csrf import ensure_csrf_cookie
|
|||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
from troggle.core.models.logbooks import LogbookEntry
|
from troggle.core.models.logbooks import LogbookEntry
|
||||||
from troggle.core.models.caves import Cave, GetCaveLookup
|
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.models.wallets import Wallet
|
||||||
from troggle.core.utils import only_commit
|
from troggle.core.utils import only_commit
|
||||||
from troggle.parsers.survex import parse_one_file
|
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
|
as the info it holds is always embedded in the survexFile path directories
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sds = SurvexDirectory.objects.all() #.order_by("cave")
|
# sds = SurvexDirectory.objects.all() #.order_by("cave")
|
||||||
for sd in sds:
|
sds ={}
|
||||||
sd.matchbad = True
|
# for sd in sds:
|
||||||
if f"{sd.primarysurvexfile}".startswith(str(sd.path)):
|
# sd.matchbad = True
|
||||||
sd.matchbad = False
|
# if f"{sd.primarysurvexfile}".startswith(str(sd.path)):
|
||||||
|
# sd.matchbad = False
|
||||||
|
|
||||||
sd.pathbad = True
|
# sd.pathbad = True
|
||||||
if Path(settings.SURVEX_DATA, f"{sd.primarysurvexfile}.svx").is_file():
|
# if Path(settings.SURVEX_DATA, f"{sd.primarysurvexfile}.svx").is_file():
|
||||||
sd.pathbad = False
|
# sd.pathbad = False
|
||||||
|
|
||||||
survexfiles = SurvexFile.objects.all().order_by("cave")
|
survexfiles = SurvexFile.objects.all().order_by("cave")
|
||||||
for f in survexfiles:
|
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
|
f.pathbad = True
|
||||||
if Path(settings.SURVEX_DATA, f"{f.path}.svx").is_file():
|
if Path(settings.SURVEX_DATA, f"{f.path}.svx").is_file():
|
||||||
f.pathbad = False
|
f.pathbad = False
|
||||||
|
@ -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..
|
# can happen if connecting a wallet to a survex file.. i think..
|
||||||
QSsvxfiles = SurvexFile.objects.filter(path=sxpath)
|
QSsvxfiles = SurvexFile.objects.filter(path=sxpath)
|
||||||
for s in QSsvxfiles:
|
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..
|
# QSsvxfiles[0] # dont' know how this happened, fix later..
|
||||||
except:
|
except:
|
||||||
file_complaint = (
|
file_complaint = (
|
||||||
|
@ -11,7 +11,7 @@ from pathlib import Path
|
|||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
from troggle.core.models.caves import Cave, Entrance
|
from troggle.core.models.caves import Cave, Entrance
|
||||||
from troggle.core.models.logbooks import QM
|
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.wallets import Wallet
|
||||||
from troggle.core.models.troggle import DataIssue, Expedition
|
from troggle.core.models.troggle import DataIssue, Expedition
|
||||||
from troggle.core.utils import chaosmonkey, get_process_memory
|
from troggle.core.utils import chaosmonkey, get_process_memory
|
||||||
|
@ -10,7 +10,7 @@ from pathlib import Path
|
|||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
from troggle.core.models.caves import Cave, Entrance, GetCaveLookup
|
from troggle.core.models.caves import Cave, Entrance, GetCaveLookup
|
||||||
from troggle.core.models.logbooks import QM
|
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.wallets import Wallet
|
||||||
from troggle.core.models.troggle import DataIssue, Expedition
|
from troggle.core.models.troggle import DataIssue, Expedition
|
||||||
from troggle.core.utils import chaosmonkey, get_process_memory
|
from troggle.core.utils import chaosmonkey, get_process_memory
|
||||||
@ -2137,7 +2137,8 @@ def FindAndLoadSurvex(survexblockroot):
|
|||||||
svx_scan = LoadingSurvex()
|
svx_scan = LoadingSurvex()
|
||||||
svx_scan.callcount = 0
|
svx_scan.callcount = 0
|
||||||
svx_scan.depthinclude = 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)
|
print(f" - RunSurvexIfNeeded cavern on '{fullpathtotop}'", file=sys.stderr)
|
||||||
svx_scan.RunSurvexIfNeeded(fullpathtotop, fullpathtotop)
|
svx_scan.RunSurvexIfNeeded(fullpathtotop, fullpathtotop)
|
||||||
@ -2254,7 +2255,7 @@ def FindAndLoadSurvex(survexblockroot):
|
|||||||
omit_scan = LoadingSurvex()
|
omit_scan = LoadingSurvex()
|
||||||
omit_scan.callcount = 0
|
omit_scan.callcount = 0
|
||||||
omit_scan.depthinclude = 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
|
# copy the list to prime the next pass through the files
|
||||||
omit_scan.svxfileslist = svx_scan.svxfileslist[:]
|
omit_scan.svxfileslist = svx_scan.svxfileslist[:]
|
||||||
@ -2363,7 +2364,7 @@ def display_contents(blocks):
|
|||||||
for sf in sfs:
|
for sf in sfs:
|
||||||
print(f" SF {sf}")
|
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}")
|
#print(f" SD {sf.survexdirectory} {sf.survexdirectory.path}")
|
||||||
|
|
||||||
ws = Wallet.objects.filter(survexblock=b)
|
ws = Wallet.objects.filter(survexblock=b)
|
||||||
for w in ws:
|
for w in ws:
|
||||||
@ -2511,12 +2512,12 @@ def MakeSurvexFileRoot():
|
|||||||
|
|
||||||
fileroot = SurvexFile(path=settings.SURVEX_TOPNAME, cave=None)
|
fileroot = SurvexFile(path=settings.SURVEX_TOPNAME, cave=None)
|
||||||
fileroot.save()
|
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:
|
# 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)
|
# cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.SET_NULL)
|
||||||
directoryroot.save()
|
#directoryroot.save()
|
||||||
fileroot.survexdirectory = directoryroot # i.e. SURVEX_DATA/SURVEX_TOPNAME
|
#fileroot.survexdirectory = directoryroot # i.e. SURVEX_DATA/SURVEX_TOPNAME
|
||||||
fileroot.save() # mutually dependent objects need a double-save like this
|
#fileroot.save() # mutually dependent objects need a double-save like this
|
||||||
return fileroot
|
return fileroot
|
||||||
|
|
||||||
|
|
||||||
@ -2532,10 +2533,10 @@ def MakeFileRoot(fn):
|
|||||||
print(f" - Making/finding a new root survexfile for this import: {fn}")
|
print(f" - Making/finding a new root survexfile for this import: {fn}")
|
||||||
|
|
||||||
fileroot = SurvexFile(path=fn, cave=cave)
|
fileroot = SurvexFile(path=fn, cave=cave)
|
||||||
try:
|
# try:
|
||||||
fileroot.survexdirectory = SurvexDirectory.objects.get(id=1) # default
|
# fileroot.survexdirectory = SurvexDirectory.objects.get(id=1) # default
|
||||||
except:
|
# except:
|
||||||
fileroot.survexdirectory = None
|
# fileroot.survexdirectory = None
|
||||||
|
|
||||||
|
|
||||||
# if cave:
|
# if cave:
|
||||||
@ -2566,7 +2567,6 @@ def LoadSurvexBlocks():
|
|||||||
# https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.on_delete
|
# https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.on_delete
|
||||||
SurvexBlock.objects.all().delete()
|
SurvexBlock.objects.all().delete()
|
||||||
SurvexFile.objects.all().delete()
|
SurvexFile.objects.all().delete()
|
||||||
SurvexDirectory.objects.all().delete()
|
|
||||||
SurvexPersonRole.objects.all().delete()
|
SurvexPersonRole.objects.all().delete()
|
||||||
SurvexStation.objects.all().delete()
|
SurvexStation.objects.all().delete()
|
||||||
mem1 = get_process_memory()
|
mem1 = get_process_memory()
|
||||||
|
@ -81,8 +81,8 @@ LOGMESSAGES
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
underground survey length: {{svxlength|floatformat:2}} metres<br />
|
underground survey length: {{svxlength|floatformat:2}} metres<br />
|
||||||
parent survex file <a href="/survexfile/{{ survexfile.cave.survex_file }}">{{survexfile.cave.survex_file}}</a> for this cave <br>
|
cave primary survexfile <a href="/survexfile/{{ survexfile.cave.survex_file }}">{{survexfile.cave.survex_file}}</a> <br>
|
||||||
survex directory <a href="/survexfile/{{survexfile.primary}}.svx">{{survexfile.primary}}</a> <br />
|
directory primary survexfile <a href="/survexfile/{{survexfile.primary}}.svx">{{survexfile.primary}}</a> <br />
|
||||||
{% for sb in svxblocks %}
|
{% for sb in svxblocks %}
|
||||||
block <em>{{sb}}</em> has parent block <em>{{sb.parent}}</em><br />
|
block <em>{{sb}}</em> has parent block <em>{{sb.parent}}</em><br />
|
||||||
{% empty %}
|
{% empty %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user