2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-14 03:38:50 +00:00

Removing unneeded svx from parse list

This commit is contained in:
2023-09-08 01:26:01 +03:00
parent 5fc5c1285a
commit 28d1092956
6 changed files with 81 additions and 163 deletions

View File

@@ -10,31 +10,6 @@ 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.
# 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"
# def contents(self):
# return "[SvxDir:" + str(self.path) + " | Primary svx:" + str(self.primarysurvexfile.path) + ".svx ]"
# 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)
@@ -56,19 +31,6 @@ 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()
# Don't change from the default as that breaks troggle webpages and internal referencing!
# def __str__(self):
# return "[SurvexFile:"+str(self.path) + "-" + str(self.survexdirectory) + "-" + str(self.cave)+"]"
@@ -97,17 +59,6 @@ class SurvexStation(models.Model):
y = models.FloatField(blank=True, null=True)
z = models.FloatField(blank=True, null=True)
# def path(self):
# r = self.name
# b = self.block
# while True:
# if b.name:
# r = b.name + "." + r
# if b.parent:
# b = b.parent
# else:
# return r
class Meta:
ordering = ("id",)
@@ -119,7 +70,7 @@ class SurvexStation(models.Model):
import math
def utmToLatLng(zone, easting, northing, northernHemisphere=True):
def utmToLatLng(zone, easting, northing, northernHemisphere=True): # move this to utils.py ?
if not northernHemisphere:
northing = 10000000 - northing
@@ -206,10 +157,10 @@ class SurvexBlock(models.Model):
date = models.DateField(blank=True, null=True)
expedition = models.ForeignKey("Expedition", blank=True, null=True, on_delete=models.SET_NULL)
# if the survexfile object is deleted, then all teh suvex-blocks in it should be too,
# if the survexfile object is deleted, then all the suvex-blocks in it should be too,
# though a block can span more than one file...
survexfile = models.ForeignKey("SurvexFile", blank=True, null=True, on_delete=models.CASCADE)
survexpath = models.CharField(max_length=200) # the path for the survex stations
# survexpath = models.CharField(max_length=200, blank=True, null=True) No need for this anymore
scanswallet = models.ForeignKey(
"Wallet", null=True, on_delete=models.SET_NULL
@@ -221,9 +172,6 @@ class SurvexBlock(models.Model):
class Meta:
ordering = ("id",)
# def __str__(self):
# return "[SurvexBlock:" + str(self.name) + "-path:" + str(self.survexpath) + "-cave:" + str(self.cave) + "]"
def __str__(self):
return self.name and str(self.name) or "no_name-#" + str(self.id)
@@ -244,7 +192,6 @@ class SurvexBlock(models.Model):
if index not in range(0, mx):
print(f"DayIndex: More than {mx-1} SurvexBlock items on one day '{index}' {self}, restarting colour sequence.")
index = index % mx
# return list(self.survexblock_set.all()).index(self)
return index
@@ -253,7 +200,7 @@ class SurvexPersonRole(models.Model):
is deleted too
"""
survexblock = models.ForeignKey("SurvexBlock", on_delete=models.CASCADE)
# increasing levels of precision, Surely we only need survexblock and person now that we have no link to a logbook entry?
# increasing levels of precision, Surely we only need survexblock and (either person or personexpedition)?
personname = models.CharField(max_length=100)
person = models.ForeignKey("Person", blank=True, null=True, on_delete=models.CASCADE) # not needed
personexpedition = models.ForeignKey("PersonExpedition", blank=True, null=True, on_delete=models.SET_NULL)