summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fixtures/expo_exped.json2
-rw-r--r--core/models/survex.py23
-rw-r--r--core/models/troggle.py42
3 files changed, 30 insertions, 37 deletions
diff --git a/core/fixtures/expo_exped.json b/core/fixtures/expo_exped.json
index 033411e..ebb5053 100644
--- a/core/fixtures/expo_exped.json
+++ b/core/fixtures/expo_exped.json
@@ -5,7 +5,7 @@
{"model": "core.personexpedition", "pk": 681, "fields":
{"new_since_parsing": false, "non_public": false,
"expedition": 44,
- "person": 250, "slugfield": null, "is_guest": false, "expo_committee_position": null,
+ "person": 250, "slugfield": null, "is_guest": false,
"nickname": "Mike"}},
{"model": "core.person", "pk": 250, "fields":
diff --git a/core/models/survex.py b/core/models/survex.py
index 3c6ba47..c2a68bf 100644
--- a/core/models/survex.py
+++ b/core/models/survex.py
@@ -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
diff --git a/core/models/troggle.py b/core/models/troggle.py
index f29483d..ca3df80 100644
--- a/core/models/troggle.py
+++ b/core/models/troggle.py
@@ -30,9 +30,9 @@ the django Object Relational Mapping (ORM).
There are more subclasses define in models_caves.py models_survex.py etc.
"""
-
-#This class is for adding fields and methods which all of our models will have.
class TroggleModel(models.Model):
+ """This class is for adding fields and methods which all of our models will have.
+ """
new_since_parsing = models.BooleanField(default=False, editable=False)
non_public = models.BooleanField(default=False)
def object_name(self):
@@ -98,14 +98,20 @@ class Expedition(TroggleModel):
return res
def day_min(self):
+ """First day of expedition
+ """
res = self.expeditionday_set.all()
return res and res[0] or None
def day_max(self):
+ """last day of expedition
+ """
res = self.expeditionday_set.all()
return res and res[len(res) - 1] or None
class ExpeditionDay(TroggleModel):
+ """Exists only so that we can get all logbook trips on this day
+ """
expedition = models.ForeignKey("Expedition",on_delete=models.CASCADE)
date = models.DateField()
@@ -113,6 +119,8 @@ class ExpeditionDay(TroggleModel):
ordering = ('date',)
def GetPersonTrip(self, personexpedition):
+ """returns all logbook trips for this expediton
+ """
personexpeditions = self.persontrip_set.filter(expeditionday=self)
return personexpeditions and personexpeditions[0] or None
@@ -144,6 +152,8 @@ class Person(TroggleModel):
def notability(self):
+ """This is actually recency: all recent cavers, weighted by number of expos
+ """
notability = Decimal(0)
max_expo_val = 0
@@ -156,6 +166,8 @@ class Person(TroggleModel):
return notability
def bisnotable(self):
+ """Boolean: is this person notable?
+ """
return self.notability() > Decimal(1)/Decimal(3)
def surveyedleglength(self):
@@ -174,31 +186,7 @@ class PersonExpedition(TroggleModel):
slugfield = models.SlugField(max_length=50,blank=True, null=True) # 2022 to be used in future
is_guest = models.BooleanField(default=False)
- COMMITTEE_CHOICES = (
- ('leader','Expo leader'),
- ('medical','Expo medical officer'),
- ('treasurer','Expo treasurer'),
- ('sponsorship','Expo sponsorship coordinator'),
- ('research','Expo research coordinator'),
- )
- expo_committee_position = models.CharField(blank=True,null=True,choices=COMMITTEE_CHOICES,max_length=200)
nickname = models.CharField(max_length=100,blank=True, null=True)
-
- def GetPersonroles(self):
- '''To do: excise the 'role' bit of this while retaining personrole
- which is used in some later logic
-
- But apparently never used !?
-
- '''
- res = [ ]
- for personrole in self.personrole_set.order_by('survexblock'):
- res.append({'date':personrole.survexblock.date, 'survexpath':personrole.survexblock.survexpath})
- # if res and res[-1]['survexpath'] == personrole.survexblock.survexpath:
- # res[-1]['roles'] += ", " + str(personrole.role)
- # else:
- # res.append({'date':personrole.survexblock.date, 'survexpath':personrole.survexblock.survexpath, 'roles':str(personrole.role)})
- return res
class Meta:
ordering = ('-expedition',)
@@ -219,6 +207,8 @@ class PersonExpedition(TroggleModel):
return urljoin(settings.URL_ROOT, reverse('personexpedition',kwargs={'first_name':self.person.first_name,'last_name':self.person.last_name,'year':self.expedition.year}))
def surveyedleglength(self):
+ """Survey length for this person on all survex trips on this expedition
+ """
survexblocks = [personrole.survexblock for personrole in self.survexpersonrole_set.all() ]
return sum([survexblock.legslength for survexblock in set(survexblocks)])