From ab2239009a1b1cf3dcb07bead662b8046131b80a 2015-03-09 06:40:47 From: Bradley M. Kuhn Date: 2015-03-09 06:40:47 Subject: [PATCH] Rework again to see if I can get this corrected. --- diff --git a/www/conservancy/static/views.py b/www/conservancy/static/views.py index 29f1a12a2b156df22f9f7c6f65f79d8d363934af..688d5dcb2efeeb1e1bc67b8e641f5cb576eef9a6 100644 --- a/www/conservancy/static/views.py +++ b/www/conservancy/static/views.py @@ -25,6 +25,13 @@ def handler404(request): def handler500(request): return handler(request, '500') +def fundgoal_lookup(fundraiser_sought): + try: + return FundraisingGoal.objects.get(fundraiser_code_name=fundraiser_sought) + except FundraisingGoal.DoesNotExist: + # we have no object! do something + return None + def index(request, *args, **kwargs): # return HttpResponse("Hello, static world: " + request.get_full_path()) path = request.get_full_path() @@ -37,18 +44,13 @@ def index(request, *args, **kwargs): # return HttpResponse("Sorry that's a 404: " + path) return handler404(request) template = loader.get_template(path) - context = RequestContext(request, kwargs) - return HttpResponse(template.render(context)) -def fundgoal_lookup(fundraiser_sought): - try: - return FundraisingGoal.objects.get(fundraiser_code_name=fundraiser_sought) - except FundraisingGoal.DoesNotExist: - # we have no object! do something - return None + if kwargs.has_key('fundraiser_sought'): + kwargs = kwargs.copy() + kwargs['fundgoal'] = fundgoal_lookup(kwargs['fundraiser_sought']) -def index_with_fundraiser_data(request, *args, **kwargs): - return index(request, { 'fundgoal' : fundgoal_lookup(kwargs['fundraiser_sought']) }) + context = RequestContext(request, kwargs) + return HttpResponse(template.render(context)) def debug(request): path = request.get_full_path() diff --git a/www/conservancy/urls.py b/www/conservancy/urls.py index e9c2cd8f337bf3b3e473142319ad91aeab56ad96..183aad97fc0c15c88ec556f8148bb4111b9a328b 100644 --- a/www/conservancy/urls.py +++ b/www/conservancy/urls.py @@ -53,10 +53,10 @@ urlpatterns = patterns('', (r'^error', 'conservancy.static.views.index'), (r'^about', 'conservancy.static.views.index'), (r'^donate', 'conservancy.static.views.index'), - (r'^linux-compliance', 'conservancy.static.views.index_with_fundraiser_data', + (r'^linux-compliance', 'conservancy.static.views.index', {'fundraiser_sought' : 'vmware-match-0'}), (r'^members', 'conservancy.static.views.index'), - (r'^npoacct', 'conservancy.static.views.index_with_fundraiser_data', + (r'^npoacct', 'conservancy.static.views.index', {'fundraiser_sought' : 'npoacct'}), (r'^overview', 'conservancy.static.views.index'), (r'^privacy-policy', 'conservancy.static.views.index'),