[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()
import parsers.cavetab
parsers.cavetab.LoadCaveTab()
import parsers.people
parsers.people.LoadPersonsExpos()
import parsers.logbooks

View File

@ -49,18 +49,6 @@ class Expedition(models.Model):
date+=datetime.timedelta(days=1)
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)
class Cave(models.Model):
# too much here perhaps
official_name = models.CharField(max_length=160)
area = models.ManyToManyField(Area, 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)
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
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):
if self.kataster_number:
if self.kat_area():
@ -227,6 +228,8 @@ class Cave(models.Model):
return self.kat_area() + u": " + self.unofficial_number
else:
return self.unofficial_number
def kat_area(self):
for a in self.area.all():
if a.kat_area():
@ -271,12 +274,15 @@ class LogbookEntry(models.Model):
text = models.TextField()
href = models.CharField(max_length=100)
# turn these into functions
logbookentry_next = models.ForeignKey('LogbookEntry', related_name='pnext', blank=True,null=True)
logbookentry_prev = models.ForeignKey('LogbookEntry', related_name='pprev', blank=True,null=True)
class Meta:
verbose_name_plural = "Logbook Entries"
# several PersonTrips point in to this object
class Meta:
ordering = ('-date',)
def __unicode__(self):
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
# possibly a trip has a plurality of triplets pointing into it
place = models.CharField(max_length=100)
# should add cave thing here (copied from logbook maybe)
date = models.DateField()
time_underground = models.FloatField()
logbook_entry = models.ForeignKey(LogbookEntry)
@ -473,4 +480,6 @@ class Survey(models.Model):
return self.scannedimage_set.filter(contents='plan')
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):
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):
#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]
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):
cave = Cave.objects.filter(kataster_number = cave_id)[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
{ width:260px; background-color:#feeeed; }
table.survexcontibutions td.trip
{ width:190px; }
{ width:280px; }
table.survexcontibutions td.place
{ width:140px; }

View File

@ -56,9 +56,6 @@ MarkingComment = 43
Findability = 44
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):
if type(text) != str:
@ -138,130 +135,137 @@ def html_to_wiki(text):
text2 = ""
return out
for katArea in ['1623', '1626']:
if not models.Area.objects.filter(short_name = katArea):
newArea = models.Area(short_name = katArea)
newArea.save()
area1626 = models.Area.objects.filter(short_name = '1626')[0]
area1623 = models.Area.objects.filter(short_name = '1623')[0]
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):
newArea = models.Area(short_name = katArea)
newArea.save()
area1626 = models.Area.objects.filter(short_name = '1626')[0]
area1623 = models.Area.objects.filter(short_name = '1623')[0]
counter=0
for line in caveReader :
if line[Area] == 'nonexistent':
continue
entranceLetters=[] #Used in caves that have mulitlple entrances, which are not described on seperate lines
if line[MultipleEntrances] == 'yes' or line[MultipleEntrances]=='':
args = {}
def addToArgs(CSVname, modelName):
if line[CSVname]:
args[modelName] = html_to_wiki(line[CSVname])
addToArgs(KatasterNumber, "kataster_number")
addToArgs(KatStatusCode, "kataster_code")
addToArgs(UnofficialNumber, "unofficial_number")
addToArgs(Name, "official_name")
addToArgs(Comment, "notes")
addToArgs(Explorers, "explorers")
addToArgs(UndergroundDescription, "underground_description")
addToArgs(Equipment, "equipment")
addToArgs(KatasterStatus, "kataster_status")
addToArgs(References, "references")
addToArgs(UndergroundCentreLine, "underground_centre_line")
addToArgs(UndergroundDrawnSurvey, "survey")
addToArgs(Length, "length")
addToArgs(Depth, "depth")
addToArgs(Extent, "extent")
addToArgs(SurvexFile, "survex_file")
addToArgs(Notes, "notes")
counter=0
for line in caveReader :
if line[Area] == 'nonexistent':
continue
entranceLetters=[] #Used in caves that have mulitlple entrances, which are not described on seperate lines
if line[MultipleEntrances] == 'yes' or line[MultipleEntrances]=='':
args = {}
def addToArgs(CSVname, modelName):
if line[CSVname]:
args[modelName] = html_to_wiki(line[CSVname])
addToArgs(KatasterNumber, "kataster_number")
addToArgs(KatStatusCode, "kataster_code")
addToArgs(UnofficialNumber, "unofficial_number")
addToArgs(Name, "official_name")
addToArgs(Comment, "notes")
addToArgs(Explorers, "explorers")
addToArgs(UndergroundDescription, "underground_description")
addToArgs(Equipment, "equipment")
addToArgs(KatasterStatus, "kataster_status")
addToArgs(References, "references")
addToArgs(UndergroundCentreLine, "underground_centre_line")
addToArgs(UndergroundDrawnSurvey, "survey")
addToArgs(Length, "length")
addToArgs(Depth, "depth")
addToArgs(Extent, "extent")
addToArgs(SurvexFile, "survex_file")
addToArgs(Notes, "notes")
newCave = models.Cave(**args)
newCave.save()
if line[Area]:
if line[Area] == "1626":
newCave.area.add(area1626)
else:
area = models.Area.objects.filter(short_name = line[Area])
if area:
newArea = area[0]
newCave = models.Cave(**args)
newCave.Sethref()
newCave.save()
if line[Area]:
if line[Area] == "1626":
newCave.area.add(area1626)
else:
newArea = models.Area(short_name = line[Area], parent = area1623)
newArea.save()
newCave.area.add(newArea)
else:
newCave.area.add(area1623)
newCave.save()
area = models.Area.objects.filter(short_name = line[Area])
if area:
newArea = area[0]
else:
newArea = models.Area(short_name = line[Area], parent = area1623)
newArea.save()
newCave.area.add(newArea)
else:
newCave.area.add(area1623)
newCave.save()
if line[UnofficialName]:
newUnofficialName = models.OtherCaveName(cave = newCave, name = line[UnofficialName])
newUnofficialName.save()
if line[MultipleEntrances] == '' or \
line[MultipleEntrances] == 'entrance' or \
line[MultipleEntrances] == 'last entrance':
args = {}
def addToArgs(CSVname, modelName):
if line[CSVname]:
args[modelName] = html_to_wiki(line[CSVname])
def addToArgsViaDict(CSVname, modelName, dictionary):
if line[CSVname]:
args[modelName] = dictionary[html_to_wiki(line[CSVname])]
addToArgs(EntranceName, 'name')
addToArgs(Explorers, 'explorers')
addToArgs(Map, 'map_description')
addToArgs(Location, 'location_description')
addToArgs(Approach, 'approach')
addToArgs(EntranceDescription, 'entrance_description')
addToArgs(UndergroundDescription, 'underground_description')
addToArgs(PhotoOfLocation, 'photo')
addToArgsViaDict(Marking, 'marking', {"Paint": "P",
"Paint (?)": "P?",
"Tag": "T",
"Tag (?)": "T?",
"Retagged": "R",
"Retag": "R",
"Spit": "S",
"Spit (?)": "S?",
"Unmarked": "U",
"": "?",
})
addToArgs(MarkingComment, 'marking_comment')
addToArgsViaDict(Findability, 'findability', {"Surveyed": "S",
"Lost": "L",
"Refindable": "R",
"": "?",
"?": "?",
})
addToArgs(FindabilityComment, 'findability_description')
addToArgs(Easting, 'easting')
addToArgs(Northing, 'northing')
addToArgs(Altitude, 'alt')
addToArgs(DescriptionOfOtherPoint, 'other_description')
def addToArgsSurveyStation(CSVname, modelName):
if line[CSVname]:
surveyPoint = models.SurveyStation(name = line[CSVname])
surveyPoint.save()
args[modelName] = html_to_wiki(surveyPoint)
addToArgsSurveyStation(TagPoint, 'tag_station')
addToArgsSurveyStation(ExactEntrance, 'exact_station')
addToArgsSurveyStation(OtherPoint, 'other_station')
addToArgs(OtherPoint, 'other_description')
if line[GPSpreSA]:
addToArgsSurveyStation(GPSpreSA, 'other_station')
args['other_description'] = 'pre selective availability GPS'
if line[GPSpostSA]:
addToArgsSurveyStation(GPSpostSA, 'other_station')
args['other_description'] = 'post selective availability GPS'
addToArgs(Bearings, 'bearings')
newEntrance = models.Entrance(**args)
newEntrance.save()
if line[Entrances]:
entrance_letter = line[Entrances]
else:
entrance_letter = ''
newCaveAndEntrance = models.CaveAndEntrance(cave = newCave, entrance = newEntrance, entrance_letter = entrance_letter)
newCaveAndEntrance.save()
if line[MultipleEntrances] == '' or \
line[MultipleEntrances] == 'entrance' or \
line[MultipleEntrances] == 'last entrance':
args = {}
def addToArgs(CSVname, modelName):
if line[CSVname]:
args[modelName] = html_to_wiki(line[CSVname])
def addToArgsViaDict(CSVname, modelName, dictionary):
if line[CSVname]:
args[modelName] = dictionary[html_to_wiki(line[CSVname])]
addToArgs(EntranceName, 'name')
addToArgs(Explorers, 'explorers')
addToArgs(Map, 'map_description')
addToArgs(Location, 'location_description')
addToArgs(Approach, 'approach')
addToArgs(EntranceDescription, 'entrance_description')
addToArgs(UndergroundDescription, 'underground_description')
addToArgs(PhotoOfLocation, 'photo')
addToArgsViaDict(Marking, 'marking', {"Paint": "P",
"Paint (?)": "P?",
"Tag": "T",
"Tag (?)": "T?",
"Retagged": "R",
"Retag": "R",
"Spit": "S",
"Spit (?)": "S?",
"Unmarked": "U",
"": "?",
})
addToArgs(MarkingComment, 'marking_comment')
addToArgsViaDict(Findability, 'findability', {"Surveyed": "S",
"Lost": "L",
"Refindable": "R",
"": "?",
"?": "?",
})
addToArgs(FindabilityComment, 'findability_description')
addToArgs(Easting, 'easting')
addToArgs(Northing, 'northing')
addToArgs(Altitude, 'alt')
addToArgs(DescriptionOfOtherPoint, 'other_description')
def addToArgsSurveyStation(CSVname, modelName):
if line[CSVname]:
surveyPoint = models.SurveyStation(name = line[CSVname])
surveyPoint.save()
args[modelName] = html_to_wiki(surveyPoint)
addToArgsSurveyStation(TagPoint, 'tag_station')
addToArgsSurveyStation(ExactEntrance, 'exact_station')
addToArgsSurveyStation(OtherPoint, 'other_station')
addToArgs(OtherPoint, 'other_description')
if line[GPSpreSA]:
addToArgsSurveyStation(GPSpreSA, 'other_station')
args['other_description'] = 'pre selective availability GPS'
if line[GPSpostSA]:
addToArgsSurveyStation(GPSpostSA, 'other_station')
args['other_description'] = 'post selective availability GPS'
addToArgs(Bearings, 'bearings')
newEntrance = models.Entrance(**args)
newEntrance.save()
if line[Entrances]:
entrance_letter = line[Entrances]
else:
entrance_letter = ''
newCaveAndEntrance = models.CaveAndEntrance(cave = newCave, entrance = newEntrance, entrance_letter = entrance_letter)
newCaveAndEntrance.save()
# lookup function modelled on GetPersonExpeditionNameLookup
@ -277,6 +281,9 @@ def GetCaveLookup():
Gcavelookup[cave.kataster_number] = cave
if cave.unofficial_number:
Gcavelookup[cave.unofficial_number] = cave
Gcavelookup["tunnocks"] = Gcavelookup["258"]
Gcavelookup["hauchhole"] = Gcavelookup["234"]
return Gcavelookup

