[svn r8228] cave maps to all logbook entry trips done there

This commit is contained in:
julian 2009-01-25 00:59:45 +01:00
parent 8068d02734
commit 1f70991566
14 changed files with 226 additions and 160 deletions

View File

@ -18,6 +18,7 @@ user.is_superuser = True
user.save() user.save()
import parsers.cavetab import parsers.cavetab
parsers.cavetab.LoadCaveTab()
import parsers.people import parsers.people
parsers.people.LoadPersonsExpos() parsers.people.LoadPersonsExpos()
import parsers.logbooks import parsers.logbooks

View File

@ -49,18 +49,6 @@ class Expedition(models.Model):
date+=datetime.timedelta(days=1) date+=datetime.timedelta(days=1)
return res return res
# deprecated
def GetPersonExpedition(self, name):
person_expeditions = PersonExpedition.objects.filter(expedition=self)
res = None
for person_expedition in person_expeditions:
for possible_name_from in person_expedition.GetPossibleNameForms():
#print "nnn", possiblenamefrom
if name == possible_name_from:
assert not res, "Ambiguous: " + name
res = person_expedition
return res
@ -198,6 +186,7 @@ class CaveAndEntrance(models.Model):
return unicode(self.cave) + unicode(self.entrance_letter) return unicode(self.cave) + unicode(self.entrance_letter)
class Cave(models.Model): class Cave(models.Model):
# too much here perhaps
official_name = models.CharField(max_length=160) official_name = models.CharField(max_length=160)
area = models.ManyToManyField(Area, blank=True, null=True) area = models.ManyToManyField(Area, blank=True, null=True)
kataster_code = models.CharField(max_length=20,blank=True,null=True) kataster_code = models.CharField(max_length=20,blank=True,null=True)
@ -216,6 +205,18 @@ class Cave(models.Model):
depth = models.CharField(max_length=100,blank=True,null=True) depth = models.CharField(max_length=100,blank=True,null=True)
extent = models.CharField(max_length=100,blank=True,null=True) extent = models.CharField(max_length=100,blank=True,null=True)
survex_file = models.CharField(max_length=100,blank=True,null=True) #should be filefield, need to fix parser first survex_file = models.CharField(max_length=100,blank=True,null=True) #should be filefield, need to fix parser first
href = models.CharField(max_length=100)
def Sethref(self):
if self.kataster_number:
self.href = self.kataster_number
elif self.unofficial_number:
self.href = self.unofficial_number
else:
self.href = official_name.lower()
def __unicode__(self): def __unicode__(self):
if self.kataster_number: if self.kataster_number:
if self.kat_area(): if self.kat_area():
@ -227,6 +228,8 @@ class Cave(models.Model):
return self.kat_area() + u": " + self.unofficial_number return self.kat_area() + u": " + self.unofficial_number
else: else:
return self.unofficial_number return self.unofficial_number
def kat_area(self): def kat_area(self):
for a in self.area.all(): for a in self.area.all():
if a.kat_area(): if a.kat_area():
@ -271,12 +274,15 @@ class LogbookEntry(models.Model):
text = models.TextField() text = models.TextField()
href = models.CharField(max_length=100) href = models.CharField(max_length=100)
# turn these into functions
logbookentry_next = models.ForeignKey('LogbookEntry', related_name='pnext', blank=True,null=True) logbookentry_next = models.ForeignKey('LogbookEntry', related_name='pnext', blank=True,null=True)
logbookentry_prev = models.ForeignKey('LogbookEntry', related_name='pprev', blank=True,null=True) logbookentry_prev = models.ForeignKey('LogbookEntry', related_name='pprev', blank=True,null=True)
class Meta: class Meta:
verbose_name_plural = "Logbook Entries" verbose_name_plural = "Logbook Entries"
# several PersonTrips point in to this object # several PersonTrips point in to this object
class Meta:
ordering = ('-date',)
def __unicode__(self): def __unicode__(self):
return "%s: (%s)" % (self.date, self.title) return "%s: (%s)" % (self.date, self.title)
@ -287,6 +293,7 @@ class PersonTrip(models.Model):
# this will be a foreign key of the place(s) the trip went through # this will be a foreign key of the place(s) the trip went through
# possibly a trip has a plurality of triplets pointing into it # possibly a trip has a plurality of triplets pointing into it
place = models.CharField(max_length=100) place = models.CharField(max_length=100)
# should add cave thing here (copied from logbook maybe)
date = models.DateField() date = models.DateField()
time_underground = models.FloatField() time_underground = models.FloatField()
logbook_entry = models.ForeignKey(LogbookEntry) logbook_entry = models.ForeignKey(LogbookEntry)
@ -474,3 +481,5 @@ class Survey(models.Model):
def elevations(self): def elevations(self):
return self.scannedimage_set.filter(contents='elevation') return self.scannedimage_set.filter(contents='elevation')

