Skip to content

Instantly share code, notes, and snippets.

@ebroder
Created June 8, 2012 20:22
Show Gist options
  • Save ebroder/2897961 to your computer and use it in GitHub Desktop.
Save ebroder/2897961 to your computer and use it in GitHub Desktop.
monospace-django bug fix
diff --git a/monospace/views.py b/monospace/views.py
index beadc55..d587230 100644
--- a/monospace/views.py
+++ b/monospace/views.py
@@ -61,27 +61,30 @@ def register(request):
form = UserForm(request.POST)
if form.is_valid():
- customer = stripe.Customer.create(
- description = form.cleaned_data['email'],
- card = form.cleaned_data['stripe_token'],
- plan = 'basic'
- )
-
- user = User(
- name = form.cleaned_data['name'],
- email = form.cleaned_data['email'],
- last_4_digits = form.cleaned_data['last_4_digits'],
- stripe_id = customer.id
- )
- user.set_password(form.cleaned_data['password1'])
-
try:
- user.save()
- except IntegrityError:
- form.addError(user.email + ' is already a member')
- else:
- request.session['user'] = user.pk
- return HttpResponseRedirect('/')
+ customer = stripe.Customer.create(
+ description = form.cleaned_data['email'],
+ card = form.cleaned_data['stripe_token'],
+ plan = 'basic'
+ )
+
+ user = User(
+ name = form.cleaned_data['name'],
+ email = form.cleaned_data['email'],
+ last_4_digits = form.cleaned_data['last_4_digits'],
+ stripe_id = customer.id
+ )
+ user.set_password(form.cleaned_data['password1'])
+
+ try:
+ user.save()
+ except IntegrityError:
+ form.addError(user.email + ' is already a member')
+ else:
+ request.session['user'] = user.pk
+ return HttpResponseRedirect('/')
+ except:
+ form.addError("Whoops! We weren't able to charge that card")
else:
form = UserForm()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment