2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-05-10 11:25:46 +01:00

[svn] merge the trip table to have surveys by date

Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8221 by julian @ 1/24/2009 2:01 PM
This commit is contained in:
substantialnoninfringinguser 2009-05-13 05:43:20 +01:00
parent 6598dd5105
commit 60735a9b3a
8 changed files with 139 additions and 39 deletions

@ -86,6 +86,34 @@ class PersonExpedition(models.Model):
is_guest = models.BooleanField(default=False) is_guest = models.BooleanField(default=False)
nickname = models.CharField(max_length=100,blank=True,null=True) nickname = models.CharField(max_length=100,blank=True,null=True)
def GetPersonroles(self):
res = [ ]
for personrole in self.personrole_set.order_by('survex_block'):
if res and res[-1]['survexpath'] == personrole.survex_block.survexpath:
res[-1]['roles'] += ", " + str(personrole.role)
else:
res.append({'date':personrole.survex_block.date, 'survexpath':personrole.survex_block.survexpath, 'roles':str(personrole.role)})
print res
return res
def GetPersonChronology(self):
res = { }
for persontrip in self.persontrip_set.all():
a = res.setdefault(persontrip.date, { })
a.setdefault("persontrips", [ ]).append(persontrip)
for personrole in self.personrole_set.all():
a = res.setdefault(personrole.survex_block.date, { })
b = a.setdefault("personroles", { })
survexpath = personrole.survex_block.survexpath
if b.get(survexpath):
b[survexpath] += ", " + str(personrole.role)
else:
b[survexpath] = str(personrole.role)
# needs converting dict into list
return sorted(res.items())
# deprecated # deprecated
def GetPossibleNameForms(self): def GetPossibleNameForms(self):
res = [ ] res = [ ]

@ -27,6 +27,9 @@ class SurvexBlock(models.Model):
end_file = models.CharField(max_length=200, blank=True, null=True) end_file = models.CharField(max_length=200, blank=True, null=True)
end_char = models.IntegerField(blank=True, null=True) end_char = models.IntegerField(blank=True, null=True)
class Meta:
ordering = ('date', 'survexpath')
def __unicode__(self): def __unicode__(self):
return unicode(self.name) return unicode(self.name)
@ -37,6 +40,15 @@ class SurvexBlock(models.Model):
fin.close() fin.close()
return res return res
def GetPersonroles(self):
res = [ ]
for personrole in self.personrole_set.order_by('personexpedition'):
if res and res[-1]['person'] == personrole.personexpedition.person:
res[-1]['roles'] += ", " + str(personrole.role)
else:
res.append({'person':personrole.personexpedition.person, 'expeditionyear':personrole.personexpedition.expedition.year, 'roles':str(personrole.role)})
print res
return res
class PersonRole(models.Model): class PersonRole(models.Model):

