Commit 32fc0f16 authored by jc's avatar jc
Browse files

fixes Pokemon exception handling

parent 5f87e532
...@@ -30,7 +30,7 @@ status_map = dict(STATUS) ...@@ -30,7 +30,7 @@ status_map = dict(STATUS)
def status(code): def status(code):
try: try:
return status_map[code] return status_map[code]
except: except Exception:
return code return code
...@@ -41,7 +41,7 @@ type_map = dict(TYPES) ...@@ -41,7 +41,7 @@ type_map = dict(TYPES)
def type(code): def type(code):
try: try:
return type_map[code] return type_map[code]
except: except Exception:
return code return code
...@@ -52,5 +52,5 @@ media_map = dict(MEDIA) ...@@ -52,5 +52,5 @@ media_map = dict(MEDIA)
def media(code): def media(code):
try: try:
return media_map[code] return media_map[code]
except: except Exception:
return code return code
...@@ -55,7 +55,7 @@ def sanitizeHtml(value, base_url=None): ...@@ -55,7 +55,7 @@ def sanitizeHtml(value, base_url=None):
def activate(request): def activate(request):
try: try:
v = Violation.objects.get(activationid=request.GET.get('key', 'asdf')) v = Violation.objects.get(activationid=request.GET.get('key', 'asdf'))
except: except Exception:
messages.add_message(request, messages.INFO, unicode(_('Thank you, this key has been already activated'))) messages.add_message(request, messages.INFO, unicode(_('Thank you, this key has been already activated')))
return HttpResponseRedirect('/') # Redirect after POST return HttpResponseRedirect('/') # Redirect after POST
if v: if v:
...@@ -80,7 +80,7 @@ def activate(request): ...@@ -80,7 +80,7 @@ def activate(request):
def moderate(request): def moderate(request):
try: try:
v = Violation.objects.get(activationid=request.GET.get('key', 'asdf')) v = Violation.objects.get(activationid=request.GET.get('key', 'asdf'))
except: except Exception:
messages.add_message(request, messages.INFO, unicode(_('Thank you, this key has been already activated'))) messages.add_message(request, messages.INFO, unicode(_('Thank you, this key has been already activated')))
return HttpResponseRedirect('/') # Redirect after POST return HttpResponseRedirect('/') # Redirect after POST
if not v: if not v:
...@@ -101,7 +101,7 @@ def moderate(request): ...@@ -101,7 +101,7 @@ def moderate(request):
try: try:
settings.TWITTER_API.PostUpdate("New #NetNeutrality violation reported for %s (%s) %s %s/%s" % settings.TWITTER_API.PostUpdate("New #NetNeutrality violation reported for %s (%s) %s %s/%s" %
(v.operator, v.country, v.contract, settings.ROOT_URL or 'http://localhost:8001/', v.id)) (v.operator, v.country, v.contract, settings.ROOT_URL or 'http://localhost:8001/', v.id))
except: except Exception:
pass pass
v.activationid = '' v.activationid = ''
v.save() v.save()
...@@ -127,14 +127,14 @@ def confirm(request, id, name=None): ...@@ -127,14 +127,14 @@ def confirm(request, id, name=None):
actid = sendverifymail('confirm/', name, msg) actid = sendverifymail('confirm/', name, msg)
try: try:
c = Confirmation(key=actid, email=name, violation=violation) c = Confirmation(key=actid, email=name, violation=violation)
except: except Exception:
# should except IntegrityError properly # should except IntegrityError properly
return HttpResponse(unicode(_('Thank you, this has been already confirmed'))) return HttpResponse(unicode(_('Thank you, this has been already confirmed')))
c.save() c.save()
return HttpResponse(unicode(_('Thank you for your confirmation'))) return HttpResponse(unicode(_('Thank you for your confirmation')))
try: try:
c = get_object_or_404(Confirmation, key=id) c = get_object_or_404(Confirmation, key=id)
except: except Exception:
messages.add_message(request, messages.INFO, unicode(_("Thank you, this has been already confirmed"))) messages.add_message(request, messages.INFO, unicode(_("Thank you, this has been already confirmed")))
return HttpResponseRedirect('/') # Redirect after POST return HttpResponseRedirect('/') # Redirect after POST
c.key = '' c.key = ''
...@@ -304,7 +304,7 @@ def get_attach(request, id): ...@@ -304,7 +304,7 @@ def get_attach(request, id):
response = HttpResponse(wrapper, content_type=f.type) response = HttpResponse(wrapper, content_type=f.type)
response['Content-Disposition'] = 'attachment; filename="%s"' % f.name response['Content-Disposition'] = 'attachment; filename="%s"' % f.name
response['Content-Length'] = f.storage.size response['Content-Length'] = f.storage.size
except: except Exception:
response = HttpResponseNotFound('<h1>Document not found.</h1>') response = HttpResponseNotFound('<h1>Document not found.</h1>')
return response return response
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment