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