2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 16:51:54 +00:00

[svn] My crusade to make our project more Djangoic.

Got rid of the url tags in template, replaced them with get_absolute_url method calls where possible. Adding get_absolute_url in models enables direct link to the public model views in admin. The use of get_absolute_url, which is the correct Django way of doing things, eliminates any need for the redundant "href" fields we were using. Those fields now need to be deleted from the models and from the parsers.

Made the context processor to pass settings to all templates actually work, although this was a little uglier than expected. I had to put in a new render_response to replace render_to_response. This is because Django uses Context, not RequestContext by default. I wish they would change this, it's annoying. Anyway, I deleted all the manual settings passing in the views.

I also eliminated a couple of unnecessary methods and stuff like that.
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8244 by aaron @ 2/16/2009 8:31 AM
This commit is contained in:
substantialnoninfringinguser 2009-05-13 05:52:15 +01:00
parent 3b35b6bb76
commit d25fd97864
21 changed files with 220 additions and 176 deletions

View File

@ -1,7 +0,0 @@
import troggle.settings as settings
def settingsContext(request):
return { 'settings.MEDIA_URL':settings.MEDIA_URL,
'settings.URL_ROOT':settings.URL_ROOT,
'settings.ADMIN_MEDIA_PREFIX':settings.ADMIN_MEDIA_PREFIX,
'settings.SVX_URL':settings.SVX_URL }

View File

@ -29,8 +29,12 @@ class PersonAdmin(admin.ModelAdmin):
class PersonExpeditionAdmin(admin.ModelAdmin):
search_fields = ('person__first_name','expedition__year')
class CaveAdmin(admin.ModelAdmin):
search_fields = ('official_name','kataster_number','unofficial_number')
extra = 4
admin.site.register(Photo)
admin.site.register(Cave)
admin.site.register(Cave, CaveAdmin)
admin.site.register(Area)
admin.site.register(OtherCaveName)
admin.site.register(CaveAndEntrance)

4
expo/context.py Normal file
View File

@ -0,0 +1,4 @@
from django.conf import settings
def settings_context(request):
return { 'settings':settings }

View File

