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
...
 
@@ -41,2 +41,13 @@ def index(request, *args, **kwargs):
 

	
 
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):
www/conservancy/urls.py
Show inline comments
...
 
@@ -39,9 +39,2 @@ 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('',
...
 
@@ -63,5 +56,7 @@ urlpatterns = patterns('',
 
    (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'),
0 comments (0 inline, 0 general)