forked from expo/troggle
[svn] Made the subcaves work! Now we just have to figure out how to parse them...
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8343 by cucc @ 5/11/2009 6:36 AM
This commit is contained in:
parent
7164296c9d
commit
0f64e786b5
@ -1,17 +1,14 @@
|
||||
import urllib
|
||||
import string
|
||||
import urllib, urlparse, string, os, datetime
|
||||
from django.forms import ModelForm
|
||||
from django.db import models
|
||||
from django.contrib import admin
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
import os
|
||||
from django.conf import settings
|
||||
import datetime
|
||||
from decimal import Decimal, getcontext
|
||||
from django.core.urlresolvers import reverse
|
||||
from troggle.imagekit.models import ImageModel
|
||||
from django.core.urlresolvers import reverse
|
||||
from imagekit.models import ImageModel
|
||||
getcontext().prec=2 #use 2 significant figures for decimal calculations
|
||||
|
||||
from models_survex import *
|
||||
@ -462,7 +459,7 @@ class Subcave(TroggleModel):
|
||||
description = models.TextField()
|
||||
name = models.CharField(max_length=200, )
|
||||
cave = models.ForeignKey('Cave', blank=True, null=True, help_text="Only the top-level subcave should be linked to a cave")
|
||||
parent= models.ForeignKey('Subcave', blank=True, null=True,)
|
||||
parent= models.ForeignKey('Subcave', blank=True, null=True, related_name='children')
|
||||
adjoining = models.ManyToManyField('Subcave',blank=True, null=True,)
|
||||
survex_file = models.CharField(max_length=200, blank=True, null=True,)
|
||||
|
||||
@ -473,14 +470,17 @@ class Subcave(TroggleModel):
|
||||
urlString=self.name
|
||||
if self.parent:
|
||||
parent=self.parent
|
||||
while parent.parent:
|
||||
while parent: #recursively walk up the tree, adding parents to the left of the URL
|
||||
urlString=parent.name+'/'+urlString
|
||||
if parent.cave:
|
||||
cave=parent.cave
|
||||
parent=parent.parent
|
||||
urlString=unicode(parent.cave.kataster_number)+urlString
|
||||
urlString='cave/'+unicode(cave.kataster_number)+'/'+urlString
|
||||
else:
|
||||
urlString=unicode(self.cave.kataster_number)+urlString
|
||||
urlString='cave/'+unicode(self.cave.kataster_number)+'/'+urlString
|
||||
|
||||
return settings.URL_ROOT + urlString
|
||||
|
||||
return urlparse.urljoin(settings.URL_ROOT, urlString)
|
||||
|
||||
class QM(TroggleModel):
|
||||
#based on qm.csv in trunk/expoweb/smkridge/204 which has the fields:
|
||||
|
@ -54,15 +54,16 @@ def survexblock(request, survexpath):
|
||||
|
||||
def subcave(request, cave_id, subcave):
|
||||
print subcave
|
||||
subcaveSeq=re.findall('([a-zA-Z]*)(?:/)',subcave)
|
||||
subcaveSeq=re.findall('(?:/)([^/]*)',subcave)
|
||||
print subcaveSeq
|
||||
cave=models.Cave.objects.filter(kataster_number = cave_id)[0]
|
||||
cave=models.Cave.objects.get(kataster_number = cave_id)
|
||||
subcave=models.Subcave.objects.get(name=subcaveSeq[0], cave=cave)
|
||||
if len(subcaveSeq)>1:
|
||||
for singleSubcave in subcaveSeq[1:]:
|
||||
subcave=subcave.subcave_set.get(name=singleSubcave)
|
||||
for subcaveUrlSegment in subcaveSeq[1:]:
|
||||
if subcaveUrlSegment:
|
||||
subcave=subcave.children.get(name=subcaveUrlSegment)
|
||||
print subcave
|
||||
return render_response(request,'subcave.html', {'subcave': subcave,})
|
||||
return render_response(request,'subcave.html', {'subcave': subcave,'cave':cave})
|
||||
|
||||
def caveSearch(request):
|
||||
query_string = ''
|
||||
|
@ -84,5 +84,5 @@ INSTALLED_APPS = (
|
||||
'troggle.registration',
|
||||
'troggle.profiles',
|
||||
'troggle.expo',
|
||||
'troggle.imagekit',
|
||||
'troggle.imagekit',
|
||||
)
|
||||
|
45
templates/subcave.html
Normal file
45
templates/subcave.html
Normal file
@ -0,0 +1,45 @@
|
||||
{% extends "cavebase.html" %}
|
||||
{% load wiki_markup %}
|
||||
{% block title %} Subcave {{subcave}} {% endblock title %}
|
||||
{% block editLink %}<a href={{subcave.get_admin_url}}>Edit subcave {{subcave|wiki_to_html_short}}</a>{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<h2>{{subcave}}</h2>
|
||||
<p>
|
||||
{{subcave.description}}
|
||||
</p>
|
||||
|
||||
<div id="col2">
|
||||
|
||||
<h2>Related places</h2>
|
||||
|
||||
<h3>Parent</h3>
|
||||
|
||||
<ul>
|
||||
{% if subcave.parent %}
|
||||
<li><a href="{{subcave.parent.get_absolute_url}}">{{subcave.parent}}</a></li>
|
||||
{% else %}
|
||||
<li><a href="{{subcave.cave.get_absolute_url}}">{{subcave.cave}}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
<h3>Connected subareas</h3>
|
||||
|
||||
<ul>
|
||||
{% for sibling in subcave.adjoining.all%}
|
||||
<li><a href="{{sibling.get_absolute_url}}">{{silbling}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h3>Children</h3>
|
||||
|
||||
<ul>
|
||||
{% for child in subcave.children.all %}
|
||||
<li><a href="{{child.get_absolute_url}}">{{child}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock content %}
|
59
templates/todo.html
Normal file
59
templates/todo.html
Normal file
@ -0,0 +1,59 @@
|
||||
{% extends "base.html" %}
|
||||
{% load wiki_markup %}
|
||||
|
||||
{% block title %}Cambridge Expeditions to Austria{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h2>The unfinished front page</h2>
|
||||
<ul>
|
||||
<li><b>About {{totallogbookentries}} logbook entries have been loaded</b></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="{% url jgtfile aaaa %}">JGT list of files</a> (temporary simple file list and tunnel use)</li>
|
||||
<li><a href="{% url survey %}">Survey files</a></li>
|
||||
<li><a href="{% url survexindex all %}">Survex directory</a></li>
|
||||
<li><a href="{% url expedition 2008 %}">Expedition 2008</a></li>
|
||||
<li><a href="{% url expedition 2007 %}">Expedition 2007</a></li>
|
||||
<li><a href="{% url expedition 1993 %}">Expedition 1993</a> (earliest parsed)</li>
|
||||
</ul>
|
||||
|
||||
<h2>Further work</h2>
|
||||
|
||||
<p>Julian's work:
|
||||
<p>parse 1992-1976 logbooks; (esp top 161)</p>
|
||||
<p>detect T/U on log entries; </p>
|
||||
<p>name matching and spelling in survex files; </p>
|
||||
<p>Improve logbook wikihtml text</p>
|
||||
|
||||
<p>Other work:</p>
|
||||
<p>surf through the tunnel sketches and images</p>
|
||||
<p>bugs with all.svx block (double dot)
|
||||
<p>render bitmap view of every survex block as a thumbnail</p>
|
||||
<p>upload tunnel images and tunnel sketches</p>
|
||||
<p>where are the subcaves; </p>
|
||||
<p>cave section entrance match for logbook entries</p>
|
||||
<p>simplify the survex parsing code (if necessary); </p>
|
||||
<p>wiki survex stop linegap between comment lins</p>
|
||||
<p>links between logbooks and survex blocks to cave things; </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>
|
||||
|
||||
<form action="" method="GET">
|
||||
<input type="submit" name="reloadexpos" value="Reload Expos">
|
||||
<input type="submit" name="reloadsurvex" value="Reload Survex">
|
||||
</form>
|
||||
|
||||
<ul id="expeditionlist">
|
||||
{% for expedition in expeditions %}
|
||||
<li>
|
||||
<a href="{% url expedition expedition.year %}">{{expedition.name}}</a>
|
||||
- <b>{{expedition.logbookentry_set.count}}</b> logbook entries
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
2
urls.py
2
urls.py
@ -36,7 +36,7 @@ urlpatterns = patterns('',
|
||||
url(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent),
|
||||
#(r'^cave/(?P<cave_id>[^/]+)/edit/$', edit_cave),
|
||||
#(r'^cavesearch', caveSearch),
|
||||
url(r'^cave/(?P<cave_id>[^/]+)/(?P<subcave>[a-zA-Z/]+)/?$', subcave, name="subcave"),
|
||||
url(r'^cave/(?P<cave_id>[^/]+)(?P<subcave>/.*)/?$', subcave, name="subcave"),
|
||||
|
||||
url(r'^survex/(.*?)\.index$', views_survex.index, name="survexindex"),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user