@ -22,6 +22,10 @@ class Expedition(models.Model):
class Meta:
ordering = ('year',)
get_latest_by = 'date_from'
def get_absolute_url(self):
return settings.URL_ROOT + "/expedition/%s" % self.year
# lose these two functions (inelegant, and we may create a file with the dates that we can load from)
def GuessDateFrom(self):
@ -66,6 +70,8 @@ class Person(models.Model):
notability = models.FloatField() # for listing the top 20 people
bisnotable = models.BooleanField()
user = models.ForeignKey(User, unique=True, null=True, blank=True)
def get_absolute_url(self):
return settings.URL_ROOT + "/person/%s_%s/" % (self.first_name, self.last_name)
class Meta:
verbose_name_plural = "People"
@ -77,11 +83,12 @@ class Person(models.Model):
return "%s %s" % (self.first_name, self.last_name)
return self.first_name
# Below are no longer needed. Use {{ person.personexpedition_set.all.0.expedition }} for Firstexpedition, and {{ person.personexpedition_set.latest.expedition }} for Lastexpedition
# these ought to be possible by piping through |min in the template, or getting the first of an ordered list
def Firstexpedition(self):
return self.personexpedition_set.order_by('expedition')[0]
def Lastexpedition(self):
return self.personexpedition_set.order_by('-expedition')[0]
# def Firstexpedition(self):
# return self.personexpedition_set.order_by('expedition')[0]
# def Lastexpedition(self):
# return self.personexpedition_set.order_by('-expedition')[0]
def Sethref(self):
if self.last_name:
@ -99,6 +106,14 @@ class PersonExpedition(models.Model):
date_from = models.DateField(blank=True,null=True)
date_to = models.DateField(blank=True,null=True)
is_guest = models.BooleanField(default=False)
COMMITTEE_CHOICES = (
('leader','Expo leader'),
('medical','Expo medical officer'),
('treasurer','Expo treasurer'),
('sponsorship','Expo sponsorship coordinator'),
('research','Expo research coordinator'),
)
expo_committee_position = models.CharField(blank=True,null=True,choices=COMMITTEE_CHOICES,max_length=200)
nickname = models.CharField(max_length=100,blank=True,null=True)
def GetPersonroles(self):
@ -112,6 +127,7 @@ class PersonExpedition(models.Model):
class Meta:
ordering = ('expedition',)
get_latest_by = 'date_from'
def GetPersonChronology(self):
res = { }
@ -130,8 +146,8 @@ class PersonExpedition(models.Model):
# needs converting dict into list
return sorted(res.items())
# don't use tabs.
# possibly not useful functions anyway
# possibly not useful functions anyway -JT
# if you can find a better way to make the expo calendar table, be my guest. It isn't possible to do this logic in a django template without writing custom tags.
def ListDays(self):
if self.date_from and self.date_to:
res=[]
@ -151,6 +167,7 @@ class PersonExpedition(models.Model):
def __unicode__(self):
return "%s: (%s)" % (self.person, self.expedition)
#why is the below a function in personexpedition, rather than in person? - AC 14 Feb 09
def name(self):
if self.nickname:
return "%s (%s) %s" % (self.person.first_name, self.nickname, self.person.last_name)
@ -158,6 +175,8 @@ class PersonExpedition(models.Model):
return "%s %s" % (self.person.first_name, self.person.last_name)
return self.person.first_name
def get_absolute_url(self):
return settings.URL_ROOT + '/personexpedition/' + str(self.person.first_name) + '_' + str(self.person.last_name) + '/' +self.expedition.year
class LogbookEntry(models.Model):
date = models.DateField()
@ -167,11 +186,11 @@ class LogbookEntry(models.Model):
cave = models.ForeignKey('Cave',blank=True,null=True)
place = models.CharField(max_length=100,blank=True,null=True)
text = models.TextField()
href = models.CharField(max_length=100)
#href = models.CharField(max_length=100)
# turn these into functions
logbookentry_next = models.ForeignKey('LogbookEntry', related_name='pnext', blank=True,null=True)
logbookentry_prev = models.ForeignKey('LogbookEntry', related_name='pprev', blank=True,null=True)
#logbookentry_next = models.ForeignKey('LogbookEntry', related_name='pnext', blank=True,null=True)
#logbookentry_prev = models.ForeignKey('LogbookEntry', related_name='pprev', blank=True,null=True)
class Meta:
verbose_name_plural = "Logbook Entries"
@ -179,10 +198,14 @@ class LogbookEntry(models.Model):
class Meta:
ordering = ('-date',)
def get_absolute_url(self):
return settings.URL_ROOT + "/logbookentry/" + str(self.pk)
def __unicode__(self):
return "%s: (%s)" % (self.date, self.title)
class PersonTrip(models.Model):
person_expedition = models.ForeignKey(PersonExpedition)
@ -252,13 +275,14 @@ class Cave(models.Model):
href = models.CharField(max_length=100)
def Sethref(self):
def get_absolute_url(self):
if self.kataster_number:
self.href = self.kataster_number
href = self.kataster_number
elif self.unofficial_number:
self.href = self.unofficial_number
href = self.unofficial_number
else:
self.href = official_name.lower()
href = official_name.lower()
return settings.URL_ROOT + '/cave/' + self.href + '/'
def __unicode__(self):

View File

@ -1,4 +1,5 @@
# primary namespace
import view_surveys
import views_caves
import views_survex

View File

@ -1,57 +1,57 @@
from django.shortcuts import render_to_response
from troggle.expo.models import Cave, CaveAndEntrance, Survey, Expedition
import troggle.expo.models as models
import troggle.settings as settings
from troggle.expo.forms import CaveForm
import search
from troggle.alwaysUseRequestContext import render_response # see views_logbooks for explanation on this.
def caveindex(request):
caves = Cave.objects.all()
notablecavehrefs = [ "161", "204", "258", "76" ] # could detect notability by trips and notability of people who have been down them
notablecaves = [ Cave.objects.get(href=href) for href in notablecavehrefs ]
return render_to_response('caveindex.html', {'caves': caves, 'notablecaves':notablecaves, 'settings': settings})
return render_response(request,'caveindex.html', {'caves': caves, 'notablecaves':notablecaves})
def cavehref(request, href):
cave = Cave.objects.get(href=href)
return render_to_response('cave.html', {'cave': cave, 'settings': settings})
def cavehref(request, cave_id='', offical_name=''):
try:
cave = Cave.objects.get(kataster_number=cave_id)
except DoesNotExist:
cave = Cave.objects.get(unofficial_number=cave_id)
return render_response(request,'cave.html', {'cave': cave,})
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,
return render_response(request,'entrance.html', {'cave': cave,
'entrance': cave_and_ent.entrance,
'letter': cave_and_ent.entrance_letter,
'settings': settings})
'letter': cave_and_ent.entrance_letter,})
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 })
return render_response(request,'survexblock.html', {'survexblock':survexblock, 'ftext':ftext, })
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 })
return render_response(request,'cavearea.html', {'cavearea': cavearea, 'cave': cave,})
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)
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))
return render_response(request,'cavesearch.html',
{ 'query_string': query_string, 'found_entries': found_entries,})
def surveyindex(request):
surveys=Survey.objects.all()
expeditions=Expedition.objects.all()
dictToPass=locals()
dictToPass.update({'settings':settings})
return render_to_response('survey.html',dictToPass)
return render_response(request,'survey.html',locals())
def survey(request,year,wallet_number):
surveys=Survey.objects.all()
@ -64,8 +64,5 @@ def survey(request,year,wallet_number):
planSketches=current_survey.scannedimage_set.filter(contents='plan')
elevationSketches=current_survey.scannedimage_set.filter(contents='elevation')
dictToPass=locals()
dictToPass.update({'settings':settings})
return render_to_response('survey.html',dictToPass)
return render_response(request,'survey.html', locals())

