From 8c818906b5c1228a6fb411cb96d1bd5f1663b49a Mon Sep 17 00:00:00 2001 From: substantialnoninfringinguser Date: Wed, 13 May 2009 05:24:37 +0100 Subject: [svn] Added QM model and parser. Had to merge models_cave.py and models_logbooks.py into models.py. This is because logbook entries now have an optional foreign key to caves, and QMs have a required foreign key to a logbook entry of the trip that created them. So, the two files became circularly dependent. Also, the urls for the person model now allow lookups using their actual first and last name in the url instead of the primary key. We should do similar things for all models, maybe even using the url as a search which results in a page with multiple model instance results if the input is ambiguous (e.g. they only enter a first name). Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8093 by aaron @ 12/13/2008 11:17 PM --- expo/views_logbooks.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'expo/views_logbooks.py') diff --git a/expo/views_logbooks.py b/expo/views_logbooks.py index b44c770..ac1954a 100644 --- a/expo/views_logbooks.py +++ b/expo/views_logbooks.py @@ -2,13 +2,17 @@ from django.shortcuts import render_to_response from troggle.expo.models import Expedition, Person, PersonExpedition, PersonTrip, LogbookEntry import troggle.settings as settings import search +import re def personindex(request): persons = Person.objects.all() return render_to_response('personindex.html', {'persons': persons, 'settings': settings}) -def person(request, person_id): - person = Person.objects.filter(id = person_id)[0] +def person(request, person_id, first_name, last_name): + if first_name == '' or last_name == '': + person = Person.objects.filter(id = person_id)[0] + else: + person = Person.objects.filter(first_name = first_name, last_name = last_name)[0] return render_to_response('person.html', {'person': person, 'settings': settings}) def logbookentry(request, logbookentry_id): @@ -25,4 +29,4 @@ def logbookSearch(request, extra): return render_to_response('logbooksearch.html', { 'query_string': query_string, 'found_entries': found_entries, 'settings': settings}) - #context_instance=RequestContext(request)) \ No newline at end of file + #context_instance=RequestContext(request)) -- cgit v1.2.3