From 268d69214d0fd61236da0b9df307cd4081f2ab58 Mon Sep 17 00:00:00 2001 From: substantialnoninfringinguser Date: Wed, 13 May 2009 06:28:36 +0100 Subject: [PATCH] [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 --- expo/models.py | 22 ++++++++-------- expo/views_caves.py | 11 ++++---- settings.py | 2 +- templates/subcave.html | 45 ++++++++++++++++++++++++++++++++ templates/todo.html | 59 ++++++++++++++++++++++++++++++++++++++++++ urls.py | 2 +- 6 files changed, 123 insertions(+), 18 deletions(-) create mode 100644 templates/subcave.html create mode 100644 templates/todo.html 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 %}Edit subcave {{subcave|wiki_to_html_short}}{% endblock %} +{% block content %} + +

{{subcave}}

+

+ {{subcave.description}} +

+ +
+ +

Related places

+ +

Parent

+ + + +

Connected subareas

+ + + +

Children

+ + + + +
+ +{% 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 %} + +

The unfinished front page

+ + +

Further work

+ +

Julian's work: +

parse 1992-1976 logbooks; (esp top 161)

+

detect T/U on log entries;

+

name matching and spelling in survex files;

+

Improve logbook wikihtml text

+ +

Other work:

+

surf through the tunnel sketches and images

+

bugs with all.svx block (double dot) +

render bitmap view of every survex block as a thumbnail

+

upload tunnel images and tunnel sketches

+

where are the subcaves;

+

cave section entrance match for logbook entries

+

simplify the survex parsing code (if necessary);

+

wiki survex stop linegap between comment lins

+

links between logbooks and survex blocks to cave things;

+

mini-tree of survexblocks;

+

connect sketches to caves to survey blocks and render thumbnailwise;

+

all images to start appearing in pages; and so on

+ +

{{message}}

+ +
+ + +
+ + + +{% 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[^/]+)/?(?P[^/])$', ent), #(r'^cave/(?P[^/]+)/edit/$', edit_cave), #(r'^cavesearch', caveSearch), - url(r'^cave/(?P[^/]+)/(?P[a-zA-Z/]+)/?$', subcave, name="subcave"), + url(r'^cave/(?P[^/]+)(?P/.*)/?$', subcave, name="subcave"), url(r'^survex/(.*?)\.index$', views_survex.index, name="survexindex"),