Mercurial > public > sg101
comparison gpp/forums/signals.py @ 469:3b30286adba5
Smarter search index updating for forums. This work is for #227.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 17 Aug 2011 01:02:08 +0000 |
parents | e0523e17ea43 |
children | d9b6c4ec1977 |
comparison
equal
deleted
inserted
replaced
468:ad4b63fbc584 | 469:3b30286adba5 |
---|---|
1 """ | 1 """ |
2 Signal handlers for the forums application. | 2 Signal handlers & signals for the forums application. |
3 | |
3 """ | 4 """ |
4 from django.db.models.signals import post_save | 5 from django.db.models.signals import post_save |
5 from django.db.models.signals import post_delete | 6 from django.db.models.signals import post_delete |
7 import django.dispatch | |
6 | 8 |
7 from forums.models import Forum, Topic, Post | 9 from forums.models import Forum, Topic, Post |
8 from forums.views.subscriptions import notify_topic_subscribers | 10 from forums.views.subscriptions import notify_topic_subscribers |
9 from forums.tools import auto_favorite, auto_subscribe | 11 from forums.tools import auto_favorite, auto_subscribe |
10 | 12 |
63 post_save.connect(on_topic_save, sender=Topic, dispatch_uid='forums.signals') | 65 post_save.connect(on_topic_save, sender=Topic, dispatch_uid='forums.signals') |
64 post_delete.connect(on_topic_delete, sender=Topic, dispatch_uid='forums.signals') | 66 post_delete.connect(on_topic_delete, sender=Topic, dispatch_uid='forums.signals') |
65 | 67 |
66 post_save.connect(on_post_save, sender=Post, dispatch_uid='forums.signals') | 68 post_save.connect(on_post_save, sender=Post, dispatch_uid='forums.signals') |
67 post_delete.connect(on_post_delete, sender=Post, dispatch_uid='forums.signals') | 69 post_delete.connect(on_post_delete, sender=Post, dispatch_uid='forums.signals') |
70 | |
71 | |
72 # Signals for the forums application. | |
73 # | |
74 # This signal is sent when a topic has had its textual content (title) changed. | |
75 # The provided arguments are: | |
76 # sender - the topic model instance | |
77 # instance - the topic model instance | |
78 # created - True if the topic is new, False if updated | |
79 | |
80 topic_content_update = django.dispatch.Signal(providing_args=['action']) | |
81 | |
82 # This signal is sent when a post has had its textual content (body) changed. | |
83 # The provided arguments are: | |
84 # sender - the post model instance | |
85 # instance - the topic model instance | |
86 # created - True if the post is new, False if updated | |
87 | |
88 post_content_update = django.dispatch.Signal(providing_args=['action']) | |
89 | |
90 | |
91 def notify_new_topic(topic): | |
92 """ | |
93 Sends the topic_content_update signal for a new topic instance. | |
94 | |
95 """ | |
96 topic_content_update.send_robust(topic, instance=topic, created=True) | |
97 | |
98 | |
99 def notify_updated_topic(topic): | |
100 """ | |
101 Sends the topic_content_update signal for an updated topic instance. | |
102 | |
103 """ | |
104 topic_content_update.send_robust(topic, instance=topic, created=False) | |
105 | |
106 | |
107 def notify_new_post(post): | |
108 """ | |
109 Sends the post_content_update signal for a new post instance. | |
110 | |
111 """ | |
112 post_content_update.send_robust(post, instance=post, created=True) | |
113 | |
114 | |
115 def notify_updated_post(post): | |
116 """ | |
117 Sends the post_content_update signal for an updated post instance. | |
118 | |
119 """ | |
120 post_content_update.send_robust(post, instance=post, created=False) |