From 419cb678949006d2c5bd6bf5a3176c67adf4cef7 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 31 Oct 2008 21:23:04 +0100 Subject: [PATCH] Send a notification on comment creation. --- influences/notify.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/influences/notify.py b/influences/notify.py index 86a5047..e5c763a 100644 --- a/influences/notify.py +++ b/influences/notify.py @@ -4,6 +4,7 @@ from django.conf import settings from xerxes.influences.models import Character,Influence from xerxes.tools.notify import notify from django.contrib.auth.models import Group +from threadedcomments.models import ThreadedComment def character_saved(**kwargs): instance = kwargs['instance'] @@ -20,6 +21,26 @@ def influence_saved(**kwargs): # TODO: Perhaps only notify when the status is / becomes Done? notify([instance.character.player, 'lextalionis@evolution-events.nl'], 'influences/email/influence_changed.html', {'influence' : instance, 'created' : created}) -signals.post_save.connect(influence_saved, sender=Influence) +def comment_saved(**kwargs): + if (settings.DEBUG): + return + + comment = kwargs['instance'] + # We don't support comment editing, but let's check this anyway + if not kwargs['created']: + return + + object = comment.content_object + if isinstance(object, Influence): + notify( + [object.character.player, 'matthijs@stdin.nl'], + 'influences/email/influence_comment_added.html', + {'comment' : comment, + 'influence' : object, + 'commenter' : comment.user + } + ) + +signals.post_save.connect(comment_saved, sender=ThreadedComment) # vim: set sts=4 sw=4 expandtab: -- 2.30.2