]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/activity.py
ALteration of the schema to a single content model. As a bonus there is a complete...
[osqa.git] / forum / activity.py
index 9c27e12fd9ea90dfdc89af14a68f7dd240722126..1f2d7f081b3afb415108cc64aab5a3e30f743fa7 100644 (file)
@@ -31,20 +31,13 @@ def record_comment_event(instance, created, **kwargs):
 post_save.connect(record_comment_event, sender=Comment)\r
 \r
 \r
-def record_question_revision_event(instance, created, **kwargs):\r
-    if created and instance.revision <> 1:\r
-        activity = Activity(user=instance.author, active_at=instance.revised_at, content_object=instance, activity_type=TYPE_ACTIVITY_UPDATE_QUESTION)\r
+def record_revision_event(instance, created, **kwargs):\r
+    if created and instance.revision <> 1 and instance.node.node_type in ('question', 'answer',):\r
+        activity_type = instance.node == 'question' and TYPE_ACTIVITY_UPDATE_QUESTION or TYPE_ACTIVITY_UPDATE_ANSWER\r
+        activity = Activity(user=instance.author, active_at=instance.revised_at, content_object=instance, activity_type=activity_type)\r
         activity.save()\r
 \r
-post_save.connect(record_question_revision_event, sender=QuestionRevision)\r
-\r
-\r
-def record_answer_revision_event(instance, created, **kwargs):\r
-    if created and instance.revision <> 1:\r
-        activity = Activity(user=instance.author, active_at=instance.revised_at, content_object=instance, activity_type=TYPE_ACTIVITY_UPDATE_ANSWER)\r
-        activity.save()\r
-\r
-post_save.connect(record_answer_revision_event, sender=AnswerRevision)\r
+post_save.connect(record_revision_event, sender=NodeRevision)\r
 \r
 \r
 def record_award_event(instance, created, **kwargs):\r