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

Adding docstrings, deleting unused code

This commit is contained in:
2022-12-23 23:32:59 +00:00
parent 0e29cdd48c
commit 5bbb363f12
4 changed files with 32 additions and 39 deletions

View File

@@ -109,6 +109,8 @@ class SurvexBlockLookUpManager(models.Manager):
return block
class SurvexBlock(models.Model):
"""One begin..end block within a survex file. The basic elemt of a survey trip.
"""
objects = SurvexBlockLookUpManager()
name = models.CharField(max_length=100)
title = models.CharField(max_length=200)
@@ -141,15 +143,6 @@ class SurvexBlock(models.Model):
def isSurvexBlock(self): # Function used in templates
return True
def GetPersonroles(self):
'''
But apparently never used !?
'''
res = [ ]
for personrole in self.survexpersonrole_set.order_by('personexpedition'):
res.append({'person':personrole.personexpedition.person, 'expeditionyear':personrole.personexpedition.expedition.year})
return res
def DayIndex(self):
return list(self.expeditionday.survexblock_set.all()).index(self)
@@ -181,6 +174,8 @@ class Wallet(models.Model):
return urljoin(settings.URL_ROOT, reverse('singlewallet', kwargs={"path":re.sub("#", "%23", self.walletname)}))
def get_json(self):
"""Read the JSON file for the wallet and do stuff
"""
#jsonfile = Path(self.fpath, 'contents.json')
# Get from git repo instead
@@ -246,6 +241,8 @@ class Wallet(models.Model):
# Yes this is horribly, horribly inefficient, esp. for a page that have date, people and cave in it
def date(self):
"""Reads all the JSON data just to get the JSNON date.
"""
if self.walletdate:
return self.walletdate
if not self.get_json():
@@ -319,6 +316,8 @@ class Wallet(models.Model):
return result
def get_ticks(self):
"""Reads all the JSON data and sets the colour of the completion tick for each condition
"""
ticks = {}
waldata = self.get_json()
if not waldata:
@@ -438,6 +437,8 @@ class Wallet(models.Model):
return "[" + str(self.walletname) + " (Wallet)]"
class SingleScan(models.Model):
"""A single file holding an image. Could be raw notes, an elevation plot or whatever
"""
ffile = models.CharField(max_length=200)
name = models.CharField(max_length=200)
wallet = models.ForeignKey("Wallet", null=True,on_delete=models.SET_NULL)
@@ -449,9 +450,11 @@ class SingleScan(models.Model):
return urljoin(settings.URL_ROOT, reverse('scansingle', kwargs={"path":re.sub("#", "%23", self.wallet.walletname), "file":self.name}))
def __str__(self):
return "Survey Scan Image: " + str(self.name) + " in " + str(self.wallet)
return "Scan Image: " + str(self.name) + " in " + str(self.wallet)
class DrawingFile(models.Model):
"""A file holding a Therion (several types) or a Tunnel drawing
"""
dwgpath = models.CharField(max_length=200)
dwgname = models.CharField(max_length=200)
dwgwallets = models.ManyToManyField("Wallet") # implicitly links via folders to scans to SVX files