Skip to content

Commit

Permalink
Update view to use different imports/decorators
Browse files Browse the repository at this point in the history
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 c97dc5e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions kaleo/views.py
Original file line number Original file line Diff line number Diff line change
@@ -1,18 +1,18 @@
import json

from django import http from django import http
from django.utils import simplejson as json from django.views.decorators.http import require_POST
from django.views.decorators.http import require_http_methods


from account.models import EmailAddress from account.models import EmailAddress
from django.contrib.auth.decorators import login_required


from kaleo.forms import InviteForm from kaleo.forms import InviteForm
from kaleo.models import JoinInvitation from kaleo.models import JoinInvitation




@require_http_methods(["POST"]) @login_required
@require_POST
def invite(request): 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) form = InviteForm(request.POST)
if form.is_valid(): if form.is_valid():
email = form.cleaned_data["email_address"] email = form.cleaned_data["email_address"]
Expand Down

0 comments on commit c97dc5e

Please sign in to comment.