View File

@ -6,11 +6,15 @@ from troggle.parsers.logbooks import LoadLogbookForExpedition
from troggle.parsers.people import GetPersonExpeditionNameLookup
from troggle.expo.forms import PersonForm
# Django uses Context, not RequestContext when you call render_to_response. We always want to use RequestContext, so that django adds the context from settings.TEMPLATE_CONTEXT_PROCESSORS. This way we automatically get necessary settings variables passed to each template. So we use a custom method, render_response instead of render_to_response. Hopefully future Django releases will make this unnecessary.
from troggle.alwaysUseRequestContext import render_response
import search
import re
def personindex(request):
persons = Person.objects.all()
# From what I can tell, "persons" seems to be the table rows, while "personss" is the table columns. - AC 16 Feb 09
personss = [ ]
ncols = 5
nc = (len(persons) + ncols - 1) / ncols
@ -18,7 +22,7 @@ def personindex(request):
personss.append(persons[i * nc: (i + 1) * nc])
notablepersons = Person.objects.filter(bisnotable=True)
return render_to_response('personindex.html', {'persons': persons, 'personss':personss, 'notablepersons':notablepersons, 'settings': settings})
return render_response(request,'personindex.html', {'persons': persons, 'personss':personss, 'notablepersons':notablepersons, })
def expedition(request, expeditionname):
year = int(expeditionname)
@ -30,22 +34,28 @@ def expedition(request, expeditionname):
message = LoadLogbookForExpedition(expedition)
#message = str(GetPersonExpeditionNameLookup(expedition).keys())
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})
return render_response(request,'expedition.html', {'expedition': expedition, 'expedition_next':expedition_next, 'expedition_prev':expedition_prev, 'logbookentries':logbookentries, 'message':message, })
def person(request, name):
person = Person.objects.get(href=name)
return render_to_response('person.html', {'person': person, 'settings': settings})
def person(request, first_name='', last_name=''):
person = Person.objects.get(first_name = first_name, last_name = last_name)
return render_response(request,'person.html', {'person': person, })
def personexpedition(request, name, expeditionname):
person = Person.objects.get(href=name)
year = int(expeditionname)
def get_absolute_url(self):
return settings.URL_ROOT + self.first_name + '_' + self.last_name
#def person(request, name):
# person = Person.objects.get(href=name)
#
def personexpedition(request, first_name='', last_name='', year=''):
person = Person.objects.get(first_name = first_name, last_name = last_name)
expedition = Expedition.objects.get(year=year)
personexpedition = person.personexpedition_set.get(expedition=expedition)
return render_to_response('personexpedition.html', {'personexpedition': personexpedition, 'settings': settings})
return render_response(request,'personexpedition.html', {'personexpedition': personexpedition, })
def logbookentry(request, logbookentry_id):
logbookentry = LogbookEntry.objects.filter(href = logbookentry_id)[0]
return render_to_response('logbookentry.html', {'logbookentry': logbookentry, 'settings': settings})
def logbookentry(request, logbookentry_pk):
logbookentry = LogbookEntry.objects.get(pk = logbookentry_pk)
return render_response(request, 'logbookentry.html', {'logbookentry': logbookentry, })
def logbookSearch(request, extra):
query_string = ''
@ -55,11 +65,11 @@ def logbookSearch(request, extra):
entry_query = search.get_query(query_string, ['text','title',])
found_entries = LogbookEntry.objects.filter(entry_query)
return render_to_response('logbooksearch.html',
{ 'query_string': query_string, 'found_entries': found_entries, 'settings': settings})
return render_response(request,'logbooksearch.html',
{ 'query_string': query_string, 'found_entries': found_entries, })
#context_instance=RequestContext(request))
def personForm(request,pk):
person=Person.objects.get(pk=pk)
form=PersonForm(instance=person)
return render_to_response('personform.html', {'form':form,'settings':settings})
return render_response(request,'personform.html', {'form':form,})