@ -142,6 +142,17 @@ p.indent
margin-left:10px; margin-left:10px;
} }
table.survexcontibutions td.date
{ width:90px; }
table.survexcontibutions td.roles
{ width:100px; background-color:#feeeed; }
table.survexcontibutions td.survexblock
{ width:260px; background-color:#feeeed; }
table.survexcontibutions td.trip
{ width:190px; }
table.survexcontibutions td.place
{ width:140px; }
#expoHeader { #expoHeader {
width:100%; width:100%;
position:relative; position:relative;

@ -262,3 +262,21 @@ for line in caveReader :
newCaveAndEntrance = models.CaveAndEntrance(cave = newCave, entrance = newEntrance, entrance_letter = entrance_letter) newCaveAndEntrance = models.CaveAndEntrance(cave = newCave, entrance = newEntrance, entrance_letter = entrance_letter)
newCaveAndEntrance.save() newCaveAndEntrance.save()
# lookup function modelled on GetPersonExpeditionNameLookup
Gcavelookup = None
def GetCaveLookup():
global Gcavelookup
if Gcavelookup:
return Gcavelookup
Gcavelookup = {"NONEPLACEHOLDER":None}
for cave in models.Cave.objects.all():
Gcavelookup[cave.official_name.lower()] = cave
if cave.kataster_number:
Gcavelookup[cave.kataster_number] = cave
if cave.unofficial_number:
Gcavelookup[cave.unofficial_number] = cave
return Gcavelookup

@ -4,6 +4,7 @@ import troggle.settings as settings
import troggle.expo.models as models import troggle.expo.models as models
from troggle.parsers.people import GetPersonExpeditionNameLookup from troggle.parsers.people import GetPersonExpeditionNameLookup
from troggle.parsers.cavetab import GetCaveLookup
import csv import csv
import re import re
@ -64,13 +65,14 @@ def GetTripCave(place): #need to be fuzzier about matching h
def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_underground): def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_underground):
trippersons, author = GetTripPersons(trippeople, expedition, logtime_underground) trippersons, author = GetTripPersons(trippeople, expedition, logtime_underground)
tripCave = GetTripCave(place) # tripCave = GetTripCave(place)
lbo = models.LogbookEntry(date=date, place=place, title=title[:50], text=text, author=author, expedition=expedition) lbo = models.LogbookEntry(date=date, place=place, title=title[:50], text=text, author=author, expedition=expedition)
if tripCave: lbo.cave=GetCaveLookup().get(place)
lbo.cave=tripCave print "pppp", place, lbo.cave
lbo.save() lbo.save()
print "ttt", date, place #print "ttt", date, place
for tripperson, time_underground in trippersons: for tripperson, time_underground in trippersons:
pto = models.PersonTrip(person_expedition = tripperson, place=place, date=date, time_underground=time_underground, pto = models.PersonTrip(person_expedition = tripperson, place=place, date=date, time_underground=time_underground,
logbook_entry=lbo, is_logbook_entry_author=(tripperson == author)) logbook_entry=lbo, is_logbook_entry_author=(tripperson == author))
@ -156,7 +158,7 @@ def Parseloghtml01(year, expedition, txt):
tripid = mtripid and mtripid.group(1) or "" tripid = mtripid and mtripid.group(1) or ""
tripheader = re.sub("</?(?:[ab]|span)[^>]*>", "", tripheader) tripheader = re.sub("</?(?:[ab]|span)[^>]*>", "", tripheader)
#print [tripheader] print [tripheader]
#continue #continue
tripdate, triptitle, trippeople = tripheader.split("|") tripdate, triptitle, trippeople = tripheader.split("|")
@ -234,7 +236,7 @@ yearlinks = [
("1999", "1999/log.htm", Parseloghtml01), ("1999", "1999/log.htm", Parseloghtml01),
("1998", "1998/log.htm", Parseloghtml01), ("1998", "1998/log.htm", Parseloghtml01),
("1997", "1997/log.htm", Parseloghtml01), ("1997", "1997/log.htm", Parseloghtml01),
#("1996", "1996/log.htm", Parseloghtml01), ("1996", "1996/log.htm", Parseloghtml01),
] ]
def SetDatesFromLogbookEntries(expedition): def SetDatesFromLogbookEntries(expedition):
@ -303,7 +305,7 @@ def LoadLogbooks():
models.LogbookEntry.objects.all().delete() models.LogbookEntry.objects.all().delete()
expowebbase = os.path.join(settings.EXPOWEB, "years") expowebbase = os.path.join(settings.EXPOWEB, "years")
#yearlinks = [ ("2001", "2001/log.htm", Parseloghtml01), ] #overwrite #yearlinks = [ ("2001", "2001/log.htm", Parseloghtml01), ] #overwrite
#yearlinks = [ ("1997", "1997/log.htm", Parseloghtml01),] # overwrite #yearlinks = [ ("1996", "1996/log.htm", Parseloghtml01),] # overwrite
for year, lloc, parsefunc in yearlinks: for year, lloc, parsefunc in yearlinks:
expedition = models.Expedition.objects.filter(year = year)[0] expedition = models.Expedition.objects.filter(year = year)[0]

@ -7,11 +7,22 @@
<h2>The unfinished front page</h2> <h2>The unfinished front page</h2>
<b>Work down through an expedition page link</b> <b>Work down through an expedition page link</b>
<p class="indent">Remaining work: continue to build up the network; tables of trips per year per person; parse 1996 logbook; <p class="indent"><b>Remaining work:</b>
continue to correct the name matching and spelling; detect T/U on log entries; match caves to log entries; see the cave list;
simplify the survex parsing code (if necessary); vast front-page layout table of folks and caving trips and years; <p>continue to build up the network; </p>
links between logbooks and survex blocks to cave things; where are the subcaves; mini-tree of survexblocks; connect sketches <p>tables of trips per year per person;</p>
to caves to survey blocks and render thumbnailwise; all images to start appearing in pages; and so on</p> <p>parse 1995-1976 logbooks; </p>
<p>continue to correct the name matching and spelling; </p>
<p>detect T/U on log entries; </p>
<p>match caves to log entries; </p>
<p>see the cave list;</p>
<p>simplify the survex parsing code (if necessary); </p>
<p>vast front-page layout table of folks and caving trips and years; </p>
<p>links between logbooks and survex blocks to cave things; </p>
<p>where are the subcaves; </p>
<p>mini-tree of survexblocks; </p>
<p>connect sketches to caves to survey blocks and render thumbnailwise; </p>
<p>all images to start appearing in pages; and so on</p>
<h3>{{message}}</h3> <h3>{{message}}</h3>

