From 3a3c00de881e3387562d8b2f46b8c5debba17639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 20 Oct 2012 20:55:55 +0200 Subject: [PATCH] Send mail to author and add proxyied IP to comments --- views.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/views.py b/views.py index 416caea..ee14f8e 100644 --- a/views.py +++ b/views.py @@ -533,8 +533,14 @@ def add_comment(request, post_id, parent_id): print 'Error on author or the_comment' return HttpResponseRedirect(ref) + # Behind a proxy + if 'X-Real-IP' in request.META: + ip = request.META['X-Real-IP'] + else: + ip = request.META['REMOTE_ADDR'] + comment = Comment(post=post, parent=parentComment, date=datetime.now(), author=request.POST['author'],\ - email=request.POST['email'], the_comment=request.POST['the_comment'], ip=request.META['REMOTE_ADDR']) + email=request.POST['email'], the_comment=request.POST['the_comment'], ip=ip) comment.save() engine = globals()['post'] @@ -557,6 +563,10 @@ def add_comment(request, post_id, parent_id): if email != '' and email != request.POST['email'] and not email in emails: emails[email] = comment.author + + if post.author.email not in email: + emails[post.author.email] = post.author.first_name + if len(emails) > 0: connection = mail.get_connection(fail_silently=True) connection.open()