Permalink
Browse files

MOve the add_friend part of the action to it's own view

  • Loading branch information...
1 parent cdf126b commit 8b2bd89e340bbbba10c0af36b6d22db66b2713bc @alex alex committed Oct 24, 2009
Showing with 17 additions and 5 deletions.
  1. +17 −5 friends/views.py
View
@@ -1,5 +1,6 @@
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
+from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
@@ -9,14 +10,25 @@
@login_required
def find_friends(request):
- if request.method == "POST":
- u = get_object_or_404(User, pk=request.POST["user_id"])
- FriendshipInvitation.create_friendship_request(request.user, u)
- return HttpResponseRedirect(request.path)
- elif request.GET.get("q"):
+ if request.GET.get("q"):
friends = User.objects.filter(username__icontains=request.GET["q"])
else:
friends = None
return render_to_response("friends/find_friends.html", {
"friends": friends,
}, context_instance=RequestContext(request))
+
+"""
+@login_required
+def add_friend(request):
+ if request.method == "POST":
+ form = AddFriendForm(request.POST)
+ if form.is_valid():
+ form.save()
+ return HttpResponseRedirect(reverse(find_friends))
+ else:
+ form = AddFriendForm()
+ return render_to_response("friends/add_fiend.html", {
+ "form": form,
+ })
+"""

0 comments on commit 8b2bd89

Please sign in to comment.