Permalink
Browse files

Update view to use different imports/decorators

1. We can generally expect the json module to be
   available now, so no need to use what ships with
   django
2. require_POST is just simpler and more direct
3. Using login_required is clearer as well instead
   of using custom logic.
  • Loading branch information...
paltman committed Jan 14, 2013
1 parent 9cc7b95 commit c97dc5e977e57df26962a1f3e7bf0dc4b3440508
Showing with 6 additions and 6 deletions.
  1. +6 −6 kaleo/views.py
View
@@ -1,18 +1,18 @@
+import json
+
from django import http
-from django.utils import simplejson as json
-from django.views.decorators.http import require_http_methods
+from django.views.decorators.http import require_POST
from account.models import EmailAddress
+from django.contrib.auth.decorators import login_required
from kaleo.forms import InviteForm
from kaleo.models import JoinInvitation
-@require_http_methods(["POST"])
+@login_required
+@require_POST
def invite(request):
- if not request.user.is_authenticated():
- data = {"status": "ERROR", "message": "not authenticated"}
- return http.HttpResponseBadRequest(json.dumps(data), content_type="application/json")
form = InviteForm(request.POST)
if form.is_valid():
email = form.cleaned_data["email_address"]

0 comments on commit c97dc5e

Please sign in to comment.