]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/reputation.py
fix in flag and delete commands, and added the possibility for admins and post author...
[osqa.git] / forum / reputation.py
index 7bca6659c97bee1062aea462d235da748aea2ba0..fd5ce633363ffc269b0b676cb31fc7f706dcd525 100644 (file)
@@ -9,10 +9,10 @@ def on_flagged_item(instance, created, **kwargs):
     if not created:\r
         return\r
 \r
-    post = instance.content_object\r
+    post = instance.content_object.leaf\r
     question = (post.__class__ == Question) and post or post.question\r
 \r
-    user.reputes.create(value=-int(settings.REP_LOST_BY_FLAGGED), question=question,\r
+    post.author.reputes.create(value=-int(settings.REP_LOST_BY_FLAGGED), question=question,\r
                reputation_type=TYPE_REPUTATION_LOST_BY_FLAGGED)\r
 \r
 \r
@@ -50,7 +50,7 @@ post_save.connect(on_answer_accepted_switch, sender=Answer)
 \r
 def on_vote(instance, created, **kwargs):\r
     if created and not instance.content_object.wiki:\r
-        post = instance.content_object\r
+        post = instance.content_object.leaf\r
         question = (post.__class__ == Question) and post or post.question\r
 \r
         if instance.vote == -1:\r
@@ -71,7 +71,7 @@ post_save.connect(on_vote, sender=Vote)
 \r
 def on_vote_canceled(instance, **kwargs):\r
     if not instance.content_object.wiki:\r
-        post = instance.content_object\r
+        post = instance.content_object.leaf\r
         question = (post.__class__ == Question) and post or post.question\r
 \r
         if instance.vote == -1:\r