View File

@ -1,4 +1,3 @@
from django.shortcuts import render_to_response
from troggle.expo.models import Cave, Expedition, Person, LogbookEntry, PersonExpedition
import troggle.settings as settings
from django import forms
@ -9,6 +8,7 @@ from troggle.parsers.survex import LoadAllSurvexBlocks
import randSent
from django.core.urlresolvers import reverse
from troggle.alwaysUseRequestContext import render_response # see views_logbooks for explanation on this.
def stats(request):
statsDict={}
@ -16,7 +16,7 @@ def stats(request):
statsDict['caveCount'] = int(Cave.objects.count())
statsDict['personCount'] = int(Person.objects.count())
statsDict['logbookEntryCount'] = int(LogbookEntry.objects.count())
return render_to_response('statistics.html', statsDict)
return render_response(request,'statistics.html', statsDict)
def frontpage(request):
message = "no test message" #reverse('personn', kwargs={"name":"hkjhjh"})
@ -29,7 +29,7 @@ def frontpage(request):
#'randSent':randSent.randomLogbookSentence(),
expeditions = Expedition.objects.order_by("-year")
return render_to_response('index.html', {'expeditions':expeditions, 'settings':settings, 'all':'all', "message":message})
return render_response(request,'index.html', {'expeditions':expeditions, 'all':'all', "message":message})
def calendar(request,year):
week=['S','S','M','T','W','T','F']
@ -37,6 +37,4 @@ def calendar(request,year):
expedition=Expedition.objects.get(year=year)
PersonExpeditions=expedition.personexpedition_set.all()
dictToPass=locals()
dictToPass.update({'settings':settings})
return render_to_response('calendar.html', dictToPass)
return render_response(request,'calendar.html', locals())

View File

@ -58,7 +58,7 @@ def LoadPersonsExpos():
years = headers[5:]
years.append("2008")
for year in years:
expedition = models.Expedition(year = year, name = "CUCC expo%s" % year)
expedition = models.Expedition(year = year, name = "CUCC expo %s" % year)
expedition.save()

View File

@ -1,28 +1,24 @@
import sys
import os
import urllib
import types
#sys.path.append('C:\\Expo\\expoweb')
sys.path.append('C:\\Expo\\expoweb')
from troggle import *
#os.environ['DJANGO_SETTINGS_MODULE']='troggle.settings'
os.environ['DJANGO_SETTINGS_MODULE']='troggle.settings'
import troggle.settings as settings
import troggle.expo.models as models
import troggle.expo.fileAbstraction as fileAbstraction
#import settings
#import expo.models as models
import csv
import re
import datetime
import cStringIO
surveytab = fileAbstraction.readFile("Surveys.csv")
dialect=csv.Sniffer().sniff(surveytab)
surveyreader = csv.reader(cStringIO.StringIO(surveytab),dialect=dialect)
print surveyreader
surveytab = open(os.path.join(settings.SURVEYS, "Surveys.csv"))
dialect=csv.Sniffer().sniff(surveytab.read())
surveytab.seek(0,0)
surveyreader = csv.reader(surveytab,dialect=dialect)
headers = surveyreader.next()
header = dict(zip(headers, range(len(headers)))) #set up a dictionary where the indexes are header names and the values are column numbers
print header
# test if the expeditions have been added yet
if len(models.Expedition.objects.all())==0:
@ -31,7 +27,6 @@ if len(models.Expedition.objects.all())==0:
models.ScannedImage.objects.all().delete()
models.Survey.objects.all().delete()
for survey in surveyreader:
print type(survey), survey
walletNumberLetter = re.match(r'(?P<number>\d*)(?P<letter>[a-zA-Z]*)',survey[header['Survey Number']]) #I hate this, but some surveys have a letter eg 2000#34a. This line deals with that.
# print walletNumberLetter.groups()
@ -51,13 +46,12 @@ for survey in surveyreader:
# add survey scans
def parseSurveyScans(year):
yearDirList = fileAbstraction.dirsAsList(year.year)
for surveyFolder in yearDirList:
print surveyFolder
yearPath=os.path.join(settings.SURVEYS, year.year)
yearFileList=os.listdir(yearPath)
for surveyFolder in yearFileList:
try:
surveyNumber=re.match(r'\d\d\d\d#0*(\d+)',surveyFolder).groups()
scanList=fileAbstraction.filesAsList(year.year, surveyFolder)
print "BAR: ", year.year, surveyFolder, scanList
scanList=os.listdir(os.path.join(yearPath,surveyFolder))
except AttributeError:
print surveyFolder + " ignored"
continue
@ -65,7 +59,6 @@ def parseSurveyScans(year):
for scan in scanList:
try:
scanChopped=re.match(r'(?i).*(notes|elev|plan|elevation|extend)(\d*)\.(png|jpg|jpeg)',scan).groups()
print "BAR: ", scanChopped
scanType,scanNumber,scanFormat=scanChopped
except AttributeError:
print "Adding scans: " + scan + " ignored"
@ -89,7 +82,7 @@ def parseSurveyScans(year):
number_in_wallet=scanNumber,
survey=survey
)
print "Added scanned image at " + str(scanObj)
#print "Added scanned image at " + str(scanObj)
scanObj.save()
for year in models.Expedition.objects.filter(year__gte=2000): #expos since 2000, because paths and filenames were nonstandard before then

