]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/subscriptions.py
switch to a default sort of active, and "pushed" the active tab to the beggining
[osqa.git] / forum / subscriptions.py
index 4c5725650994f45c2dbc9d8579fc5db812c2884f..4966ec65772c1b44683d6a770b07fccdd855acbe 100644 (file)
@@ -3,6 +3,7 @@ import re
 import datetime\r
 from forum.models import User, Question, Comment, QuestionSubscription, SubscriptionSettings, Answer\r
 from forum.models.user import activity_record\r
+from forum.models.node import node_create\r
 from forum.utils.mail import send_email\r
 from forum.views.readers import question_view\r
 from django.utils.translation import ugettext as _\r
@@ -25,9 +26,7 @@ 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(instance, created, **kwargs):\r
-    if not created: return\r
-\r
+def question_posted(instance, **kwargs):\r
     question = instance\r
 \r
     subscribers = User.objects.values('email', 'username').filter(\r
@@ -57,12 +56,10 @@ def question_posted(instance, created, **kwargs):
     for user in new_subscribers:\r
         create_subscription_if_not_exists(question, user)\r
 \r
-#post_save.connect(question_posted, sender=Question)\r
-\r
+node_create.connect(question_posted, sender=Question)\r
 \r
-def answer_posted(instance, created, **kwargs):\r
-    if not created: return\r
 \r
+def answer_posted(instance, **kwargs):\r
     answer = instance\r
     question = answer.question\r
 \r
@@ -82,11 +79,11 @@ def answer_posted(instance, created, **kwargs):
     if answer.author.subscription_settings.questions_answered:\r
         create_subscription_if_not_exists(question, answer.author)\r
 \r
-post_save.connect(answer_posted, sender=Answer)\r
+node_create.connect(answer_posted, sender=Answer)\r
 \r
 \r
-def comment_posted(sender, instance, **kwargs):\r
-    comment = instance.content_object\r
+def comment_posted(instance, **kwargs):\r
+    comment = instance\r
     post = comment.content_object\r
 \r
     if post.__class__ == Question:\r
@@ -107,7 +104,7 @@ def comment_posted(sender, instance, **kwargs):
                                 )\r
 \r
     subscribers = subscribers.filter(\r
-            q_filter, subscription_settings__subscribed_questions='i', subscription_settings__enable_notifications=True \r
+            q_filter, subscription_settings__subscribed_questions='i', subscription_settings__enable_notifications=True\r
     ).exclude(id=comment.user.id).distinct()\r
 \r
     recipients = create_recipients_dict(subscribers)\r
@@ -122,8 +119,7 @@ def comment_posted(sender, instance, **kwargs):
     if comment.user.subscription_settings.questions_commented:\r
         create_subscription_if_not_exists(question, comment.user)\r
 \r
-activity_record.connect(comment_posted, sender=const.TYPE_ACTIVITY_COMMENT_QUESTION, weak=False)\r
-activity_record.connect(comment_posted, sender=const.TYPE_ACTIVITY_COMMENT_ANSWER, weak=False)\r
+node_create.connect(comment_posted, sender=Comment)\r
 \r
 \r
 def answer_accepted(instance, created, **kwargs):\r