2009-05-13 05:13:38 +01:00
|
|
|
from django.shortcuts import render_to_response
|
2009-05-13 05:31:21 +01:00
|
|
|
from troggle.expo.models import Cave, CaveAndEntrance, Survey, Expedition
|
2009-05-13 05:39:52 +01:00
|
|
|
import troggle.expo.models as models
|
2009-05-13 05:13:38 +01:00
|
|
|
import troggle.settings as settings
|
2009-05-13 05:22:14 +01:00
|
|
|
from troggle.expo.forms import CaveForm
|
|
|
|
import search
|
2009-05-13 05:13:38 +01:00
|
|
|
|
|
|
|
def caveindex(request):
|
|
|
|
caves = Cave.objects.all()
|
2009-05-13 05:48:47 +01:00
|
|
|
notablecavehrefs = [ "161", "204", "258", "76" ] # could detect notability by trips and notability of people who have been down them
|
2009-05-13 05:46:12 +01:00
|
|
|
notablecaves = [ Cave.objects.get(href=href) for href in notablecavehrefs ]
|
|
|
|
return render_to_response('caveindex.html', {'caves': caves, 'notablecaves':notablecaves, 'settings': settings})
|
2009-05-13 05:13:38 +01:00
|
|
|
|
2009-05-13 05:46:12 +01:00
|
|
|
def cavehref(request, href):
|
|
|
|
cave = Cave.objects.get(href=href)
|
|
|
|
return render_to_response('cave.html', {'cave': cave, 'settings': settings})
|
|
|
|
|
|
|
|
|
2009-05-13 05:13:38 +01:00
|
|
|
def ent(request, cave_id, ent_letter):
|
|
|
|
cave = Cave.objects.filter(kataster_number = cave_id)[0]
|
|
|
|
cave_and_ent = CaveAndEntrance.objects.filter(cave = cave).filter(entrance_letter = ent_letter)[0]
|
|
|
|
return render_to_response('entrance.html', {'cave': cave,
|
|
|
|
'entrance': cave_and_ent.entrance,
|
|
|
|
'letter': cave_and_ent.entrance_letter,
|
|
|
|
'settings': settings})
|
2009-05-13 05:39:52 +01:00
|
|
|
def survexblock(request, survexpath):
|
|
|
|
survexblock = models.SurvexBlock.objects.get(survexpath=survexpath)
|
|
|
|
#ftext = survexblock.filecontents()
|
|
|
|
ftext = survexblock.text
|
|
|
|
return render_to_response('survexblock.html', {'survexblock':survexblock, 'ftext':ftext, 'settings':settings })
|
2009-05-13 05:22:14 +01:00
|
|
|
|
2009-05-13 05:45:26 +01:00
|
|
|
def caveArea(request, name):
|
|
|
|
cavearea = models.CaveArea.objects.get(name = name)
|
|
|
|
cave = cavearea.cave
|
|
|
|
return render_to_response('cavearea.html', {'cavearea': cavearea, 'cave': cave, 'settings':settings })
|
|
|
|
|
2009-05-13 05:22:14 +01:00
|
|
|
def caveSearch(request):
|
|
|
|
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, ['underground_description','official_name',])
|
|
|
|
found_entries = Cave.objects.filter(entry_query)
|
|
|
|
|
|
|
|
return render_to_response('cavesearch.html',
|
|
|
|
{ 'query_string': query_string, 'found_entries': found_entries, 'settings': settings})
|
|
|
|
#context_instance=RequestContext(request))
|
|
|
|
|
2009-05-13 05:27:43 +01:00
|
|
|
def surveyindex(request):
|
|
|
|
surveys=Survey.objects.all()
|
2009-05-13 05:31:21 +01:00
|
|
|
expeditions=Expedition.objects.all()
|
|
|
|
dictToPass=locals()
|
|
|
|
dictToPass.update({'settings':settings})
|
|
|
|
return render_to_response('survey.html',dictToPass)
|
2009-05-13 05:27:43 +01:00
|
|
|
|
2009-05-13 05:31:21 +01:00
|
|
|
def survey(request,year,wallet_number):
|
2009-05-13 05:27:43 +01:00
|
|
|
surveys=Survey.objects.all()
|
2009-05-13 05:31:21 +01:00
|
|
|
expeditions=Expedition.objects.all()
|
|
|
|
current_expedition=Expedition.objects.filter(year=year)[0]
|
|
|
|
|
|
|
|
if wallet_number!='':
|
|
|
|
current_survey=Survey.objects.filter(expedition=current_expedition,wallet_number=wallet_number)[0]
|
|
|
|
notes=current_survey.scannedimage_set.filter(contents='notes')
|
|
|
|
planSketches=current_survey.scannedimage_set.filter(contents='plan')
|
|
|
|
elevationSketches=current_survey.scannedimage_set.filter(contents='elevation')
|
|
|
|
|
2009-05-13 05:27:43 +01:00
|
|
|
dictToPass=locals()
|
|
|
|
dictToPass.update({'settings':settings})
|
|
|
|
|
2009-05-13 05:39:52 +01:00
|
|
|
return render_to_response('survey.html',dictToPass)
|
|
|
|
|