View File

@ -46,7 +46,7 @@ TEMPLATE_LOADERS = (
# 'django.template.loaders.eggs.load_template_source',
)
TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "troggle.context.settingsContext")
TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "expo.context.settings_context", )
LOGIN_REDIRECT_URL = '/'

View File

@ -21,6 +21,18 @@
{% endblock %}
{% block contentheader %}
<h2>Expedition members present calendar for {{ expedition.year }}</h2>
<table style="margin:0 auto">
<tr>
<td class='yes' width="10"></td><td>Expedition member present in Austria</td>
</tr>
<tr>
<td class='no' width="10"></td><td>Expedition member absent in Austria</td>
</tr></table>
<br />
{% endblock%}
{% block content %}
{% if expedition %}
<table>
@ -47,7 +59,8 @@
{% for personexpedition in expedition.personexpedition_set.all %}
<tr>
<td class="name">
{{ personexpedition.person }}
<a href="">{{ personexpedition.person }}</a>
</td>
{% if personexpedition.ListDaysTF %}
{% for dateTF in personexpedition.ListDaysTF %}

View File

@ -10,7 +10,7 @@
{% if logbookentry.title %}
<tr>
<td>{{logbookentry.date}}</td>
<td><a href="{% url logbookentry logbookentry.href %}">{{logbookentry.title|safe}}</a></td>
<td><a href="{{ logbookentry.get_absolute_url }}">{{logbookentry.title|safe}}</a></td>
</tr>
{% endif %}
{% endfor %}

View File

@ -8,14 +8,14 @@
<h3>Notable caves</h3>
<ul>
{% for cave in notablecaves %}
<li> <a href="{% url cave cave.href %}">{{cave.official_name|wiki_to_html_short}} ({{cave.href}})</a> </li>
<li> <a href="{{ cave.get_absolute_url }}">{{cave.official_name|wiki_to_html_short}} ({{cave.href}})</a> </li>
{% endfor %}
</ul>
<h3>All caves</h3>
<ul>
{% for cave in caves %}
<li> <a href="{% url cave cave.href %}">{{cave.official_name|wiki_to_html_short}} ({{cave.href}})</a> </li>
<li> <a href="{{ cave.get_absolute_url }}">{{cave.official_name|wiki_to_html_short}} ({{cave.href}})</a> </li>
{% endfor %}
</ul>

View File

