2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +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): class PersonExpeditionAdmin(admin.ModelAdmin):
search_fields = ('person__first_name','expedition__year') 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(Photo)
admin.site.register(Cave) admin.site.register(Cave, CaveAdmin)
admin.site.register(Area) admin.site.register(Area)
admin.site.register(OtherCaveName) admin.site.register(OtherCaveName)
admin.site.register(CaveAndEntrance) 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: class Meta:
ordering = ('year',) 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) # lose these two functions (inelegant, and we may create a file with the dates that we can load from)
def GuessDateFrom(self): def GuessDateFrom(self):
@ -62,11 +66,13 @@ class Person(models.Model):
blurb = models.TextField(blank=True,null=True) blurb = models.TextField(blank=True,null=True)
href = models.CharField(max_length=200) href = models.CharField(max_length=200)
orderref = models.CharField(max_length=200) # for alphabetic orderref = models.CharField(max_length=200) # for alphabetic
notability = models.FloatField() # for listing the top 20 people notability = models.FloatField() # for listing the top 20 people
bisnotable = models.BooleanField() bisnotable = models.BooleanField()
user = models.ForeignKey(User, unique=True, null=True, blank=True) 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: class Meta:
verbose_name_plural = "People" verbose_name_plural = "People"
class Meta: class Meta:
@ -76,12 +82,13 @@ class Person(models.Model):
if self.last_name: if self.last_name:
return "%s %s" % (self.first_name, self.last_name) return "%s %s" % (self.first_name, self.last_name)
return self.first_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 # these ought to be possible by piping through |min in the template, or getting the first of an ordered list
def Firstexpedition(self): # def Firstexpedition(self):
return self.personexpedition_set.order_by('expedition')[0] # return self.personexpedition_set.order_by('expedition')[0]
def Lastexpedition(self): # def Lastexpedition(self):
return self.personexpedition_set.order_by('-expedition')[0] # return self.personexpedition_set.order_by('-expedition')[0]
def Sethref(self): def Sethref(self):
if self.last_name: if self.last_name:
@ -99,6 +106,14 @@ class PersonExpedition(models.Model):
date_from = models.DateField(blank=True,null=True) date_from = models.DateField(blank=True,null=True)
date_to = models.DateField(blank=True,null=True) date_to = models.DateField(blank=True,null=True)
is_guest = models.BooleanField(default=False) 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) nickname = models.CharField(max_length=100,blank=True,null=True)
def GetPersonroles(self): def GetPersonroles(self):
@ -112,6 +127,7 @@ class PersonExpedition(models.Model):
class Meta: class Meta:
ordering = ('expedition',) ordering = ('expedition',)
get_latest_by = 'date_from'
def GetPersonChronology(self): def GetPersonChronology(self):
res = { } res = { }
@ -130,8 +146,8 @@ class PersonExpedition(models.Model):
# needs converting dict into list # needs converting dict into list
return sorted(res.items()) return sorted(res.items())
# don't use tabs. # possibly not useful functions anyway -JT
# possibly not useful functions anyway # 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): def ListDays(self):
if self.date_from and self.date_to: if self.date_from and self.date_to:
res=[] res=[]
@ -151,6 +167,7 @@ class PersonExpedition(models.Model):
def __unicode__(self): def __unicode__(self):
return "%s: (%s)" % (self.person, self.expedition) 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): def name(self):
if self.nickname: if self.nickname:
return "%s (%s) %s" % (self.person.first_name, self.nickname, self.person.last_name) 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 "%s %s" % (self.person.first_name, self.person.last_name)
return self.person.first_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): class LogbookEntry(models.Model):
date = models.DateField() date = models.DateField()
@ -167,22 +186,26 @@ class LogbookEntry(models.Model):
cave = models.ForeignKey('Cave',blank=True,null=True) cave = models.ForeignKey('Cave',blank=True,null=True)
place = models.CharField(max_length=100,blank=True,null=True) place = models.CharField(max_length=100,blank=True,null=True)
text = models.TextField() 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: class Meta:
verbose_name_plural = "Logbook Entries" verbose_name_plural = "Logbook Entries"
# several PersonTrips point in to this object # several PersonTrips point in to this object
class Meta: class Meta:
ordering = ('-date',) ordering = ('-date',)
def get_absolute_url(self):
return settings.URL_ROOT + "/logbookentry/" + str(self.pk)
def __unicode__(self): def __unicode__(self):
return "%s: (%s)" % (self.date, self.title) return "%s: (%s)" % (self.date, self.title)
class PersonTrip(models.Model): class PersonTrip(models.Model):
person_expedition = models.ForeignKey(PersonExpedition) person_expedition = models.ForeignKey(PersonExpedition)
@ -252,13 +275,14 @@ class Cave(models.Model):
href = models.CharField(max_length=100) href = models.CharField(max_length=100)
def Sethref(self): def get_absolute_url(self):
if self.kataster_number: if self.kataster_number:
self.href = self.kataster_number href = self.kataster_number
elif self.unofficial_number: elif self.unofficial_number:
self.href = self.unofficial_number href = self.unofficial_number
else: else:
self.href = official_name.lower() href = official_name.lower()
return settings.URL_ROOT + '/cave/' + self.href + '/'
def __unicode__(self): def __unicode__(self):