@ -9,32 +9,50 @@
<h3>{{message}}</h3> <h3>{{message}}</h3>
<p>Needs links fore and back through expeditions attended by this person (or as a complete barchart type list with one date in bold)</p> <p><b><a href="{% url expedition personexpedition.expedition.year %}">Main page for expedition: {{personexpedition.expedition}}</a></b></p>
<p>Needs lists below to be sorted by date, and the duplicates removed from survey role list</p>
<p>Finally, a correspondence between these two columns</p>
<div id="col2"> <p>List of other expos by this person</p>
<table class="survexcontibutions"> <p>
<tr><th>Date</th><th>Place</th><th>Role</th></tr> {% for otherpersonexpedition in personexpedition.person.personexpedition_set.all %}
{% for personrole in personexpedition.personrole_set.all %} {% ifequal otherpersonexpedition personexpedition %}
<tr> | <b>{{otherpersonexpedition.expedition.year}}</b>
<td>{{personrole.survex_block.date}}</td> {% else %}
<td><a href="{% url survexblock personrole.survex_block.survexpath %}">{{personrole.survex_block.survexpath}}</a></td> | <a href="{% url personexpedition personexpedition.person.href otherpersonexpedition.expedition.year %}">{{otherpersonexpedition.expedition.year}}</a>
<td>{{personrole.role}}</td> {% endifequal %}
</tr>
{% endfor %} {% endfor %}
</table> </p>
</div>
<div id="col1"> <h3>Table of all trips and surveys aligned by date</h3>
<table class="expeditionlogbooks"> <div>
<tr><th>Date</th><th>Title</th><th>Place</th></tr> <table class="survexcontibutions">
{% for persontrip in personexpedition.persontrip_set.all %} <tr><th>Date</th><th>Trips</th><th>Surveys</th></tr>
{% for persondate in personexpedition.GetPersonChronology %}
<tr>
<td class="date">{{persondate.0}}</td>
<td>
<table>
{% for persontrip in persondate.1.persontrips %}
<tr> <tr>
<td>{{persontrip.date}}</td> <td class="trip"><a href="{% url logbookentry persontrip.logbook_entry.href %}">{{persontrip.logbook_entry.title|safe}}</a></td>
<td><a href="{% url logbookentry persontrip.logbook_entry.href %}">{{persontrip.logbook_entry.title|safe}}</td> <td class="place">{{persontrip.place}}</td>
<td>{{persontrip.place}}</td>
</tr> </tr>
{% endfor %}
</table>
</td>
<td>
<table>
{% for personsurvexroles in persondate.1.personroles.items %}
<tr>
<td class="survexblock"><a href="{% url survexblock personsurvexroles.0 %}">{{personsurvexroles.0}}</a></td>
<td class="roles">{{personsurvexroles.1}}</td>
</tr>
{% endfor %}
</table>
</td>
</tr>
{% endfor %} {% endfor %}
</table> </table>
</div> </div>

@ -29,10 +29,10 @@
<p>Date: {{survexblock.date}}</p> <p>Date: {{survexblock.date}}</p>
<table> <table>
{% for personrole in survexblock.personrole_set.all %} {% for personrole in survexblock.GetPersonroles %}
<tr> <tr>
<td><a href="{% url personexpedition personrole.personexpedition.person.href personrole.personexpedition.expedition.year%}">{{personrole.personexpedition.person}}</a></td> <td><a href="{% url personexpedition personrole.person.href personrole.expeditionyear%}">{{personrole.person}}</a></td>
<td>{{personrole.role}}</td> <td>{{personrole.roles}}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
@ -40,7 +40,7 @@
</div> </div>
<div id="col1"> <div class="survexblock">
{{ftext|survex_to_html}} {{ftext|survex_to_html}}
</div> </div>