forked from expo/troggle
[svn] cave maps to all logbook entry trips done there
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8228 by julian @ 1/24/2009 11:59 PM
This commit is contained in:
parent
84e9cc3396
commit
cdd4e685ee
@ -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
|
||||
|
@ -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)
|
||||
@ -474,3 +481,5 @@ class Survey(models.Model):
|
||||
|
||||
def elevations(self):
|
||||
return self.scannedimage_set.filter(contents='elevation')
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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,15 +135,20 @@ def html_to_wiki(text):
|
||||
text2 = ""
|
||||
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):
|
||||
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]
|
||||
area1626 = models.Area.objects.filter(short_name = '1626')[0]
|
||||
area1623 = models.Area.objects.filter(short_name = '1623')[0]
|
||||
|
||||
counter=0
|
||||
for line in caveReader :
|
||||
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
|
||||
@ -174,6 +176,7 @@ for line in caveReader :
|
||||
addToArgs(Notes, "notes")
|
||||
|
||||
newCave = models.Cave(**args)
|
||||
newCave.Sethref()
|
||||
newCave.save()
|
||||
|
||||
if line[Area]:
|
||||
@ -195,6 +198,7 @@ for line in caveReader :
|
||||
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':
|
||||
@ -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
|
||||
|
||||
|
@ -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("|")
|
||||
|
@ -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 %}
|
||||
|
@ -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 %}
|
@ -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>
|
||||
|
||||
{% if logbookentry.cave %}
|
||||
<td><a href="{% url cave logbookentry.cave.href %}">{{logbookentry.place}}</a></td>
|
||||
{% else %}
|
||||
<td>{{logbookentry.place}}</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
@ -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>
|
||||
{% for expedition in expeditions %}
|
||||
<li>
|
||||
<a href="{% url expedition expedition.year %}">{{expedition.name}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
@ -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 %}
|
||||
|
@ -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>
|
||||
|
4
urls.py
4
urls.py
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user