View File

@ -1,4 +1,5 @@
# primary namespace # primary namespace
import view_surveys import view_surveys
import views_caves import views_caves
import views_survex 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 from troggle.expo.models import Cave, CaveAndEntrance, Survey, Expedition
import troggle.expo.models as models import troggle.expo.models as models
import troggle.settings as settings import troggle.settings as settings
from troggle.expo.forms import CaveForm from troggle.expo.forms import CaveForm
import search import search
from troggle.alwaysUseRequestContext import render_response # see views_logbooks for explanation on this.
def caveindex(request): def caveindex(request):
caves = Cave.objects.all() caves = Cave.objects.all()
notablecavehrefs = [ "161", "204", "258", "76" ] # could detect notability by trips and notability of people who have been down them 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 ] 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): def cavehref(request, cave_id='', offical_name=''):
cave = Cave.objects.get(href=href) try:
return render_to_response('cave.html', {'cave': cave, 'settings': settings}) 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): def ent(request, cave_id, ent_letter):
cave = Cave.objects.filter(kataster_number = cave_id)[0] cave = Cave.objects.filter(kataster_number = cave_id)[0]
cave_and_ent = CaveAndEntrance.objects.filter(cave = cave).filter(entrance_letter = ent_letter)[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, 'entrance': cave_and_ent.entrance,
'letter': cave_and_ent.entrance_letter, 'letter': cave_and_ent.entrance_letter,})
'settings': settings})
def survexblock(request, survexpath): def survexblock(request, survexpath):
survexblock = models.SurvexBlock.objects.get(survexpath=survexpath) survexblock = models.SurvexBlock.objects.get(survexpath=survexpath)
#ftext = survexblock.filecontents() #ftext = survexblock.filecontents()
ftext = survexblock.text 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): def caveArea(request, name):
cavearea = models.CaveArea.objects.get(name = name) cavearea = models.CaveArea.objects.get(name = name)
cave = cavearea.cave 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): def caveSearch(request):
query_string = '' query_string = ''
found_entries = None found_entries = None
if ('q' in request.GET) and request.GET['q'].strip(): if ('q' in request.GET) and request.GET['q'].strip():
query_string = request.GET['q'] query_string = request.GET['q']
entry_query = search.get_query(query_string, ['underground_description','official_name',]) entry_query = search.get_query(query_string, ['underground_description','official_name',])
found_entries = Cave.objects.filter(entry_query) found_entries = Cave.objects.filter(entry_query)
return render_to_response('cavesearch.html', return render_response(request,'cavesearch.html',
{ 'query_string': query_string, 'found_entries': found_entries, 'settings': settings}) { 'query_string': query_string, 'found_entries': found_entries,})
#context_instance=RequestContext(request))
def surveyindex(request): def surveyindex(request):
surveys=Survey.objects.all() surveys=Survey.objects.all()
expeditions=Expedition.objects.all() expeditions=Expedition.objects.all()
dictToPass=locals() return render_response(request,'survey.html',locals())
dictToPass.update({'settings':settings})
return render_to_response('survey.html',dictToPass)
def survey(request,year,wallet_number): def survey(request,year,wallet_number):
surveys=Survey.objects.all() surveys=Survey.objects.all()
@ -63,9 +63,6 @@ def survey(request,year,wallet_number):
notes=current_survey.scannedimage_set.filter(contents='notes') notes=current_survey.scannedimage_set.filter(contents='notes')
planSketches=current_survey.scannedimage_set.filter(contents='plan') planSketches=current_survey.scannedimage_set.filter(contents='plan')
elevationSketches=current_survey.scannedimage_set.filter(contents='elevation') 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.parsers.people import GetPersonExpeditionNameLookup
from troggle.expo.forms import PersonForm 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 search
import re import re
def personindex(request): def personindex(request):
persons = Person.objects.all() 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 = [ ] personss = [ ]
ncols = 5 ncols = 5
nc = (len(persons) + ncols - 1) / ncols nc = (len(persons) + ncols - 1) / ncols
@ -18,7 +22,7 @@ def personindex(request):
personss.append(persons[i * nc: (i + 1) * nc]) personss.append(persons[i * nc: (i + 1) * nc])
notablepersons = Person.objects.filter(bisnotable=True) 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): def expedition(request, expeditionname):
year = int(expeditionname) year = int(expeditionname)
@ -30,22 +34,28 @@ def expedition(request, expeditionname):
message = LoadLogbookForExpedition(expedition) message = LoadLogbookForExpedition(expedition)
#message = str(GetPersonExpeditionNameLookup(expedition).keys()) #message = str(GetPersonExpeditionNameLookup(expedition).keys())
logbookentries = expedition.logbookentry_set.order_by('date') 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): def person(request, first_name='', last_name=''):
person = Person.objects.get(href=name) person = Person.objects.get(first_name = first_name, last_name = last_name)
return render_to_response('person.html', {'person': person, 'settings': settings}) return render_response(request,'person.html', {'person': person, })
def get_absolute_url(self):
return settings.URL_ROOT + self.first_name + '_' + self.last_name
def personexpedition(request, name, expeditionname): #def person(request, name):
person = Person.objects.get(href=name) # person = Person.objects.get(href=name)
year = int(expeditionname) #
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) expedition = Expedition.objects.get(year=year)
personexpedition = person.personexpedition_set.get(expedition=expedition) 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): def logbookentry(request, logbookentry_pk):
logbookentry = LogbookEntry.objects.filter(href = logbookentry_id)[0] logbookentry = LogbookEntry.objects.get(pk = logbookentry_pk)
return render_to_response('logbookentry.html', {'logbookentry': logbookentry, 'settings': settings}) return render_response(request, 'logbookentry.html', {'logbookentry': logbookentry, })
def logbookSearch(request, extra): def logbookSearch(request, extra):
query_string = '' query_string = ''
@ -55,11 +65,11 @@ def logbookSearch(request, extra):
entry_query = search.get_query(query_string, ['text','title',]) entry_query = search.get_query(query_string, ['text','title',])
found_entries = LogbookEntry.objects.filter(entry_query) found_entries = LogbookEntry.objects.filter(entry_query)
return render_to_response('logbooksearch.html', return render_response(request,'logbooksearch.html',
{ 'query_string': query_string, 'found_entries': found_entries, 'settings': settings}) { 'query_string': query_string, 'found_entries': found_entries, })
#context_instance=RequestContext(request)) #context_instance=RequestContext(request))
def personForm(request,pk): def personForm(request,pk):
person=Person.objects.get(pk=pk) person=Person.objects.get(pk=pk)
form=PersonForm(instance=person) 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 from troggle.expo.models import Cave, Expedition, Person, LogbookEntry, PersonExpedition
import troggle.settings as settings import troggle.settings as settings
from django import forms from django import forms
@ -9,6 +8,7 @@ from troggle.parsers.survex import LoadAllSurvexBlocks
import randSent import randSent
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from troggle.alwaysUseRequestContext import render_response # see views_logbooks for explanation on this.
def stats(request): def stats(request):
statsDict={} statsDict={}
@ -16,7 +16,7 @@ def stats(request):
statsDict['caveCount'] = int(Cave.objects.count()) statsDict['caveCount'] = int(Cave.objects.count())
statsDict['personCount'] = int(Person.objects.count()) statsDict['personCount'] = int(Person.objects.count())
statsDict['logbookEntryCount'] = int(LogbookEntry.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): def frontpage(request):
message = "no test message" #reverse('personn', kwargs={"name":"hkjhjh"}) message = "no test message" #reverse('personn', kwargs={"name":"hkjhjh"})
@ -29,7 +29,7 @@ def frontpage(request):
#'randSent':randSent.randomLogbookSentence(), #'randSent':randSent.randomLogbookSentence(),
expeditions = Expedition.objects.order_by("-year") 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): def calendar(request,year):
week=['S','S','M','T','W','T','F'] week=['S','S','M','T','W','T','F']
@ -37,6 +37,4 @@ def calendar(request,year):
expedition=Expedition.objects.get(year=year) expedition=Expedition.objects.get(year=year)
PersonExpeditions=expedition.personexpedition_set.all() PersonExpeditions=expedition.personexpedition_set.all()
dictToPass=locals() return render_response(request,'calendar.html', locals())
dictToPass.update({'settings':settings})
return render_to_response('calendar.html', dictToPass)