View File

@ -63,13 +63,16 @@ def GetTripCave(place): #need to be fuzzier about matching h
return
noncaveplaces = [ "Journey", "Loser Plateau" ]
def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_underground):
trippersons, author = GetTripPersons(trippeople, expedition, logtime_underground)
# tripCave = GetTripCave(place)
lbo = models.LogbookEntry(date=date, place=place, title=title[:50], text=text, author=author, expedition=expedition)
lbo.cave=GetCaveLookup().get(place)
print "pppp", place, lbo.cave
lplace = place.lower()
if lplace not in noncaveplaces:
lbo.cave=GetCaveLookup().get(lplace)
print "pppp %s |%s|" % (lplace, str(lbo.cave))
lbo.save()
#print "ttt", date, place
@ -158,7 +161,7 @@ def Parseloghtml01(year, expedition, txt):
tripid = mtripid and mtripid.group(1) or ""
tripheader = re.sub("</?(?:[ab]|span)[^>]*>", "", tripheader)
print [tripheader]
#print [tripheader]
#continue
tripdate, triptitle, trippeople = tripheader.split("|")

View File

@ -2,6 +2,19 @@
{% load wiki_markup %}
{% 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 %}
<h2>Entrances</h2>
{% for ent in cave.entrances %}

View File

@ -4,7 +4,19 @@
{% block title %}Cave Index{% endblock %}
{% 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 %}
</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 %}

