Mercurial > public > sg101
diff gpp/forums/views.py @ 216:fe900598f81c
Implement #85 - display who has posted from a post's IP address.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 30 May 2010 20:51:41 +0000 |
parents | 8c1832b9d815 |
children |
line wrap: on
line diff
--- a/gpp/forums/views.py Sat May 29 04:51:28 2010 +0000 +++ b/gpp/forums/views.py Sun May 30 20:51:41 2010 +0000 @@ -748,6 +748,24 @@ return _user_posts(request, target_user, request.user, 'Posts by %s' % username) +@login_required +def post_ip_info(request, post_id): + """Displays information about the IP address the post was made from.""" + post = get_object_or_404(Post.objects.select_related(), pk=post_id) + + if not _can_moderate(post.topic.forum, request.user): + return HttpResponseForbidden("You don't have permission for this post.") + + ip_users = sorted(set(Post.objects.filter( + user_ip=post.user_ip).values_list('user__username', flat=True))) + + return render_to_response('forums/post_ip.html', { + 'post': post, + 'ip_users': ip_users, + }, + context_instance=RequestContext(request)) + + def _user_posts(request, target_user, req_user, page_title): """Displays a list of posts made by the target user. req_user is the user trying to view the posts. Only the forums