comparison gpp/forums/signals.py @ 390:e0523e17ea43

Fixing #175; add an auto-subscribe and auto-favorite forum topic feature. Added 2 flags to the user profile. Added 2 functions that are called on the post post-save signal that auto-favorite and auto-subscribe the post creator if they have requested this service.
author Brian Neal <bgneal@gmail.com>
date Mon, 21 Mar 2011 00:39:52 +0000
parents d1b11096595b
children 3b30286adba5
comparison
equal deleted inserted replaced
389:3fa61786abf1 390:e0523e17ea43
4 from django.db.models.signals import post_save 4 from django.db.models.signals import post_save
5 from django.db.models.signals import post_delete 5 from django.db.models.signals import post_delete
6 6
7 from forums.models import Forum, Topic, Post 7 from forums.models import Forum, Topic, Post
8 from forums.views.subscriptions import notify_topic_subscribers 8 from forums.views.subscriptions import notify_topic_subscribers
9 from forums.tools import auto_favorite, auto_subscribe
9 10
10 11
11 def on_topic_save(sender, **kwargs): 12 def on_topic_save(sender, **kwargs):
12 if kwargs['created']: 13 if kwargs['created']:
13 topic = kwargs['instance'] 14 topic = kwargs['instance']
34 post.topic.forum.save() 35 post.topic.forum.save()
35 36
36 # send out any email notifications 37 # send out any email notifications
37 notify_topic_subscribers(post) 38 notify_topic_subscribers(post)
38 39
40 # perform any auto-favorite and auto-subscribe actions for the new post
41 auto_favorite(post)
42 auto_subscribe(post)
43
39 44
40 def on_post_delete(sender, **kwargs): 45 def on_post_delete(sender, **kwargs):
41 post = kwargs['instance'] 46 post = kwargs['instance']
42 47
43 # update the topic 48 # update the topic