View File

@ -38,7 +38,12 @@
<td>{{logbookentry.date}}</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>{{logbookentry.place}}</td>
{% if logbookentry.cave %}
<td><a href="{% url cave logbookentry.cave.href %}">{{logbookentry.place}}</a></td>
{% else %}
<td>{{logbookentry.place}}</td>
{% endif %}
</tr>
{% endfor %}
</table>

View File

@ -9,26 +9,25 @@
<b>Work down through an expedition page link</b>
<p class="indent"><b>Remaining work:</b>
<p>continue to build up the network; </p>
<p>tables of trips per year per person;</p>
<p>(separate out the recent/notable people) vast front-page layout table of folks and caving trips and years; </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>Improve logbook wikihtml text</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>
<p>tables of trips per year per person;</p>
<h3>{{message}}</h3>
<ul>
<li><a href="{% url personindex %}">List of People</a></li>
<li><a href="{% url caveindex %}">List of Caves</a></li>
<li><b><a href="{% url personindex %}">List of People</a></b></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="{% url survexindex all %}">Survex directory</a></li>
<li><a href="{% url survey %}">Survey files</a></li>
@ -40,13 +39,11 @@
</form>
<ul id="expeditionlist">
{% for expedition in expeditions %}
<li>
<a href="{% url expedition expedition.year %}">{{expedition.name}}</a>
</li>
{% endfor %}
{% for expedition in expeditions %}
<li>
<a href="{% url expedition expedition.year %}">{{expedition.name}}</a>
</li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -8,7 +8,12 @@
<div id="col2">
<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>
{% if logbookentry.logbookentry_prev %}

View File

@ -36,7 +36,12 @@
{% for persontrip in persondate.1.persontrips %}
<tr>
<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>
{% endfor %}
</table>

View File

@ -9,8 +9,10 @@ urlpatterns = patterns('',
(r'^$', frontPage),
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>[^/]+)/edit/$', edit_cave),
(r'^cavesearch', caveSearch),

View File

@ -282,7 +282,7 @@ FRIDAY 28th JULY
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