X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=influences%2Fnotify.py;h=2e719de41c6f83b539d5a9daa4f4c5c78f0685f9;hb=0bb81ee5973a3fb3096c5e8ccbb3dd49dae0934c;hp=86a5047c63a4215dd00317c1f74af708fd140eb2;hpb=ff1befea16180a016a807b975fb4bee0bc53d662;p=matthijs%2Fprojects%2Fxerxes.git diff --git a/influences/notify.py b/influences/notify.py index 86a5047..2e719de 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'] @@ -18,8 +19,33 @@ def influence_saved(**kwargs): created = kwargs['created'] if (not settings.DEBUG): # 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}) + notify([instance.related_players.keys(), '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): + recipients = ['lextalionis@evolution-events.nl'] + if comment.is_public: + recipients.extend(object.related_players.keys()) + + notify( + recipients, + '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: