2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-14 15:37:19 +00:00

SurvexDirectory removed from active code

This commit is contained in:
2023-09-06 22:58:14 +03:00
parent 1ddb8248df
commit 69340db438
7 changed files with 64 additions and 73 deletions

View File

@@ -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):