示例#1
0
文件: tests.py 项目: praekelt/ummeli
 def test_user_node_creation(self):
     tom = Person.get_and_update(self.tom)
     luke = Person.get_and_update(self.luke)
     
     self.assertEquals(len(tom.connections()), 0)
     
     add_connection_for_user(self.tom, self.luke)
     
     self.assertEquals(len(tom.connections()), 1)
     self.assertEquals(len(luke.connections()), 1)
     
     self.assertTrue(tom.is_connected_to(luke))
示例#2
0
文件: views.py 项目: praekelt/ummeli
def confirm_request(request, user_id):
    user = get_object_or_404(User, pk = user_id)
    profile = user.get_profile()

    if not request.user.get_profile().connection_requests.filter(pk=user_id).exists():
        raise Http404

    if request.method == 'POST':
        add_connection_for_user(user, request.user)
        request.user.get_profile().connection_requests.remove(user)
        redirect_to = request.POST.get('next', reverse('profile'))
        return redirect(redirect_to)

    next = request.GET.get('next', reverse('profile'))
    return render(request, 'profile/confirm_request.html',
                            {'other_user_profile': profile,
                             'other_user_pk':user.pk,
                             'next':next})