Send mail to author and add proxyied IP to comments

This commit is contained in:
Grégory Soutadé 2012-10-20 20:55:55 +02:00
parent 5ac783ae66
commit 3a3c00de88
1 changed files with 11 additions and 1 deletions

View File

@ -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()