summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsubstantialnoninfringinguser <substantialnoninfringinguser@gmail.com>2009-05-13 06:28:36 +0100
committersubstantialnoninfringinguser <substantialnoninfringinguser@gmail.com>2009-05-13 06:28:36 +0100
commit268d69214d0fd61236da0b9df307cd4081f2ab58 (patch)
treed5001ac40c1f9d3fcf699e1c54b014693a5b6b17
parent987bd56edd333a5f4b1eab407f75e9bd179abe19 (diff)
downloadtroggle-268d69214d0fd61236da0b9df307cd4081f2ab58.tar.gz
troggle-268d69214d0fd61236da0b9df307cd4081f2ab58.tar.bz2
troggle-268d69214d0fd61236da0b9df307cd4081f2ab58.zip
[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
-rw-r--r--expo/models.py22
-rw-r--r--expo/views_caves.py11
-rw-r--r--settings.py2
-rw-r--r--templates/subcave.html45
-rw-r--r--templates/todo.html59
-rw-r--r--urls.py2
6 files changed, 123 insertions, 18 deletions
diff --git a/expo/models.py b/expo/models.py
index 6331c0c..3472a01 100644
--- a/expo/models.py
+++ b/expo/models.py
@@ -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:
diff --git a/expo/views_caves.py b/expo/views_caves.py
index 1e11602..691cdcb 100644
--- a/expo/views_caves.py
+++ b/expo/views_caves.py
@@ -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 = ''
diff --git a/settings.py b/settings.py
index 777a0a9..449faf4 100644
--- a/settings.py
+++ b/settings.py
@@ -84,5 +84,5 @@ INSTALLED_APPS = (
'troggle.registration',
'troggle.profiles',
'troggle.expo',
- 'troggle.imagekit',
+ 'troggle.imagekit',
)
diff --git a/templates/subcave.html b/templates/subcave.html
new file mode 100644
index 0000000..c635833
--- /dev/null
+++ b/templates/subcave.html
@@ -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 %} \ No newline at end of file
diff --git a/templates/todo.html b/templates/todo.html
new file mode 100644
index 0000000..1c9fd3b
--- /dev/null
+++ b/templates/todo.html
@@ -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 %}
diff --git a/urls.py b/urls.py
index 780fdb0..ee4dc62 100644
--- a/urls.py
+++ b/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"),