Skip to content

Commit

Permalink
Fix a bug when receiving stats, allow submitter to specify html inste…
Browse files Browse the repository at this point in the history
…ad of json.
  • Loading branch information
avidal committed Apr 13, 2012
1 parent d861d45 commit e12c0a3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions wotmad/stats/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.http import HttpResponse
from django.views.generic import TemplateView, ListView, View

from annoying.decorators import JsonResponse
Expand All @@ -21,9 +22,14 @@ class SubmitStat(View):

def get(self, *args, **kwargs):
request = self.request
ashtml = 'ashtml' in request.GET

def make_response(data, code=200):
resp = JsonResponse(data)
if ashtml:
resp = HttpResponse(data)
else:
resp = JsonResponse(data)

resp.status_code = code
return resp

Expand Down Expand Up @@ -56,7 +62,7 @@ def make_error(msg, errors=None):
for k, map_ in fulltext_maps.iteritems():
v = formdata.get(k, None)
if v and v in map_:
formdata[k] = map_[k]
formdata[k] = map_[v]

# Create the form instance
form = SubmitStatForm(formdata)
Expand Down

0 comments on commit e12c0a3

Please sign in to comment.