@ -9,8 +9,8 @@
<div id="col2">
<table class="prevnextexpeditions">
<tr>
<td>{% if expedition_prev %}&lt; &lt; <a href="{% url expedition expedition_prev.year %}">{{expedition_prev.year}}</a>{% endif %}</td>
<td>{% if expedition_next %}&gt; &gt; <a href="{% url expedition expedition_next.year %}">{{expedition_next.year}}</a>{% endif %}</td>
<td>{% if expedition_prev %}&lt; &lt; <a href="{{ expedition_prev.get_absolute_url }}">{{expedition_prev.year}}</a>{% endif %}</td>
<td>{% if expedition_next %}&gt; &gt; <a href="{{ expedition_next.get_absolute_url }}">{{expedition_next.year}}</a>{% endif %}</td>
</tr>
</ul>
@ -18,7 +18,7 @@
<tr><th>Caver</th><th>From</th><th>To</th></tr>
{% for personexpedition in expedition.personexpedition_set.all %}
<tr>
<td><a href="{% url personexpedition personexpedition.person.href personexpedition.expedition.year %}">{{personexpedition.person}}</a></td>
<td><a href="{{ personexpedition.get_absolute_url }}">{{personexpedition.person}}</a></td>
<td>{{personexpedition.date_from}}</td>
<td>{{personexpedition.date_to}}</td>
</tr>
@ -36,11 +36,11 @@
{% for logbookentry in logbookentries %}
<tr>
<td>{{logbookentry.date}}</td>
<td><a href="{% url logbookentry logbookentry.href %}">{{logbookentry.title|safe}}</td>
<td><a href="{% url personexpedition logbookentry.author.person.href logbookentry.author.expedition.year %}">{{logbookentry.author.name}}</a></td>
<td><a href="{{ logbookentry.get_absolute_url }}">{{logbookentry.title|safe}}</td>
<td><a href="{{ logbookentry.author.get_absolute_url }}">{{logbookentry.author.name}}</a></td>
{% if logbookentry.cave %}
<td><a href="{% url cave logbookentry.cave.href %}">{{logbookentry.place}}</a></td>
<td><a href="{{ logbookentry.cave.get_absolute_url }}">{{logbookentry.place}}</a></td>
{% else %}
<td>{{logbookentry.place}}</td>
{% endif %}

View File

@ -4,23 +4,24 @@
{% block title %}Logbook {{logbookentry.id}}{% endblock %}
{% block content %}
<h2>{{logbookentry.title|safe}}</h2>
<div id="col2">
<p><a href="{% url expedition logbookentry.expedition.year %}">{{logbookentry.expedition.name}}</a></p>
<p><a href="{{ logbookentry.expedition.get_absolute_url }}">{{logbookentry.expedition.name}}</a></p>
{% if logbookentry.cave %}
<p>place: <a href="{% url cave logbookentry.cave.href %}">{{logbookentry.place}}</p>
<p>place: <a href="{{ logbookentry.cave.get_absolute_url }}">{{logbookentry.place}}</p>
{% else %}
<p>{{logbookentry.place}}</p>
{% endif %}
<p>
{% if logbookentry.get_previous_by_date %}
<a href="{% url logbookentry logbookentry.get_previous_by_date.href %}">{{logbookentry.get_previous_by_date.date}}</a>
<a href="{{ logbookentry.get_previous_by_date.get_absolute_url }}">{{logbookentry.get_previous_by_date.date}}</a>
{% endif %}
{% if logbookentry.get_next_by_date %}
<a href="{% url logbookentry logbookentry.get_next_by_date.href %}">{{logbookentry.get_next_by_date.date}}</a>
<a href="{{ logbookentry.get_next_by_date.get_absolute_url }}">{{logbookentry.get_next_by_date.date}}</a>
{% endif %}
</p>
@ -33,7 +34,7 @@
{% else %}
<td>
{% endifequal %}
<a href="{% url personexpedition persontrip.person_expedition.person.href persontrip.person_expedition.expedition.year %}">{{persontrip.person_expedition.person}}</a>
<a href="{{ persontrip.person_expedition.get_absolute_url }}">{{persontrip.person_expedition.person}}</a>
</td>
<td>
@ -44,12 +45,12 @@
<td>
{% if persontrip.get_previous_by_date %}
<a href="{% url logbookentry persontrip.get_previous_by_date.logbook_entry.href %}">{{persontrip.get_previous_by_date.date}}</a>
<a href="{{ persontrip.get_previous_by_date.logbook_entry.get_absolute_url }}">{{persontrip.get_previous_by_date.date}}</a>
{% endif %}
</td>
<td>
{% if persontrip.get_next_by_date %}
<a href="{% url logbookentry persontrip.get_next_by_date.logbook_entry.href %}">{{persontrip.get_next_by_date.date}}</a>
<a href="{{ persontrip.get_next_by_date.logbook_entry.get_absolute_url }}">{{persontrip.get_next_by_date.date}}</a>
{% endif %}
</td>
</tr>

