Changeset - 9dab2837748b
[Not reviewed]
0 2 0
Bradley Kuhn (bkuhn) - 6 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
...
 
@@ -61,6 +61,7 @@ urlpatterns = patterns('',
 
    (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:],
0 comments (0 inline, 0 general)