View File

@ -7,13 +7,20 @@ import search
def caveindex(request): def caveindex(request):
caves = Cave.objects.all() caves = Cave.objects.all()
return render_to_response('caveindex.html', {'caves': caves, 'settings': settings}) notablecavehrefs = [ "161", "204", "258", "76" ]
notablecaves = [ Cave.objects.get(href=href) for href in notablecavehrefs ]
return render_to_response('caveindex.html', {'caves': caves, 'notablecaves':notablecaves, 'settings': settings})
def cave(request, cave_id): def cave(request, cave_id):
#hm, we're only choosing by the number within kataster, needs to be fixed. Caves in 1626 will presumably not work. - AC 7DEC08 #hm, we're only choosing by the number within kataster, needs to be fixed. Caves in 1626 will presumably not work. - AC 7DEC08
cave = Cave.objects.filter(kataster_number = cave_id)[0] cave = Cave.objects.filter(kataster_number = cave_id)[0]
return render_to_response('cave.html', {'cave': cave, 'settings': settings}) return render_to_response('cave.html', {'cave': cave, 'settings': settings})
def cavehref(request, href):
cave = Cave.objects.get(href=href)
return render_to_response('cave.html', {'cave': cave, 'settings': settings})
def ent(request, cave_id, ent_letter): def ent(request, cave_id, ent_letter):
cave = Cave.objects.filter(kataster_number = cave_id)[0] cave = Cave.objects.filter(kataster_number = cave_id)[0]
cave_and_ent = CaveAndEntrance.objects.filter(cave = cave).filter(entrance_letter = ent_letter)[0] cave_and_ent = CaveAndEntrance.objects.filter(cave = cave).filter(entrance_letter = ent_letter)[0]

View File

@ -149,7 +149,7 @@ table.survexcontibutions td.roles
table.survexcontibutions td.survexblock table.survexcontibutions td.survexblock
{ width:260px; background-color:#feeeed; } { width:260px; background-color:#feeeed; }
table.survexcontibutions td.trip table.survexcontibutions td.trip
{ width:190px; } { width:280px; }
table.survexcontibutions td.place table.survexcontibutions td.place
{ width:140px; } { width:140px; }

View File

@ -56,9 +56,6 @@ MarkingComment = 43
Findability = 44 Findability = 44
FindabilityComment = 45 FindabilityComment = 45
cavetab = open(os.path.join(settings.EXPOWEB, "noinfo", "CAVETAB2.CSV"))
caveReader = csv.reader(cavetab)
caveReader.next() # Strip out column headers
def html_to_wiki(text): def html_to_wiki(text):
if type(text) != str: if type(text) != str:
@ -138,15 +135,20 @@ def html_to_wiki(text):
text2 = "" text2 = ""
return out return out
for katArea in ['1623', '1626']: def LoadCaveTab():
cavetab = open(os.path.join(settings.EXPOWEB, "noinfo", "CAVETAB2.CSV"))
caveReader = csv.reader(cavetab)
caveReader.next() # Strip out column headers
for katArea in ['1623', '1626']:
if not models.Area.objects.filter(short_name = katArea): if not models.Area.objects.filter(short_name = katArea):
newArea = models.Area(short_name = katArea) newArea = models.Area(short_name = katArea)
newArea.save() newArea.save()
area1626 = models.Area.objects.filter(short_name = '1626')[0] area1626 = models.Area.objects.filter(short_name = '1626')[0]
area1623 = models.Area.objects.filter(short_name = '1623')[0] area1623 = models.Area.objects.filter(short_name = '1623')[0]
counter=0 counter=0
for line in caveReader : for line in caveReader :
if line[Area] == 'nonexistent': if line[Area] == 'nonexistent':
continue continue
entranceLetters=[] #Used in caves that have mulitlple entrances, which are not described on seperate lines entranceLetters=[] #Used in caves that have mulitlple entrances, which are not described on seperate lines
@ -174,6 +176,7 @@ for line in caveReader :
addToArgs(Notes, "notes") addToArgs(Notes, "notes")
newCave = models.Cave(**args) newCave = models.Cave(**args)
newCave.Sethref()
newCave.save() newCave.save()
if line[Area]: if line[Area]:
@ -195,6 +198,7 @@ for line in caveReader :
if line[UnofficialName]: if line[UnofficialName]:
newUnofficialName = models.OtherCaveName(cave = newCave, name = line[UnofficialName]) newUnofficialName = models.OtherCaveName(cave = newCave, name = line[UnofficialName])
newUnofficialName.save() newUnofficialName.save()
if line[MultipleEntrances] == '' or \ if line[MultipleEntrances] == '' or \
line[MultipleEntrances] == 'entrance' or \ line[MultipleEntrances] == 'entrance' or \
line[MultipleEntrances] == 'last entrance': line[MultipleEntrances] == 'last entrance':
@ -277,6 +281,9 @@ def GetCaveLookup():
Gcavelookup[cave.kataster_number] = cave Gcavelookup[cave.kataster_number] = cave
if cave.unofficial_number: if cave.unofficial_number:
Gcavelookup[cave.unofficial_number] = cave Gcavelookup[cave.unofficial_number] = cave
Gcavelookup["tunnocks"] = Gcavelookup["258"]
Gcavelookup["hauchhole"] = Gcavelookup["234"]
return Gcavelookup return Gcavelookup

View File

@ -63,13 +63,16 @@ def GetTripCave(place): #need to be fuzzier about matching h
return return
noncaveplaces = [ "Journey", "Loser Plateau" ]
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)
lbo.cave=GetCaveLookup().get(place) lplace = place.lower()
print "pppp", place, lbo.cave if lplace not in noncaveplaces:
lbo.cave=GetCaveLookup().get(lplace)
print "pppp %s |%s|" % (lplace, str(lbo.cave))
lbo.save() lbo.save()
#print "ttt", date, place #print "ttt", date, place
@ -158,7 +161,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("|")

