# HG changeset patch # User Brian Neal # Date 1275252701 0 # Node ID fe900598f81c42370d5c5460d4aa53c06cc550da # Parent 8c1832b9d81552a19f1efda524982c30efd28a9e Implement #85 - display who has posted from a post's IP address. diff -r 8c1832b9d815 -r fe900598f81c gpp/forums/urls.py --- a/gpp/forums/urls.py Sat May 29 04:51:28 2010 +0000 +++ b/gpp/forums/urls.py Sun May 30 20:51:41 2010 +0000 @@ -21,6 +21,7 @@ url(r'^mod/topic/stick/(\d+)/$', 'mod_topic_stick', name='forums-mod_topic_stick'), url(r'^my-posts/$', 'my_posts', name='forums-my_posts'), url(r'^post/(\d+)/$', 'goto_post', name='forums-goto_post'), + url(r'^post/ip/(\d+)/$', 'post_ip_info', name='forums-post_ip_info'), url(r'^post/new/(?P\d+)/$', 'new_post', name='forums-new_post'), url(r'^posts/(?P[\w\d-]+)/$', 'posts_for_user', name='forums-posts_for_user'), url(r'^quick-reply/$', 'quick_reply_ajax', name='forums-quick_reply'), diff -r 8c1832b9d815 -r fe900598f81c gpp/forums/views.py --- 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 diff -r 8c1832b9d815 -r fe900598f81c gpp/templates/forums/display_post.html --- a/gpp/templates/forums/display_post.html Sat May 29 04:51:28 2010 +0000 +++ b/gpp/templates/forums/display_post.html Sun May 30 20:51:41 2010 +0000 @@ -27,7 +27,7 @@ {% if post.unread %}New{% endif %} Link Posted on {% forum_date post.creation_date user %} - {% if can_moderate %}from IP: {{ post.user_ip }}{% endif %} + {% if can_moderate %}from IP: {{ post.user_ip }}{% endif %}
{{ post.html|safe }} diff -r 8c1832b9d815 -r fe900598f81c gpp/templates/forums/post_ip.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gpp/templates/forums/post_ip.html Sun May 30 20:51:41 2010 +0000 @@ -0,0 +1,19 @@ +{% extends 'base.html' %} +{% block title %}Post IP Address Info: {{ post.user_ip }}{% endblock %} +{% block content %} +

Post IP Address Info: {{ post.user_ip }}

+

+This post was created by +{{ post.user.username }} from the IP address +{{ post.user_ip }}. +

+{% if ip_users %} +

All users who have posted from {{ post.user_ip }}:

+ +{% endif %} +{% endblock %}