forked from expo/troggle
d25fd97864
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
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
from troggle.expo.models import Cave, Expedition, Person, LogbookEntry, PersonExpedition
|
|
import troggle.settings as settings
|
|
from django import forms
|
|
from django.db.models import Q
|
|
from troggle.parsers.people import LoadPersonsExpos
|
|
import re
|
|
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={}
|
|
statsDict['expoCount'] = int(Expedition.objects.count())
|
|
statsDict['caveCount'] = int(Cave.objects.count())
|
|
statsDict['personCount'] = int(Person.objects.count())
|
|
statsDict['logbookEntryCount'] = int(LogbookEntry.objects.count())
|
|
return render_response(request,'statistics.html', statsDict)
|
|
|
|
def frontpage(request):
|
|
message = "no test message" #reverse('personn', kwargs={"name":"hkjhjh"})
|
|
if "reloadexpos" in request.GET:
|
|
message = LoadPersonsExpos()
|
|
message = "Reloaded personexpos"
|
|
if "reloadsurvex" in request.GET:
|
|
message = LoadAllSurvexBlocks()
|
|
message = "Reloaded survexblocks"
|
|
|
|
#'randSent':randSent.randomLogbookSentence(),
|
|
expeditions = Expedition.objects.order_by("-year")
|
|
return render_response(request,'index.html', {'expeditions':expeditions, 'all':'all', "message":message})
|
|
|
|
def calendar(request,year):
|
|
week=['S','S','M','T','W','T','F']
|
|
if year:
|
|
expedition=Expedition.objects.get(year=year)
|
|
PersonExpeditions=expedition.personexpedition_set.all()
|
|
|
|
return render_response(request,'calendar.html', locals())
|