View File

@ -58,7 +58,7 @@ def LoadPersonsExpos():
years = headers[5:] years = headers[5:]
years.append("2008") years.append("2008")
for year in years: 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() expedition.save()

View File

@ -1,28 +1,24 @@
import sys import sys
import os import os
import urllib
import types import types
#sys.path.append('C:\\Expo\\expoweb') sys.path.append('C:\\Expo\\expoweb')
from troggle import * from troggle import *
#os.environ['DJANGO_SETTINGS_MODULE']='troggle.settings' os.environ['DJANGO_SETTINGS_MODULE']='troggle.settings'
import troggle.settings as settings import troggle.settings as settings
import troggle.expo.models as models import troggle.expo.models as models
import troggle.expo.fileAbstraction as fileAbstraction
#import settings #import settings
#import expo.models as models #import expo.models as models
import csv import csv
import re import re
import datetime import datetime
import cStringIO
surveytab = fileAbstraction.readFile("Surveys.csv") surveytab = open(os.path.join(settings.SURVEYS, "Surveys.csv"))
dialect=csv.Sniffer().sniff(surveytab) dialect=csv.Sniffer().sniff(surveytab.read())
surveyreader = csv.reader(cStringIO.StringIO(surveytab),dialect=dialect) surveytab.seek(0,0)
print surveyreader surveyreader = csv.reader(surveytab,dialect=dialect)
headers = surveyreader.next() 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 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 # test if the expeditions have been added yet
if len(models.Expedition.objects.all())==0: if len(models.Expedition.objects.all())==0:
@ -31,10 +27,9 @@ if len(models.Expedition.objects.all())==0:
models.ScannedImage.objects.all().delete() models.ScannedImage.objects.all().delete()
models.Survey.objects.all().delete() models.Survey.objects.all().delete()
for survey in surveyreader: 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. 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() # print walletNumberLetter.groups()
surveyobj = models.Survey( surveyobj = models.Survey(
expedition = models.Expedition.objects.filter(year=survey[header['Year']])[0], expedition = models.Expedition.objects.filter(year=survey[header['Year']])[0],
wallet_number = walletNumberLetter.group('number'), wallet_number = walletNumberLetter.group('number'),
@ -48,16 +43,15 @@ for survey in surveyreader:
pass pass
surveyobj.save() surveyobj.save()
print "added survey " + survey[header['Year']] + "#" + surveyobj.wallet_number print "added survey " + survey[header['Year']] + "#" + surveyobj.wallet_number
# add survey scans # add survey scans
def parseSurveyScans(year): def parseSurveyScans(year):
yearDirList = fileAbstraction.dirsAsList(year.year) yearPath=os.path.join(settings.SURVEYS, year.year)
for surveyFolder in yearDirList: yearFileList=os.listdir(yearPath)
print surveyFolder for surveyFolder in yearFileList:
try: try:
surveyNumber=re.match(r'\d\d\d\d#0*(\d+)',surveyFolder).groups() surveyNumber=re.match(r'\d\d\d\d#0*(\d+)',surveyFolder).groups()
scanList=fileAbstraction.filesAsList(year.year, surveyFolder) scanList=os.listdir(os.path.join(yearPath,surveyFolder))
print "BAR: ", year.year, surveyFolder, scanList
except AttributeError: except AttributeError:
print surveyFolder + " ignored" print surveyFolder + " ignored"
continue continue
@ -65,7 +59,6 @@ def parseSurveyScans(year):
for scan in scanList: for scan in scanList:
try: try:
scanChopped=re.match(r'(?i).*(notes|elev|plan|elevation|extend)(\d*)\.(png|jpg|jpeg)',scan).groups() scanChopped=re.match(r'(?i).*(notes|elev|plan|elevation|extend)(\d*)\.(png|jpg|jpeg)',scan).groups()
print "BAR: ", scanChopped
scanType,scanNumber,scanFormat=scanChopped scanType,scanNumber,scanFormat=scanChopped
except AttributeError: except AttributeError:
print "Adding scans: " + scan + " ignored" print "Adding scans: " + scan + " ignored"
@ -82,14 +75,14 @@ def parseSurveyScans(year):
survey=models.Survey.objects.get_or_create(wallet_number=surveyNumber, expedition=year)[0] survey=models.Survey.objects.get_or_create(wallet_number=surveyNumber, expedition=year)[0]
except models.Survey.MultipleObjectsReturned: except models.Survey.MultipleObjectsReturned:
survey=models.Survey.objects.filter(wallet_number=surveyNumber, expedition=year)[0] survey=models.Survey.objects.filter(wallet_number=surveyNumber, expedition=year)[0]
scanObj = models.ScannedImage( scanObj = models.ScannedImage(
file=os.path.join(year.year, surveyFolder, scan), file=os.path.join(year.year, surveyFolder, scan),
contents=scanType, contents=scanType,
number_in_wallet=scanNumber, number_in_wallet=scanNumber,
survey=survey survey=survey
) )
print "Added scanned image at " + str(scanObj) #print "Added scanned image at " + str(scanObj)
scanObj.save() scanObj.save()
for year in models.Expedition.objects.filter(year__gte=2000): #expos since 2000, because paths and filenames were nonstandard before then 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', # '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 = '/' LOGIN_REDIRECT_URL = '/'

View File

@ -21,6 +21,18 @@
{% endblock %} {% 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 %} {% block content %}
{% if expedition %} {% if expedition %}
<table> <table>
@ -47,7 +59,8 @@
{% for personexpedition in expedition.personexpedition_set.all %} {% for personexpedition in expedition.personexpedition_set.all %}
<tr> <tr>
<td class="name"> <td class="name">
{{ personexpedition.person }} <a href="">{{ personexpedition.person }}</a>
</td> </td>
{% if personexpedition.ListDaysTF %} {% if personexpedition.ListDaysTF %}
{% for dateTF in personexpedition.ListDaysTF %} {% for dateTF in personexpedition.ListDaysTF %}

View File

@ -10,7 +10,7 @@
{% if logbookentry.title %} {% if logbookentry.title %}
<tr> <tr>
<td>{{logbookentry.date}}</td> <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> </tr>
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View File

@ -8,14 +8,14 @@
<h3>Notable caves</h3> <h3>Notable caves</h3>
<ul> <ul>
{% for cave in notablecaves %} {% 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 %} {% endfor %}
</ul> </ul>
<h3>All caves</h3> <h3>All caves</h3>
<ul> <ul>
{% for cave in caves %} {% 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 %} {% endfor %}
</ul> </ul>

View File

@ -1,52 +1,52 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load wiki_markup %} {% load wiki_markup %}
{% block title %}Expedition {{expedition.name}}{% endblock %} {% block title %}Expedition {{expedition.name}}{% endblock %}
{% block content %} {% block content %}
<h2>{{expedition.name}}: {{expedition.date_from}} - {{expedition.date_to}}</h2> <h2>{{expedition.name}}: {{expedition.date_from}} - {{expedition.date_to}}</h2>
<div id="col2"> <div id="col2">
<table class="prevnextexpeditions"> <table class="prevnextexpeditions">
<tr> <tr>
<td>{% if expedition_prev %}&lt; &lt; <a href="{% url expedition expedition_prev.year %}">{{expedition_prev.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="{% url expedition expedition_next.year %}">{{expedition_next.year}}</a>{% endif %}</td> <td>{% if expedition_next %}&gt; &gt; <a href="{{ expedition_next.get_absolute_url }}">{{expedition_next.year}}</a>{% endif %}</td>
</tr> </tr>
</ul> </ul>
<table class="expeditionpersonlist"> <table class="expeditionpersonlist">
<tr><th>Caver</th><th>From</th><th>To</th></tr> <tr><th>Caver</th><th>From</th><th>To</th></tr>
{% for personexpedition in expedition.personexpedition_set.all %} {% for personexpedition in expedition.personexpedition_set.all %}
<tr> <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_from}}</td>
<td>{{personexpedition.date_to}}</td> <td>{{personexpedition.date_to}}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
</div> </div>
<div id="col1"> <div id="col1">
<h3>Logbook entries</h3> <h3>Logbook entries</h3>
<form action="" method="GET"><input type="submit" name="reload" value="Reload"></form> <form action="" method="GET"><input type="submit" name="reload" value="Reload"></form>
<p>debug message: {{message}}</p> <p>debug message: {{message}}</p>
<table class="expeditionlogbooks"> <table class="expeditionlogbooks">
<tr><th>Date</th><th>Title</th><th>Author</th><th>Place</th></tr> <tr><th>Date</th><th>Title</th><th>Author</th><th>Place</th></tr>
{% for logbookentry in logbookentries %} {% for logbookentry in logbookentries %}
<tr> <tr>
<td>{{logbookentry.date}}</td> <td>{{logbookentry.date}}</td>
<td><a href="{% url logbookentry logbookentry.href %}">{{logbookentry.title|safe}}</td> <td><a href="{{ logbookentry.get_absolute_url }}">{{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.author.get_absolute_url }}">{{logbookentry.author.name}}</a></td>
{% if logbookentry.cave %} {% 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 %} {% else %}
<td>{{logbookentry.place}}</td> <td>{{logbookentry.place}}</td>
{% endif %} {% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -4,23 +4,24 @@
{% block title %}Logbook {{logbookentry.id}}{% endblock %} {% block title %}Logbook {{logbookentry.id}}{% endblock %}
{% block content %} {% block content %}
<h2>{{logbookentry.title|safe}}</h2> <h2>{{logbookentry.title|safe}}</h2>
<div id="col2"> <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 %} {% 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 %} {% else %}
<p>{{logbookentry.place}}</p> <p>{{logbookentry.place}}</p>
{% endif %} {% endif %}
<p> <p>
{% if logbookentry.get_previous_by_date %} {% 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 %} {% endif %}
{% if logbookentry.get_next_by_date %} {% 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 %} {% endif %}
</p> </p>
@ -33,7 +34,7 @@
{% else %} {% else %}
<td> <td>
{% endifequal %} {% 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>
<td> <td>
@ -44,12 +45,12 @@
<td> <td>
{% if persontrip.get_previous_by_date %} {% 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 %} {% endif %}
</td> </td>
<td> <td>
{% if persontrip.get_next_by_date %} {% 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 %} {% endif %}
</td> </td>
</tr> </tr>

View File

@ -8,7 +8,7 @@
<p>{{person|wiki_to_html_short}} has been on expo in the following years:</p> <p>{{person|wiki_to_html_short}} has been on expo in the following years:</p>
<p> <p>
{% for personexpedition in person.personexpedition_set.all %} {% 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 %} {% endfor %}
</p> </p>

View File

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

View File

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

View File

@ -85,7 +85,7 @@ select { margin:0.5em }
<center> <center>
<select id="expeditionChooser" class="centre" onChange="redirectYear()"> <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 %}> <option label="{{ expedition }}" value="{{ expedition }}" {% ifequal expedition current_expedition %}selected{% endifequal %}>
@ -103,9 +103,9 @@ select { margin:0.5em }
survey progress table </div> survey progress table </div>
</div> </div>
<h3>Choose a wallet number</h3> <h3>Choose a wallet number </h3>
<center> <center>
<select id="surveyChooser" class="centre" onChange="redirectSurvey()"> <select id="surveyChooser" class="centre" onChange="redirectSurvey()">
<option label="show all" value=""> <option label="show all" value="">
{% for survey in current_expedition.survey_set.all %} {% for survey in current_expedition.survey_set.all %}
</option> </option>
@ -113,6 +113,7 @@ select { margin:0.5em }
{% ifequal survey current_survey %} {% ifequal survey current_survey %}
selected selected
{% endifequal %}> {% endifequal %}>
{{ survey }}
</option> </option>
{% endfor %} {% endfor %}
@ -195,8 +196,9 @@ select { margin:0.5em }
</p> </p>
</div> </div>
{% endfor %} {% 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> </div>
<br class="clearfloat" />
<div id="survexFileContent" class="behind"> survex file editor, keeping file in original structure <br /> <div id="survexFileContent" class="behind"> survex file editor, keeping file in original structure <br />
who entered by </div> who entered by </div>
<div id="printedCentrelineContent" class="behind"> centreline </div> <div id="printedCentrelineContent" class="behind"> centreline </div>
@ -212,7 +214,7 @@ select { margin:0.5em }
</p> </p>
</div> </div>
{% endfor %} {% 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>
<div id="tunnelXMLfileContent" class="behind"> link to tunnel xml file. potentially instance of tunnel applet... </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> <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'^caveindex$', views_caves.caveindex, name="caveindex"),
url(r'^personindex$', views_logbooks.personindex, name="personindex"), 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'^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'^logbookentry/(.+)$', views_logbooks.logbookentry,name="logbookentry"),
url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"), url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"),
@ -48,7 +52,7 @@ urlpatterns = patterns('',
url(r'^statistics/?$', views_other.stats, name="stats"), 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"), url(r'^survey/?$', surveyindex, name="survey"),
(r'^survey/(?P<year>\d\d\d\d)\#(?P<wallet_number>\d*)$', survey), (r'^survey/(?P<year>\d\d\d\d)\#(?P<wallet_number>\d*)$', survey),