forked from expo/troggle
Adding docstrings, deleting unused code
This commit is contained in:
@@ -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)])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user