Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: avidal/wotmad
base: d861d458f8
...
head fork: avidal/wotmad
compare: b219e3003c
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 24 additions and 2 deletions.
  1. +24 −2 wotmad/stats/views.py
View
26 wotmad/stats/views.py
@@ -1,3 +1,4 @@
+from django.http import HttpResponse
from django.views.generic import TemplateView, ListView, View
from annoying.decorators import JsonResponse
@@ -21,9 +22,30 @@ 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:
+ out = []
+ if 'error' in data:
+ out.append("<h1>Error receiving stat</h1>")
+ out.append("<p>{0}</p>".format(data['error']))
+ if 'errors' in data:
+ out.append("<p>The following errors were encountered while "
+ "validating your submission:</p>")
+ for field, errors in data['errors'].iteritems():
+ l = "<li>{0}<ul><li>{1}</li></ul></li>"
+ out.append(l.format(field, "</li><li>".join(errors)))
+ if 'success' in data:
+ out.append("<h1>Success! Your stat was accepted.</h1>")
+
+ out.append("<br/><br/>")
+ out.append("You may close this window at any time.")
+
+ resp = HttpResponse("\n".join(out))
+ else:
+ resp = JsonResponse(data)
+
resp.status_code = code
return resp
@@ -56,7 +78,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)

No commit comments for this range

Something went wrong with that request. Please try again.