View File

@ -8,7 +8,7 @@
<p>{{person|wiki_to_html_short}} has been on expo in the following years:</p>
<p>
{% for personexpedition in person.personexpedition_set.all %}
| <a href="{% url personexpedition personexpedition.person.href personexpedition.expedition.year %}">{{personexpedition.expedition.year}}</a>
| <a href="{{ personexpedition.get_absolute_url }}">{{personexpedition.expedition.year}}</a>
{% endfor %}
</p>

View File

@ -9,8 +9,8 @@
<h3>{{message}}</h3>
<p><b><a href="{% url expedition personexpedition.expedition.year %}">Main page for expedition: {{personexpedition.expedition}}</a></b></p>
<p><b><a href="{% url person personexpedition.person.href %}">Main page for person: {{personexpedition.person}}</a></b></p>
<p><b><a href="{{ personexpedition.expedition.get_absolute_url }}">Main page for expedition: {{personexpedition.expedition}}</a></b></p>
<p><b><a href="{{ personexpedition.person.get_absolute_url }}">Main page for person: {{personexpedition.person}}</a></b></p>
<p>List of other expos by this person</p>
<p>
@ -18,7 +18,7 @@
{% ifequal otherpersonexpedition personexpedition %}
| <b>{{otherpersonexpedition.expedition.year}}</b>
{% else %}
| <a href="{% url personexpedition personexpedition.person.href otherpersonexpedition.expedition.year %}">{{otherpersonexpedition.expedition.year}}</a>
| <a href="{{ personexpedition.get_absolute_url }}">{{otherpersonexpedition.expedition.year}}</a>
{% endifequal %}
{% endfor %}
</p>
@ -35,10 +35,10 @@
<table>
{% for persontrip in persondate.1.persontrips %}
<tr>
<td class="trip"><a href="{% url logbookentry persontrip.logbook_entry.href %}">{{persontrip.logbook_entry.title|safe}}</a></td>
<td class="trip"><a href="{{ persontrip.logbook_entry.get_absolute_url }}">{{persontrip.logbook_entry.title|safe}}</a></td>
{% if persontrip.logbook_entry.cave %}
<td><a href="{% url cave persontrip.logbook_entry.cave.href %}">{{persontrip.place}}</a></td>
<td><a href="{{ persontrip.logbook_entry.cave.get_absolute_url }}">{{persontrip.place}}</a></td>
{% else %}
<td>{{persontrip.place}}</td>
{% endif %}

View File

@ -10,9 +10,9 @@
<tr><th>Person</th><th>First</th><th>Last</th><th>Notability</th></tr>
{% for person in notablepersons %}
<tr>
<td><a href="{% url person person.href%}">{{person|wiki_to_html_short}}</a></td>
<td><a href="{% url personexpedition person.href person.Firstexpedition.expedition.year %}">{{person.Firstexpedition.expedition.year}}</a></td>
<td><a href="{% url personexpedition person.href person.Lastexpedition.expedition.year %}">{{person.Lastexpedition.expedition.year}}</a></td>
<td><a href="{{ person.get_absolute_url }}">{{person|wiki_to_html_short}}</a></td>
<td><a href="{{ person.personexpedition_set.all.0.get_absolute_url }}">{{ person.personexpedition_set.all.0.expedition.year }}</a></td>
<td><a href="{{ person.personexpedition_set.latest.get_absolute_url }}">{{ person.personexpedition_set.latest.expedition.year }}</a></td>
<td>{{person.notability}}</td>
</tr>
{% endfor %}
@ -28,9 +28,9 @@
<tr><th>Person</th><th>First</th><th>Last</th></tr>
{% for person in persons %}
<tr>
<td><a href="{% url person person.href%}">{{person|wiki_to_html_short}}</a></td>
<td><a href="{% url personexpedition person.href person.Firstexpedition.expedition.year %}">{{person.Firstexpedition.expedition.year}}</a></td>
<td><a href="{% url personexpedition person.href person.Lastexpedition.expedition.year %}">{{person.Lastexpedition.expedition.year}}</a></td>
<td><a href="{{ person.get_absolute_url }}">{{person|wiki_to_html_short}}</a></td>
<td><a href="{{ person.personexpedition_set.all.0.get_absolute_url }}">{{person.personexpedition_set.all.0.expedition.year}}</a></td>
<td><a href="{{ person.personexpedition_set.latest.get_absolute_url }}">{{person.personexpedition_set.latest.expedition.year}}</a></td>
</tr>
{% endfor %}
</table>

