From 7fc1602f7ac3affcbbe8d1d015b42bdff585e61c Mon Sep 17 00:00:00 2001 From: martin speleo Date: Sat, 4 Jul 2009 18:11:20 +0100 Subject: [PATCH] [svn] Initial and poor attempt at a view for cave descriptions. --- core/views_caves.py | 10 ++++++++-- templates/cave_description.html | 20 ++++++++++++++++++++ urls.py | 5 +++-- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 templates/cave_description.html diff --git a/core/views_caves.py b/core/views_caves.py index af91742..fde7bbb 100644 --- a/core/views_caves.py +++ b/core/views_caves.py @@ -1,4 +1,4 @@ -from troggle.core.models import Cave, CaveAndEntrance, Survey, Expedition, QM +from troggle.core.models import Cave, CaveAndEntrance, Survey, Expedition, QM, CaveDescription import troggle.core.models as models import troggle.settings as settings from django.forms.models import formset_factory @@ -7,6 +7,7 @@ from utils import render_with_context # see views_logbooks for explanation on th from django.http import HttpResponseRedirect from django.conf import settings import re, urlparse +from django.shortcuts import get_object_or_404 def getCave(cave_id): """Returns a cave object when given a cave name or number. It is used by views including cavehref, ent, and qm.""" @@ -83,5 +84,10 @@ def survey(request,year,wallet_number): notes=current_survey.scannedimage_set.filter(contents='notes') planSketches=current_survey.scannedimage_set.filter(contents='plan') elevationSketches=current_survey.scannedimage_set.filter(contents='elevation') - + return render_with_context(request,'survey.html', locals()) + +def cave_description(request, cavedescription_name): + cave_description = get_object_or_404(CaveDescription, short_name = cavedescription_name) + print cave_description.long_name + return render_with_context(request,'cave_description.html', locals()) \ No newline at end of file diff --git a/templates/cave_description.html b/templates/cave_description.html new file mode 100644 index 0000000..f41d9fd --- /dev/null +++ b/templates/cave_description.html @@ -0,0 +1,20 @@ +{% extends "cavebase.html" %} +{% load wiki_markup %} +{% load mptt_tags %} +{% block title %} {{cave_description.short_name}} {% endblock title %} +{% block editLink %}Edit description {{cave_description}}{% endblock %} + +{% block contentheader %} + {{cave_description.long_name}} +{% endblock contentheader %} + + + +{% block content %} + +

{{cave_description.long_name}}

+

+ {{cave_description.description|wiki_to_html}} +

+ +{% endblock content %} \ No newline at end of file diff --git a/urls.py b/urls.py index e6dcaa5..0123080 100644 --- a/urls.py +++ b/urls.py @@ -27,14 +27,15 @@ urlpatterns = patterns('', url(r'^expeditions/?$', object_list, {'queryset':Expedition.objects.all(),'template_name':'object_list.html'},name="expeditions"), url(r'^personexpedition/(?P[A-Z]*[a-z]*)[^a-zA-Z]*(?P[A-Z]*[a-z]*)/(?P\d+)/?$', views_logbooks.personexpedition, name="personexpedition"), url(r'^logbookentry/(?P.*)/(?P.*)/?$', views_logbooks.logbookentry,name="logbookentry"), - + url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"), url(r'^cave/(?P[^/]+)/?$', views_caves.cave, name="cave"), + url(r'^cavedescription/(?P[^/]*)/$', views_caves.cave_description, name="cavedescription"), #url(r'^cavehref/(.+)$', views_caves.cave, name="cave"),url(r'cave'), url(r'^jgtfile/(.*)$', view_surveys.jgtfile, name="jgtfile"), url(r'^jgtuploadfile$', view_surveys.jgtuploadfile, name="jgtuploadfile"), - + url(r'^cave/(?P[^/]+)/?(?P[^/])$', ent), #(r'^cave/(?P[^/]+)/edit/$', edit_cave), #(r'^cavesearch', caveSearch),