From: Matthijs Kooijman Date: Fri, 31 Oct 2008 20:23:04 +0000 (+0100) Subject: Send a notification on comment creation. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=419cb678949006d2c5bd6bf5a3176c67adf4cef7;p=matthijs%2Fprojects%2Fxerxes.git Send a notification on comment creation. --- 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: