forked from expo/troggle
person attribution of surveyed length working
This commit is contained in:
@@ -157,10 +157,15 @@ class Person(TroggleModel):
|
||||
|
||||
for personexpedition in self.personexpedition_set.all():
|
||||
if not personexpedition.is_guest:
|
||||
print((personexpedition.expedition.year))
|
||||
notability += Decimal(1) / (max_expo_val - int(personexpedition.expedition.year))
|
||||
return notability
|
||||
|
||||
def legslength(self):
|
||||
for personexpedition in self.personexpedition_set.all():
|
||||
if not personexpedition.is_guest:
|
||||
length += personexpedition.legslength
|
||||
return length
|
||||
|
||||
def bisnotable(self):
|
||||
return self.notability() > Decimal(1)/Decimal(3)
|
||||
|
||||
@@ -178,7 +183,8 @@ class PersonExpedition(TroggleModel):
|
||||
expedition = models.ForeignKey(Expedition,on_delete=models.CASCADE)
|
||||
person = models.ForeignKey(Person,on_delete=models.CASCADE)
|
||||
slugfield = models.SlugField(max_length=50,blank=True, null=True)
|
||||
|
||||
legslength = models.FloatField(null=True)
|
||||
|
||||
is_guest = models.BooleanField(default=False)
|
||||
COMMITTEE_CHOICES = (
|
||||
('leader','Expo leader'),
|
||||
@@ -218,7 +224,7 @@ 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):
|
||||
survexblocks = [personrole.survexblock for personrole in self.personrole_set.all() ]
|
||||
survexblocks = [personrole.survexblock for personrole in self.survexpersonrole_set.all() ]
|
||||
return sum([survexblock.legslength for survexblock in set(survexblocks)])
|
||||
|
||||
# would prefer to return actual person trips so we could link to first and last ones
|
||||
|
||||
@@ -125,9 +125,6 @@ class SurvexBlock(models.Model):
|
||||
# str(self.cave) + "]"
|
||||
def __str__(self):
|
||||
return self.name and str(self.name) or 'no name'
|
||||
|
||||
|
||||
|
||||
|
||||
def isSurvexBlock(self): # Function used in templates
|
||||
return True
|
||||
|
||||
@@ -108,6 +108,9 @@ def person(request, first_name='', last_name='', ):
|
||||
|
||||
|
||||
def GetPersonChronology(personexpedition):
|
||||
'''Horrible bug here whern ther eis more than one survex block per day, it duplicates the entry but gets it wrong
|
||||
Fortunately this is just the display on this page which is wroing, no bad calculations get into the database.
|
||||
'''
|
||||
res = { }
|
||||
for persontrip in personexpedition.persontrip_set.all():
|
||||
a = res.setdefault(persontrip.logbook_entry.date, { })
|
||||
@@ -119,14 +122,13 @@ def GetPersonChronology(personexpedition):
|
||||
|
||||
# build up the tables
|
||||
rdates = sorted(list(res.keys()))
|
||||
|
||||
|
||||
|
||||
res2 = [ ]
|
||||
for rdate in rdates:
|
||||
persontrips = res[rdate].get("persontrips", [])
|
||||
personroles = res[rdate].get("personroles", [])
|
||||
for n in range(max(len(persontrips), len(personroles))):
|
||||
res2.append(((n == 0 and rdate or "--"), (n < len(persontrips) and persontrips[n]), (n < len(personroles) and personroles[n])))
|
||||
persontrips = res[rdate].get("persontrips", [])
|
||||
personroles = res[rdate].get("personroles", [])
|
||||
for n in range(max(len(persontrips), len(personroles) )):
|
||||
res2.append(((n == 0 and rdate or "--"), (n < len(persontrips) and persontrips[n]), (n < len(personroles) and personroles[n]) ))
|
||||
|
||||
return res2
|
||||
|
||||
|
||||
@@ -348,10 +348,10 @@ def survexcaveslist(request):
|
||||
# parsing all the survex files of a single cave and showing that it's consistent and can find all the files and people
|
||||
# doesn't use recursion. just writes it twice
|
||||
|
||||
# currently produces title and blank page.. link test is "dates and explorers"
|
||||
# currently not showing Explorers or Titles. link test from SurvexFile page is "dates and explorers"
|
||||
def survexcavesingle(request, survex_cave):
|
||||
breload = False
|
||||
cave = Cave.objects.get(kataster_number=survex_cave)
|
||||
if breload:
|
||||
parsers.survex.ReloadSurvexCave(survex_cave)
|
||||
parsers.survex.ReloadSurvexCave(survex_cave) # does not exit now, needs re-writing to work.
|
||||
return render_to_response('svxcavesingle.html', {'settings': settings, "cave":cave })
|
||||
|
||||
Reference in New Issue
Block a user