Changeset - b3f019265b24
[Not reviewed]
0 2 0
Bradley Kuhn (bkuhn) - 9 years ago 2015-03-09 06:28:42
bkuhn@ebb.org
Rework fundgoal lookup urls data.

The urls.py is of course only evaluated once: at Apache load time, which
means the data in the template became stale and is not dynamic.

This change should cause the lookup to happen at each page view.
2 files changed with 15 insertions and 9 deletions:
0 comments (0 inline, 0 general)
www/conservancy/static/views.py
Show inline comments
...
 
@@ -39,6 +39,17 @@ def index(request, *args, **kwargs):
 
    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
 

	
 
def index_with_fundraiser_data(request, *args, **kwargs):
 
    kwargs['fundgoal'] = fundgoal_lookup(kwargs['fundraiser_sought'])
 
    return index(request, kwargs)
 

	
 
def debug(request):
 
    path = request.get_full_path()
 
    path = path.lstrip('/')
www/conservancy/urls.py
Show inline comments
...
 
@@ -37,13 +37,6 @@ handler404 = 'conservancy.static.views.handler404'
 

	
 
admin.autodiscover()
 

	
 
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
 

	
 
urlpatterns = patterns('',
 
    (r'^$', 'conservancy.frontpage.view'),
 
    (r'^sponsors$', 'conservancy.frontpage.view'),
...
 
@@ -61,9 +54,11 @@ 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', {'fundgoal' : fundgoal_lookup('vmware-match-0')}),
 
    (r'^linux-compliance', 'conservancy.static.views.index_with_fundraiser_data',
 
                           {'fundraiser_sought' : 'vmware-match-0'}),
 
    (r'^members', 'conservancy.static.views.index'),
 
    (r'^npoacct', 'conservancy.static.views.index', {'fundgoal' : fundgoal_lookup('npoacct')}),
 
    (r'^npoacct', 'conservancy.static.views.index_with_fundraiser_data',
 
                  {'fundraiser_sought' : 'npoacct'}),
 
    (r'^overview', 'conservancy.static.views.index'),
 
    (r'^privacy-policy', 'conservancy.static.views.index'),
 
    (r'^supporter', 'conservancy.static.views.index'),
0 comments (0 inline, 0 general)