Skip to content
This repository

Notifier commenters of replies via email #511

Open
wants to merge 1 commit into from

2 participants

renwofei423 Stephen McDonald
renwofei423

Send email to reply or post people,instead of ADMINS.
I think it will more useful.

renwofei423 Update mezzanine/generic/views.py
send email to reply or post people,instead of ADMINS
2d03712
Stephen McDonald
Owner

Hey there, thanks a lot for submitting this.

There's quite a bit more work that would be involved in implementing it properly:

  • The code references blog posts explicitly, but comments can be associated with any model. We'd need a generic way to look up the model, and it'd also need to check a Boolean field on that model (called say email_replies, defaulting to False) to see if the author of the blog post even wants comments email to them, since they might not!
  • No option is given to the commenter (or even the blog post author as I mentioned) to let them control whether or not they want emails sent to them, so we don't even have their permission to do so. We'd need another new Boolean field on the comment model (also defaulting to False) for the commenter to flag that they actually want email sent to them. Also with that in place, the email would need an unsubscribe link so that the commenter could choose to stop receiving emails. This would need to be a separate email send by the way, since the unsubscribe link would be specific to the commenter, not the blog post author.
  • The way it's implemented, if it finds emails to send to, it ends up ignoring the COMMENTS_NOTIFICATION_EMAILS setting entirely. They should still get the same email, along with the blog author if the setup above is implemented.
  • There's an empty except clause - what error is being trapped? There's probably no need for this with all of the above implemented more granularly.

Thanks again for kicking this off - it'll be a great addition with the above implemented.

Stephen McDonald stephenmcd closed this December 22, 2012
Stephen McDonald stephenmcd reopened this December 22, 2012
Stephen McDonald
Owner

Sorry, no need to close this really. Let's leave it open.

renwofei423

Sorry! The application scene is in our cmpany,which might be mandatory in some way. I didn't think that much.

Time permitted,I will try to improve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 20, 2012
renwofei423 Update mezzanine/generic/views.py
send email to reply or post people,instead of ADMINS
2d03712
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 13 additions and 2 deletions. Show diff stats Hide diff stats

  1. 15  mezzanine/generic/views.py
15  mezzanine/generic/views.py
... ...
@@ -1,4 +1,3 @@
1  
-
2 1
 from django.contrib.admin.views.decorators import staff_member_required
3 2
 from django.contrib.messages import error
4 3
 from django.contrib.comments.signals import comment_was_posted
@@ -83,7 +82,19 @@ def comment(request, template="generic/comments.html"):
83 82
                                 request=request)
84 83
         # Send notification emails.
85 84
         comment_url = add_cache_bypass(comment.get_absolute_url())
86  
-        notify_emails = filter(None, [addr.strip() for addr in
  85
+        #=======================================================================
  86
+        # send email to reply or post people,instead of ADMINS
  87
+        #=======================================================================
  88
+        try:
  89
+            from mezzanine.blog.models import BlogPost
  90
+            notify_emails = [BlogPost.objects.get(id=comment.object_pk).user.email]
  91
+            
  92
+            if comment.threadedcomment.replied_to != None:
  93
+                other_email = comment.threadedcomment.replied_to.user_email             
  94
+                notify_emails += [other_email]
  95
+#            print notify_emails
  96
+        except:            
  97
+            notify_emails = filter(None, [addr.strip() for addr in
87 98
                             settings.COMMENTS_NOTIFICATION_EMAILS.split(",")])
88 99
         if notify_emails:
89 100
             subject = _("New comment for: ") + unicode(obj)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.