Changeset - 9dab2837748b
[Not reviewed]
0 2 0
Bradley Kuhn (bkuhn) - 9 years ago 2015-05-09 23:50:32
bkuhn@ebb.org
Generate JSON output of a fundraiser data

Allow public interface to query the fundraiser data.
2 files changed with 18 insertions and 0 deletions:
0 comments (0 inline, 0 general)
www/conservancy/apps/fundgoal/views.py
Show inline comments
 
from conservancy.apps.fundgoal.models import FundraisingGoal
 
from django.shortcuts import get_object_or_404, render_to_response
 
from django.http import JsonResponse
 

	
 

	
 
def view(request):
 
    """JSON version of request
 
    """
 
    keysForJSON = [ 'fundraiser_goal_amount', 'fundraiser_so_far_amount', 'fundraiser_donation_count',
 
                    'fundraiser_donation_count_disclose_threshold' ]
 
    GET = obj.GET
 
    codeNames =  []
 
    if 'code_name' in GET: codeNames += GET.getlist('code_name')
 

	
 
    returnDict = {}
 
    for code in FundraisingGoal.objects.filter(fundraiser_code_name__in=codeNames):
 
        for kk in keysForJSON:
 
            returnDict[code][kk] = getattr(code, kk)
 
    return JsonResponse( returnDict)
www/conservancy/urls.py
Show inline comments
...
 
@@ -58,12 +58,13 @@ urlpatterns = patterns('',
 
    (r'^members', 'conservancy.static.views.index'),
 
    (r'^npoacct', 'conservancy.static.views.index',
 
                  {'fundraiser_sought' : 'npoacct'}),
 
    (r'^overview', 'conservancy.static.views.index'),
 
    (r'^privacy-policy', 'conservancy.static.views.index'),
 
    (r'^supporter', 'conservancy.static.views.index'),
 
    (r'^fundraiser_data', 'conservancy.fundgoal.view'),
 
)
 

	
 
# urlpatterns += url(regex  = r'^%s(?P<path>.*)$' % conservancy.settings.STATIC_URL[1:],
 
# urlpatterns += url(regex  = r'^/overview',
 
#                    view   = 'django.views.static.serve',
 
#                    kwargs = {'document_root': conservancy.settings.STATIC_ROOT,
0 comments (0 inline, 0 general)