Send mail to author and add proxyied IP to comments
This commit is contained in:
parent
5ac783ae66
commit
3a3c00de88
12
views.py
12
views.py
|
@ -533,8 +533,14 @@ def add_comment(request, post_id, parent_id):
|
||||||
print 'Error on author or the_comment'
|
print 'Error on author or the_comment'
|
||||||
return HttpResponseRedirect(ref)
|
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'],\
|
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()
|
comment.save()
|
||||||
|
|
||||||
engine = globals()['post']
|
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:
|
if email != '' and email != request.POST['email'] and not email in emails:
|
||||||
emails[email] = comment.author
|
emails[email] = comment.author
|
||||||
|
|
||||||
|
|
||||||
|
if post.author.email not in email:
|
||||||
|
emails[post.author.email] = post.author.first_name
|
||||||
|
|
||||||
if len(emails) > 0:
|
if len(emails) > 0:
|
||||||
connection = mail.get_connection(fail_silently=True)
|
connection = mail.get_connection(fail_silently=True)
|
||||||
connection.open()
|
connection.open()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user