]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/subscriptions.py
ALteration of the schema to a single content model. As a bonus there is a complete...
[osqa.git] / forum / subscriptions.py
index fb2eae9c8169fe4c1b23a8640116877374b4eb52..4c5725650994f45c2dbc9d8579fc5db812c2884f 100644 (file)
@@ -25,8 +25,10 @@ def apply_default_filters(queryset, excluded_id):
 def create_recipients_dict(usr_list):\r
     return [(s['username'], s['email'], {'username': s['username']}) for s in usr_list]\r
 \r
-def question_posted(sender, instance, **kwargs):\r
-    question = instance.content_object\r
+def question_posted(instance, created, **kwargs):\r
+    if not created: return\r
+\r
+    question = instance\r
 \r
     subscribers = User.objects.values('email', 'username').filter(\r
             Q(subscription_settings__enable_notifications=True, subscription_settings__new_question='i') |\r
@@ -55,11 +57,13 @@ def question_posted(sender, instance, **kwargs):
     for user in new_subscribers:\r
         create_subscription_if_not_exists(question, user)\r
 \r
-activity_record.connect(question_posted, sender=const.TYPE_ACTIVITY_ASK_QUESTION, weak=False)\r
+#post_save.connect(question_posted, sender=Question)\r
+\r
 \r
+def answer_posted(instance, created, **kwargs):\r
+    if not created: return\r
 \r
-def answer_posted(sender, instance, **kwargs):\r
-    answer = instance.content_object\r
+    answer = instance\r
     question = answer.question\r
 \r
     subscribers = question.subscribers.values('email', 'username').filter(\r
@@ -78,7 +82,7 @@ def answer_posted(sender, instance, **kwargs):
     if answer.author.subscription_settings.questions_answered:\r
         create_subscription_if_not_exists(question, answer.author)\r
 \r
-activity_record.connect(answer_posted, sender=const.TYPE_ACTIVITY_ANSWER, weak=False)\r
+post_save.connect(answer_posted, sender=Answer)\r
 \r
 \r
 def comment_posted(sender, instance, **kwargs):\r