summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/TESTS/tests_caves.py13
-rw-r--r--core/models/caves.py4
-rw-r--r--core/models/survex.py38
-rw-r--r--core/models/troggle.py15
-rw-r--r--core/views/logbooks.py7
5 files changed, 56 insertions, 21 deletions
diff --git a/core/TESTS/tests_caves.py b/core/TESTS/tests_caves.py
index 0ff0f12..8a08c71 100644
--- a/core/TESTS/tests_caves.py
+++ b/core/TESTS/tests_caves.py
@@ -58,6 +58,19 @@ class FixtureTests(TestCase):
self.assertIsNotNone(phmatch, "In fixture-loaded cave, failed to find expected text: '" + ph +"'")
+ def test_page_personexpedition(self):
+ response = self.client.get('/personexpedition/MichaelSargent/2019')
+ content = response.content.decode()
+ # with open('testresponse.html','w') as tr:
+ # tr.writelines(content)
+ self.assertEqual(response.status_code, 200)
+ for ph in [ r'Michael Sargent',
+ r'Table of all trips and surveys aligned by date' ]:
+ phmatch = re.search(ph, content)
+ self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
+ # Need to add a fixture so that this actually has a logbook entry and a trip/svx in it.
+
+
class FixturePageTests(TestCase):
'''Currently nothing that runs troggle works - all do 404. Must be something in a template rendering crash?
ordinary pages are OK, and expopages and expofiles are OK, even though they come through troggle.
diff --git a/core/models/caves.py b/core/models/caves.py
index b3b3a59..259854d 100644
--- a/core/models/caves.py
+++ b/core/models/caves.py
@@ -432,6 +432,10 @@ class LogbookEntry(TroggleModel):
# #return super(LogbookEntry, self).__init__(*args, **kwargs) # works in py3.5
# #return TroggleModel.__init__(*args, **kwargs) # fails in py3.5, runtime fail in 3.8
+ def cave(self): # Why didn't he just make this a foreign key to Cave ? Replaces __egtattrribute__ sillyness.
+ c = CaveSlug.objects.get(slug=self.cave_slug, primary=True).cave
+ return c
+
def isLogbookEntry(self): # Function used in templates
return True
diff --git a/core/models/survex.py b/core/models/survex.py
index b30f231..9d2b17e 100644
--- a/core/models/survex.py
+++ b/core/models/survex.py
@@ -134,12 +134,18 @@ class SurvexBlock(models.Model):
return 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.survexpersonrole_set.order_by('personexpedition'):
- if res and res[-1]['person'] == personrole.personexpedition.person:
- res[-1]['roles'] += ", " + str(personrole.nrole)
- else:
- res.append({'person':personrole.personexpedition.person, 'expeditionyear':personrole.personexpedition.expedition.year, 'roles':str(personrole.nrole)})
+ # if res and res[-1]['person'] == personrole.personexpedition.person:
+ # res[-1]['roles'] += ", " + str(personrole.nrole)
+ # else:
+ # res.append({'person':personrole.personexpedition.person, 'expeditionyear':personrole.personexpedition.expedition.year, 'roles':str(personrole.nrole)})
+ res.append({'person':personrole.personexpedition.person, 'expeditionyear':personrole.personexpedition.expedition.year})
return res
def DayIndex(self):
@@ -147,21 +153,21 @@ class SurvexBlock(models.Model):
#
# member of a SurvexBlock
#
-ROLE_CHOICES = (
- ('insts','Instruments'),
- ('dog','Other'),
- ('notes','Notes'),
- ('pics','Pictures'),
- ('tape','Tape measure'),
- ('useless','Useless'),
- ('helper','Helper'),
- ('disto','Disto'),
- ('consultant','Consultant'),
- )
+# ROLE_CHOICES = (
+ # ('insts','Instruments'),
+ # ('dog','Other'),
+ # ('notes','Notes'),
+ # ('pics','Pictures'),
+ # ('tape','Tape measure'),
+ # ('useless','Useless'),
+ # ('helper','Helper'),
+ # ('disto','Disto'),
+ # ('consultant','Consultant'),
+ # )
class SurvexPersonRole(models.Model):
survexblock = models.ForeignKey('SurvexBlock',on_delete=models.CASCADE)
- nrole = models.CharField(choices=ROLE_CHOICES, max_length=200, blank=True, null=True)
+# nrole = models.CharField(choices=ROLE_CHOICES, max_length=200, blank=True, null=True)
# increasing levels of precision
personname = models.CharField(max_length=100)
person = models.ForeignKey('Person', blank=True, null=True,on_delete=models.SET_NULL)
diff --git a/core/models/troggle.py b/core/models/troggle.py
index 10c982c..f9558ff 100644
--- a/core/models/troggle.py
+++ b/core/models/troggle.py
@@ -184,12 +184,19 @@ class PersonExpedition(TroggleModel):
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'):
- 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)})
+ 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:
diff --git a/core/views/logbooks.py b/core/views/logbooks.py
index 82dbf61..3181a33 100644
--- a/core/views/logbooks.py
+++ b/core/views/logbooks.py
@@ -141,8 +141,11 @@ def person(request, first_name='', last_name='', ):
def get_person_chronology(personexpedition):
- '''Horrible bug here whern there is more than one survex block per day, it duplicates the entry but gets it wrong
+ '''Horrible bug here when there is 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.
+
+ This is just a nasty convoluted way of trying the make the template do more work than it is sensible to ask it to do.
+ Rewrite more simply with the login in the python, not in Django template language (you bastard Curtis).
'''
res = { }
for persontrip in personexpedition.persontrip_set.all():
@@ -171,6 +174,8 @@ def personexpedition(request, first_name='', last_name='', year=''):
this_expedition = Expedition.objects.get(year=year)
personexpedition = person.personexpedition_set.get(expedition=this_expedition)
personchronology = get_person_chronology(personexpedition)
+ #for pc in personchronology:
+ #print(pc)
return render(request,'personexpedition.html', {'personexpedition': personexpedition, 'personchronology':personchronology})