]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/activity.py
changed how we import the datepicker lib to use google's load function.
[osqa.git] / forum / activity.py
index a58307ba0123faea2eeb119f8cef51321b42751f..16877987317bea44a077ae37b8fed03f519d27f1 100644 (file)
@@ -1,35 +1,32 @@
 import datetime\r
 from django.db.models.signals import post_save\r
 from forum.models import *\r
-from forum.models.base import marked_deleted\r
-from forum.models.meta import vote_canceled\r
+from forum.models.base import marked_deleted, mark_canceled\r
+from forum.models.node import node_create\r
 from forum.models.answer import answer_accepted\r
 from forum.authentication import user_updated\r
 from forum.const import *\r
 \r
-def record_ask_event(instance, created, **kwargs):\r
-    if created:\r
-        activity = Activity(user=instance.author, active_at=instance.added_at, content_object=instance, activity_type=TYPE_ACTIVITY_ASK_QUESTION)\r
-        activity.save()\r
+def record_ask_event(instance, **kwargs):\r
+    activity = Activity(user=instance.author, active_at=instance.added_at, content_object=instance, activity_type=TYPE_ACTIVITY_ASK_QUESTION)\r
+    activity.save()\r
 \r
-post_save.connect(record_ask_event, sender=Question)\r
+node_create.connect(record_ask_event, sender=Question)\r
 \r
 \r
-def record_answer_event(instance, created, **kwargs):\r
-    if created:\r
-        activity = Activity(user=instance.author, active_at=instance.added_at, content_object=instance, activity_type=TYPE_ACTIVITY_ANSWER)\r
-        activity.save()\r
+def record_answer_event(instance, **kwargs):\r
+    activity = Activity(user=instance.author, active_at=instance.added_at, content_object=instance, activity_type=TYPE_ACTIVITY_ANSWER)\r
+    activity.save()\r
 \r
-post_save.connect(record_answer_event, sender=Answer)\r
+node_create.connect(record_answer_event, sender=Answer)\r
 \r
 \r
-def record_comment_event(instance, created, **kwargs):\r
-    if created:\r
-        act_type = (instance.content_object.__class__ is Question) and TYPE_ACTIVITY_COMMENT_QUESTION or TYPE_ACTIVITY_COMMENT_ANSWER\r
-        activity = Activity(user=instance.user, active_at=instance.added_at, content_object=instance, activity_type=act_type)\r
-        activity.save()\r
+def record_comment_event(instance, **kwargs):\r
+    act_type = (instance.content_object.__class__ is Question) and TYPE_ACTIVITY_COMMENT_QUESTION or TYPE_ACTIVITY_COMMENT_ANSWER\r
+    activity = Activity(user=instance.user, active_at=instance.added_at, content_object=instance, activity_type=act_type)\r
+    activity.save()\r
 \r
-post_save.connect(record_comment_event, sender=Comment)\r
+node_create.connect(record_comment_event, sender=Comment)\r
 \r
 \r
 def record_revision_event(instance, created, **kwargs):\r
@@ -80,7 +77,7 @@ def record_cancel_vote(instance, **kwargs):
     activity = Activity(user=instance.user, active_at=datetime.datetime.now(), content_object=instance, activity_type=act_type)\r
     activity.save()\r
 \r
-vote_canceled.connect(record_cancel_vote)\r
+mark_canceled.connect(record_cancel_vote, sender=Vote)\r
 \r
 \r
 def record_delete_post(instance, **kwargs):\r