From 69340db43874d1ed9a2c4d27595c090016dc4c55 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 6 Sep 2023 22:58:14 +0300 Subject: SurvexDirectory removed from active code --- core/models/survex.py | 62 +++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'core/models/survex.py') 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): -- cgit v1.2.3