View File

@ -85,7 +85,7 @@ select { margin:0.5em }
<center>
<select id="expeditionChooser" class="centre" onChange="redirectYear()">
{% for expedition in expeditions.reverse %}
{% for expedition in expeditions %}
<option label="{{ expedition }}" value="{{ expedition }}" {% ifequal expedition current_expedition %}selected{% endifequal %}>
@ -103,9 +103,9 @@ select { margin:0.5em }
survey progress table </div>
</div>
<h3>Choose a wallet number</h3>
<center>
<select id="surveyChooser" class="centre" onChange="redirectSurvey()">
<h3>Choose a wallet number </h3>
<center>
<select id="surveyChooser" class="centre" onChange="redirectSurvey()">
<option label="show all" value="">
{% for survey in current_expedition.survey_set.all %}
</option>
@ -113,6 +113,7 @@ select { margin:0.5em }
{% ifequal survey current_survey %}
selected
{% endifequal %}>
{{ survey }}
</option>
{% endfor %}
@ -195,8 +196,9 @@ select { margin:0.5em }
</p>
</div>
{% endfor %}
<div class="figure"> <a href="{{ settings.URL_ROOT }}admin/expo/scannedimage/add/"> <img src="{{ settings.URL_ROOT }}{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_addlink.gif" /> Add a new scanned notes page. </a> (to be improved) </div>
<div class="figure"> <a href="{{ settings.URL_ROOT }}admin/expo/scannedimage/add/"> <img src="{{ settings.URL_ROOT }}{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_addlink.gif" /> Add a new scanned notes page. </a> </div>
</div>
<br class="clearfloat" />
<div id="survexFileContent" class="behind"> survex file editor, keeping file in original structure <br />
who entered by </div>
<div id="printedCentrelineContent" class="behind"> centreline </div>
@ -212,7 +214,7 @@ select { margin:0.5em }
</p>
</div>
{% endfor %}
<div class="figure"> <a href="{{ settings.URL_ROOT }}admin/expo/scannedimage/add/"> <img src="{{ settings.URL_ROOT }}{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_addlink.gif" /> Add a new scanned notes page. </a> (to be improved) </div>
<div class="figure"> <a href="{{ settings.URL_ROOT }}admin/expo/scannedimage/add/"> <img src="{{ settings.URL_ROOT }}{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_addlink.gif" /> Add a new scanned sketch. </a> </div>
</div>
<div id="tunnelXMLfileContent" class="behind"> link to tunnel xml file. potentially instance of tunnel applet... </div>
<div id="mainSketchIntegrationContent" class="behind"> link to main sketch file </div>

10
urls.py
View File

@ -15,9 +15,13 @@ urlpatterns = patterns('',
url(r'^caveindex$', views_caves.caveindex, name="caveindex"),
url(r'^personindex$', views_logbooks.personindex, name="personindex"),
url(r'^person/(.+)$', views_logbooks.person, name="person"),
#(r'^person/(?P<person_id>\d*)/?$', views_logbooks.person),
url(r'^person/(?P<first_name>[A-Z]*[a-z]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-z]*)/?', views_logbooks.person, name="person"),
#url(r'^person/(\w+_\w+)$', views_logbooks.person, name="person"),
url(r'^expedition/(\d+)$', views_logbooks.expedition, name="expedition"),
url(r'^personexpedition/(.+?)/(\d+)$', views_logbooks.personexpedition, name="personexpedition"),
url(r'^personexpedition/(?P<first_name>[A-Z]*[a-z]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-z]*)/(?P<year>\d+)/?$', views_logbooks.personexpedition, name="personexpedition"),
url(r'^logbookentry/(.+)$', views_logbooks.logbookentry,name="logbookentry"),
url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"),
@ -48,7 +52,7 @@ urlpatterns = patterns('',
url(r'^statistics/?$', views_other.stats, name="stats"),
url(r'^calendar/(?P<year>\d\d\d\d)?$', views_other.calendar, name="calendar"),
url(r'^calendar/(?P<year>\d\d\d\d)/?$', views_other.calendar, name="calendar"),
url(r'^survey/?$', surveyindex, name="survey"),
(r'^survey/(?P<year>\d\d\d\d)\#(?P<wallet_number>\d*)$', survey),