mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +00:00
chipping away bug in personexpedition, remove role
This commit is contained in:
parent
e5cf1b5289
commit
03a5f5989e
@ -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.
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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})
|
||||
|
||||
|
||||
|
@ -26,6 +26,11 @@ It does also NOT scan the Loser repo for all the svx files - though it should !
|
||||
todo = '''Also walk the entire tree in the :loser: repo looking for unconnected survex files
|
||||
- add them to the system so that they can be reported-on
|
||||
- produce a parser report and create a troggle report page (some are OK, e.g. futility series replaced by ARGE survey in 115)
|
||||
|
||||
- If you look at e.g. http://expo.survex.com/survexfile/161#T_caves-1623/161/lhr/alllhr
|
||||
you will see than have the team members are recognised by this parser, but not recognised by the
|
||||
wider troggle system (the name is not a hyperlink) - apparently randomly.
|
||||
GetPersonExpeditionNameLookup() needs to be fixed.
|
||||
'''
|
||||
survexblockroot = None
|
||||
ROOTBLOCK = "rootblock"
|
||||
@ -201,7 +206,8 @@ class LoadingSurvex():
|
||||
personexpedition = survexblock.expedition and GetPersonExpeditionNameLookup(survexblock.expedition).get(tm.lower())
|
||||
if (personexpedition, tm) not in teammembers:
|
||||
teammembers.append((personexpedition, tm))
|
||||
personrole = SurvexPersonRole(survexblock=survexblock, nrole=mteammember.group(1).lower(), personexpedition=personexpedition, personname=tm)
|
||||
personrole = SurvexPersonRole(survexblock=survexblock, personexpedition=personexpedition, personname=tm)
|
||||
# personrole = SurvexPersonRole(survexblock=survexblock, nrole=mteammember.group(1).lower(), personexpedition=personexpedition, personname=tm)
|
||||
personrole.save()
|
||||
personrole.expeditionday = survexblock.expeditionday
|
||||
if personexpedition:
|
||||
|
@ -1,7 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% load survex_markup %}
|
||||
|
||||
{% block title %}All Survey scans folders (wallets){% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@ -1,7 +1,11 @@
|
||||
{% extends "base.html" %}
|
||||
{% load wiki_markup %}
|
||||
{% block title %}Person {{personexpedition.person|wiki_to_html_short}} for {{personexpedition.expedition}}{% endblock %}
|
||||
|
||||
<!-- I am removing 'role' as a thing that troggle cares about.
|
||||
This will remove the Class Role (but keep PersonRole)
|
||||
and 1 foreign key role
|
||||
If anyone really cares, they can always look in the original survex file
|
||||
-->
|
||||
|
||||
{% block content %}
|
||||
<h1>
|
||||
@ -25,25 +29,28 @@
|
||||
<h3>Table of all trips and surveys aligned by date</h3>
|
||||
<div>
|
||||
<table class="survexcontibutions">
|
||||
<tr><th>Date</th><th colspan="2">Trips</th><th colspan="3">Surveys</th></tr>
|
||||
<!--
|
||||
<tr><th>Date</th><th colspan="2">Trips</th><th colspan="3">Surveys</th></tr> Remove 'role' -->
|
||||
<tr><th>Date</th><th colspan="2">Trips</th><th colspan="2">Surveys</th></tr>
|
||||
{% for persondate in personchronology %}
|
||||
<tr>
|
||||
<td class="date">{{persondate.0}}</td>
|
||||
|
||||
{% if persondate.1 %}
|
||||
<td width="35%" class="trip"><a href="{{ persondate.1.logbook_entry.get_absolute_url }}">{{persondate.1.logbook_entry.title|safe}}</a></td>
|
||||
<td><a href="{{ persondate.1.logbook_entry.cave.get_absolute_url }}">{{persondate.1.place|safe}}</a></td>
|
||||
<td><a href="{{ persondate.1.logbook_entry.cave.get_absolute_url }}"> {{persondate.1.logbook_entry.place|safe}}</a></td>
|
||||
{% else %}
|
||||
<td colspan="2"> </td>
|
||||
{% endif %}
|
||||
|
||||
{% if persondate.2 %}
|
||||
<td class="survexblock"><a href="{% url "svx" persondate.2.survexfile.path %}">{{persondate.2.name}}</a></td>
|
||||
<td class="roles" style="padding-right: 3px; text-align:right">
|
||||
{% for survexpersonrole in persondate.2.survexpersonrole_set.all %}
|
||||
{{survexpersonrole.nrole}}
|
||||
{% endfor %}
|
||||
</td>
|
||||
{%comment%}
|
||||
<td class="roles" style="padding-right: 3px; text-align:right">
|
||||
{% for survexpersonrole in persondate.2.survexpersonrole_set.all %}
|
||||
{{survexpersonrole.nrole}}
|
||||
{% endfor %}
|
||||
</td>{%endcomment%}
|
||||
<td style="text-align:right">
|
||||
{{persondate.2.legslength|stringformat:".1f"}} m
|
||||
</td>
|
||||
@ -60,7 +67,9 @@
|
||||
e.g. see <a href="/personexpedition/Wookey/1999">Wookey 1999</a> where there are 3 eiscream survex blocks on 5th August.
|
||||
it duplicates the entry but gets it wrong. The length from the first block is displayed twice but there should be 3 rows: eiscream, eiscream2, eiscream3.
|
||||
<p>Fortunately it is <b>just this display on this page which is wrong</b>: no bad calculations get into the database.
|
||||
<p>The interaction of django database query idioms with <a href="https://docs.djangoproject.com/en/1.11/ref/templates/api/">django HTML templating language</a> is a bit impenetrable here. <br>
|
||||
<p>The interaction of django database query idioms with <a href="https://docs.djangoproject.com/en/1.11/ref/templates/api/">django HTML templating language</a> is a bit impenetrable here.
|
||||
I blame Aaron Curtis who was too fond of being clever with the Django templating system
|
||||
instead or writing it in python anyone could understand.<br>
|
||||
- The template is in <var>troggle/templates/personexpedition.html</var>
|
||||
<br>
|
||||
- The code is in function <var>personexpedition()</var> which calls
|
||||
|
2
urls.py
2
urls.py
@ -172,7 +172,7 @@ trogglepatterns = [
|
||||
re_path(r'^photos/(?P<subpath>.*)$', mediapage, {'doc_root': settings.PHOTOS_ROOT}, name="mediapage"), # photo galleries
|
||||
re_path(r'^site_media/(?P<subpath>.*)$', mediapage, {'doc_root': settings.MEDIA_ROOT}, name="mediapage"), # MEDIA_ROOT: CSS and JS
|
||||
re_path(r'^static/(?P<subpath>.*)$', mediapage, {'doc_root': settings.MEDIA_ROOT}, name="mediapage"), # STATIC is in MEDIA now!
|
||||
re_path(r'^javascript/(?P<subpath>.*)$', mediapage, {'doc_root': settings.JSLIB_ROOT}, name="mediapage"), # JSLIB_URL
|
||||
path('javascript/<path:subpath>', mediapage, {'doc_root': settings.JSLIB_ROOT}, name="mediapage"), # JSLIB_URL
|
||||
re_path(r'^expowebcache/3d/(?P<subpath>.*)$', mediapage, {'doc_root': settings.THREEDCACHEDIR}, name="mediapage"),
|
||||
|
||||
re_path(r'^/loser/(?P<subpath>.*)$', mediapage, {'doc_root': settings.SURVEX_DATA}, name="mediapage"), # Oddly not working !?
|
||||
|
Loading…
Reference in New Issue
Block a user