Mercurial > public > sg101
comparison 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 |
comparison
equal
deleted
inserted
replaced
215:8c1832b9d815 | 216:fe900598f81c |
---|---|
746 """ | 746 """ |
747 target_user = get_object_or_404(User, username=username) | 747 target_user = get_object_or_404(User, username=username) |
748 return _user_posts(request, target_user, request.user, 'Posts by %s' % username) | 748 return _user_posts(request, target_user, request.user, 'Posts by %s' % username) |
749 | 749 |
750 | 750 |
751 @login_required | |
752 def post_ip_info(request, post_id): | |
753 """Displays information about the IP address the post was made from.""" | |
754 post = get_object_or_404(Post.objects.select_related(), pk=post_id) | |
755 | |
756 if not _can_moderate(post.topic.forum, request.user): | |
757 return HttpResponseForbidden("You don't have permission for this post.") | |
758 | |
759 ip_users = sorted(set(Post.objects.filter( | |
760 user_ip=post.user_ip).values_list('user__username', flat=True))) | |
761 | |
762 return render_to_response('forums/post_ip.html', { | |
763 'post': post, | |
764 'ip_users': ip_users, | |
765 }, | |
766 context_instance=RequestContext(request)) | |
767 | |
768 | |
751 def _user_posts(request, target_user, req_user, page_title): | 769 def _user_posts(request, target_user, req_user, page_title): |
752 """Displays a list of posts made by the target user. | 770 """Displays a list of posts made by the target user. |
753 req_user is the user trying to view the posts. Only the forums | 771 req_user is the user trying to view the posts. Only the forums |
754 req_user can see are searched. | 772 req_user can see are searched. |
755 """ | 773 """ |