2009-05-13 05:14:51 +01:00
|
|
|
from django.shortcuts import render_to_response
|
|
|
|
from troggle.expo.models import Expedition, Person, PersonExpedition, PersonTrip, LogbookEntry
|
|
|
|
import troggle.settings as settings
|
2009-05-13 05:39:52 +01:00
|
|
|
|
2009-05-13 05:35:59 +01:00
|
|
|
from troggle.parsers.logbooks import LoadLogbookForExpedition
|
2009-05-13 05:39:52 +01:00
|
|
|
from troggle.parsers.people import GetPersonExpeditionNameLookup
|
|
|
|
|
2009-05-13 05:22:14 +01:00
|
|
|
import search
|
2009-05-13 05:24:37 +01:00
|
|
|
import re
|
2009-05-13 05:14:51 +01:00
|
|
|
|
|
|
|
def personindex(request):
|
|
|
|
persons = Person.objects.all()
|
|
|
|
return render_to_response('personindex.html', {'persons': persons, 'settings': settings})
|
|
|
|
|
2009-05-13 05:35:59 +01:00
|
|
|
def expedition(request, expeditionname):
|
|
|
|
year = int(expeditionname)
|
|
|
|
expedition = Expedition.objects.get(year=year)
|
|
|
|
expedition_next = Expedition.objects.filter(year=year+1) and Expedition.objects.get(year=year+1) or None
|
|
|
|
expedition_prev = Expedition.objects.filter(year=year-1) and Expedition.objects.get(year=year-1) or None
|
|
|
|
message = "No message"
|
|
|
|
if "reload" in request.GET:
|
|
|
|
message = LoadLogbookForExpedition(expedition)
|
2009-05-13 05:39:52 +01:00
|
|
|
#message = str(GetPersonExpeditionNameLookup(expedition).keys())
|
2009-05-13 05:35:59 +01:00
|
|
|
logbookentries = expedition.logbookentry_set.order_by('date')
|
|
|
|
return render_to_response('expedition.html', {'expedition': expedition, 'expedition_next':expedition_next, 'expedition_prev':expedition_prev, 'logbookentries':logbookentries, 'message':message, 'settings': settings})
|
|
|
|
|
|
|
|
def person(request, name):
|
2009-05-13 05:38:18 +01:00
|
|
|
person = Person.objects.get(href=name)
|
2009-05-13 05:14:51 +01:00
|
|
|
return render_to_response('person.html', {'person': person, 'settings': settings})
|
|
|
|
|
2009-05-13 05:38:18 +01:00
|
|
|
def personexpedition(request, name, expeditionname):
|
|
|
|
person = Person.objects.get(href=name)
|
|
|
|
year = int(expeditionname)
|
|
|
|
expedition = Expedition.objects.get(year=year)
|
|
|
|
personexpedition = person.personexpedition_set.get(expedition=expedition)
|
|
|
|
return render_to_response('personexpedition.html', {'personexpedition': personexpedition, 'settings': settings})
|
|
|
|
|
|
|
|
|
2009-05-13 05:15:49 +01:00
|
|
|
def logbookentry(request, logbookentry_id):
|
2009-05-13 05:38:18 +01:00
|
|
|
logbookentry = LogbookEntry.objects.filter(href = logbookentry_id)[0]
|
2009-05-13 05:15:49 +01:00
|
|
|
return render_to_response('logbookentry.html', {'logbookentry': logbookentry, 'settings': settings})
|
|
|
|
|
2009-05-13 05:35:59 +01:00
|
|
|
|
2009-05-13 05:22:14 +01:00
|
|
|
def logbookSearch(request, extra):
|
|
|
|
query_string = ''
|
|
|
|
found_entries = None
|
|
|
|
if ('q' in request.GET) and request.GET['q'].strip():
|
|
|
|
query_string = request.GET['q']
|
|
|
|
entry_query = search.get_query(query_string, ['text','title',])
|
|
|
|
found_entries = LogbookEntry.objects.filter(entry_query)
|
2009-05-13 05:15:49 +01:00
|
|
|
|
2009-05-13 05:22:14 +01:00
|
|
|
return render_to_response('logbooksearch.html',
|
|
|
|
{ 'query_string': query_string, 'found_entries': found_entries, 'settings': settings})
|
2009-05-13 05:24:37 +01:00
|
|
|
#context_instance=RequestContext(request))
|