Mercurial > public > sg101
comparison gpp/forums/signals.py @ 522:82b97697312e
Created Celery tasks to process new posts and topics. Keep the updated topic set in Redis.
This is for tickets #194, #237, #239.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 18 Dec 2011 23:46:52 +0000 |
parents | d9b6c4ec1977 |
children |
comparison
equal
deleted
inserted
replaced
521:dd14ab08a9c4 | 522:82b97697312e |
---|---|
5 from django.db.models.signals import post_save | 5 from django.db.models.signals import post_save |
6 from django.db.models.signals import post_delete | 6 from django.db.models.signals import post_delete |
7 import django.dispatch | 7 import django.dispatch |
8 | 8 |
9 from forums.models import Forum, Topic, Post | 9 from forums.models import Forum, Topic, Post |
10 from forums.views.subscriptions import notify_topic_subscribers | |
11 from forums.tools import auto_favorite, auto_subscribe | |
12 | 10 |
13 | 11 |
14 def on_topic_save(sender, **kwargs): | 12 def on_topic_save(sender, **kwargs): |
15 if kwargs['created']: | 13 if kwargs['created']: |
16 topic = kwargs['instance'] | 14 topic = kwargs['instance'] |
20 | 18 |
21 def on_topic_delete(sender, **kwargs): | 19 def on_topic_delete(sender, **kwargs): |
22 topic = kwargs['instance'] | 20 topic = kwargs['instance'] |
23 topic.forum.topic_count_update() | 21 topic.forum.topic_count_update() |
24 topic.forum.save() | 22 topic.forum.save() |
23 forums.latest.notify_topic_delete(topic) | |
25 | 24 |
26 | 25 |
27 def on_post_save(sender, **kwargs): | 26 def on_post_save(sender, **kwargs): |
28 if kwargs['created']: | 27 if kwargs['created']: |
29 post = kwargs['instance'] | 28 post = kwargs['instance'] |
33 post.topic.save() | 32 post.topic.save() |
34 | 33 |
35 # update the forum | 34 # update the forum |
36 post.topic.forum.post_count_update() | 35 post.topic.forum.post_count_update() |
37 post.topic.forum.save() | 36 post.topic.forum.save() |
38 | |
39 # send out any email notifications | |
40 notify_topic_subscribers(post) | |
41 | |
42 # perform any auto-favorite and auto-subscribe actions for the new post | |
43 auto_favorite(post) | |
44 auto_subscribe(post) | |
45 | 37 |
46 | 38 |
47 def on_post_delete(sender, **kwargs): | 39 def on_post_delete(sender, **kwargs): |
48 post = kwargs['instance'] | 40 post = kwargs['instance'] |
49 | 41 |
114 """ | 106 """ |
115 Sends the post_content_update signal for an updated post instance. | 107 Sends the post_content_update signal for an updated post instance. |
116 | 108 |
117 """ | 109 """ |
118 post_content_update.send_robust(post, created=False) | 110 post_content_update.send_robust(post, created=False) |
111 | |
112 | |
113 # Avoid circular imports | |
114 import forums.latest |