View File

@ -2,6 +2,19 @@
{% load wiki_markup %} {% load wiki_markup %}
{% block content %} {% block content %}
<div id="col2">
<h3>All trips done in this cave</h3>
<table>
{% for logbookentry in cave.logbookentry_set.all %}
<tr>
<td>{{logbookentry.date}}</td>
<td><a href="{% url logbookentry logbookentry.href %}">{{logbookentry.title|safe}}</a></td>
</tr>
{% endfor %}
</table>
</div>
{% if cave.entrances %} {% if cave.entrances %}
<h2>Entrances</h2> <h2>Entrances</h2>
{% for ent in cave.entrances %} {% for ent in cave.entrances %}

View File

@ -4,7 +4,19 @@
{% block title %}Cave Index{% endblock %} {% block title %}Cave Index{% endblock %}
{% block content %} {% block content %}
{% for cave in caves %}
<p>{{ cave }} <a href="{{settings.URL_ROOT}}cave/{{ cave.kataster_number }}/">{{ cave.official_name|wiki_to_html_short }}</a> </p> <h3>Notable caves</h3>
<ul>
{% for cave in notablecaves %}
<li> <a href="{% url cave cave.href %}">{{cave.official_name|wiki_to_html_short}} ({{cave.href}})</a> </li>
{% endfor %} {% endfor %}
</ul>
<h3>All caves</h3>
<ul>
{% for cave in caves %}
<li> <a href="{% url cave cave.href %}">{{cave.official_name|wiki_to_html_short}} ({{cave.href}})</a> </li>
{% endfor %}
</ul>
{% endblock %} {% endblock %}

View File

@ -38,7 +38,12 @@
<td>{{logbookentry.date}}</td> <td>{{logbookentry.date}}</td>
<td><a href="{% url logbookentry logbookentry.href %}">{{logbookentry.title|safe}}</td> <td><a href="{% url logbookentry logbookentry.href %}">{{logbookentry.title|safe}}</td>
<td><a href="{% url personexpedition logbookentry.author.person.href logbookentry.author.expedition.year %}">{{logbookentry.author.name}}</a></td> <td><a href="{% url personexpedition logbookentry.author.person.href logbookentry.author.expedition.year %}">{{logbookentry.author.name}}</a></td>
{% if logbookentry.cave %}
<td><a href="{% url cave logbookentry.cave.href %}">{{logbookentry.place}}</a></td>
{% else %}
<td>{{logbookentry.place}}</td> <td>{{logbookentry.place}}</td>
{% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

View File

@ -9,26 +9,25 @@
<b>Work down through an expedition page link</b> <b>Work down through an expedition page link</b>
<p class="indent"><b>Remaining work:</b> <p class="indent"><b>Remaining work:</b>
<p>continue to build up the network; </p> <p>(separate out the recent/notable people) vast front-page layout table of folks and caving trips and years; </p>
<p>tables of trips per year per person;</p>
<p>parse 1995-1976 logbooks; </p> <p>parse 1995-1976 logbooks; </p>
<p>continue to correct the name matching and spelling; </p> <p>name matching and spelling in survex files; </p>
<p>detect T/U on log entries; </p> <p>detect T/U on log entries; </p>
<p>Improve logbook wikihtml text</p>
<p>match caves to 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>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>links between logbooks and survex blocks to cave things; </p>
<p>where are the subcaves; </p> <p>where are the subcaves; </p>
<p>mini-tree of survexblocks; </p> <p>mini-tree of survexblocks; </p>
<p>connect sketches to caves to survey blocks and render thumbnailwise; </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> <p>all images to start appearing in pages; and so on</p>
<p>tables of trips per year per person;</p>
<h3>{{message}}</h3> <h3>{{message}}</h3>
<ul> <ul>
<li><a href="{% url personindex %}">List of People</a></li> <li><b><a href="{% url personindex %}">List of People</a></b></li>
<li><a href="{% url caveindex %}">List of Caves</a></li> <li><b><a href="{% url caveindex %}">List of Caves</a></b></li>
<li><a href="/statistics">Statistics of what's loaded in the database</a></li> <li><a href="/statistics">Statistics of what's loaded in the database</a></li>
<li><a href="{% url survexindex all %}">Survex directory</a></li> <li><a href="{% url survexindex all %}">Survex directory</a></li>
<li><a href="{% url survey %}">Survey files</a></li> <li><a href="{% url survey %}">Survey files</a></li>
@ -40,13 +39,11 @@
</form> </form>
<ul id="expeditionlist"> <ul id="expeditionlist">
{% for expedition in expeditions %}
{% for expedition in expeditions %} <li>
<li>
<a href="{% url expedition expedition.year %}">{{expedition.name}}</a> <a href="{% url expedition expedition.year %}">{{expedition.name}}</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endblock %} {% endblock %}

View File

@ -8,7 +8,12 @@
<div id="col2"> <div id="col2">
<p><a href="{% url expedition logbookentry.expedition.year %}">{{logbookentry.expedition.name}}</a></p> <p><a href="{% url expedition logbookentry.expedition.year %}">{{logbookentry.expedition.name}}</a></p>
<p>place: {{logbookentry.place}}</p>
{% if logbookentry.cave %}
<p>place: <a href="{% url cave logbookentry.cave.href %}">{{logbookentry.place}}</p>
{% else %}
<p>{{logbookentry.place}}</p>
{% endif %}
<p> <p>
{% if logbookentry.logbookentry_prev %} {% if logbookentry.logbookentry_prev %}

View File

@ -36,7 +36,12 @@
{% for persontrip in persondate.1.persontrips %} {% for persontrip in persondate.1.persontrips %}
<tr> <tr>
<td class="trip"><a href="{% url logbookentry persontrip.logbook_entry.href %}">{{persontrip.logbook_entry.title|safe}}</a></td> <td class="trip"><a href="{% url logbookentry persontrip.logbook_entry.href %}">{{persontrip.logbook_entry.title|safe}}</a></td>
<td class="place">{{persontrip.place}}</td>
{% if persontrip.logbook_entry.cave %}
<td><a href="{% url cave persontrip.logbook_entry.cave.href %}">{{persontrip.place}}</a></td>
{% else %}
<td>{{persontrip.place}}</td>
{% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>

View File

@ -9,8 +9,10 @@ urlpatterns = patterns('',
(r'^$', frontPage), (r'^$', frontPage),
url(r'^caveindex$', caveindex, name="caveindex"), url(r'^caveindex$', caveindex, name="caveindex"),
url(r'^cave/(?P<cave_id>[^/]+)/?$', cave),
url(r'^cavehref/(.+)$', cave, name="cave"),
(r'^cave/(?P<cave_id>[^/]+)/?$', cave),
(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent), (r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent),
#(r'^cave/(?P<cave_id>[^/]+)/edit/$', edit_cave), #(r'^cave/(?P<cave_id>[^/]+)/edit/$', edit_cave),
(r'^cavesearch', caveSearch), (r'^cavesearch', caveSearch),

View File

@ -282,7 +282,7 @@ FRIDAY 28th JULY
OOPS! OOPS!
===24/7/06 | Tunnocks Trips | Tom, Mark, Aaron === ===24/7/06 | Tunnocks - Trips | Tom, Mark, Aaron ===
<p> BECKA - actually three dates given: 24,25,26 July <p> BECKA - actually three dates given: 24,25,26 July