]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/actions/meta.py
Fixes a problem that might allow some users to get multiple badges in some strange...
[osqa.git] / forum / actions / meta.py
index 1862cb3113c04c2910e7bb0992958153ea5c8459..ccdaa75f390396d09b2687b95e1277f3b450e9b9 100644 (file)
@@ -27,6 +27,14 @@ class VoteAction(ActionProxy):
         except:\r
             return None\r
 \r
         except:\r
             return None\r
 \r
+    @classmethod\r
+    def get_action_for(cls, user, node):\r
+        try:\r
+            vote = Vote.objects.get(user=user, node=node)\r
+            return vote.action\r
+        except:\r
+            return None\r
+\r
     def describe_vote(self, vote_desc, viewer=None):\r
         return _("%(user)s %(vote_desc)s %(post_desc)s") % {\r
             'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),\r
     def describe_vote(self, vote_desc, viewer=None):\r
         return _("%(user)s %(vote_desc)s %(post_desc)s") % {\r
             'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),\r
@@ -94,7 +102,7 @@ class FlagAction(ActionProxy):
 \r
         if self.node.flag_count == int(settings.FLAG_COUNT_TO_DELETE_POST):\r
             self.repute(self.node.author, -int(settings.REP_LOST_BY_FLAGGED_5_TIMES))\r
 \r
         if self.node.flag_count == int(settings.FLAG_COUNT_TO_DELETE_POST):\r
             self.repute(self.node.author, -int(settings.REP_LOST_BY_FLAGGED_5_TIMES))\r
-            if not self.node.deleted:\r
+            if not self.node.nis.deleted:\r
                 DeleteAction(node=self.node, user=self.user, extra="BYFLAGGED").save()\r
 \r
     def cancel_action(self):\r
                 DeleteAction(node=self.node, user=self.user, extra="BYFLAGGED").save()\r
 \r
     def cancel_action(self):\r
@@ -128,14 +136,14 @@ class AcceptAnswerAction(ActionProxy):
         self.node.parent.extra_ref = self.node\r
         self.node.parent.save()\r
         self.node.marked = True\r
         self.node.parent.extra_ref = self.node\r
         self.node.parent.save()\r
         self.node.marked = True\r
-        self.node.extra_action = self\r
+        self.node.nstate.accepted = self\r
         self.node.save()\r
 \r
     def cancel_action(self):\r
         self.node.parent.extra_ref = None\r
         self.node.parent.save()\r
         self.node.marked = False\r
         self.node.save()\r
 \r
     def cancel_action(self):\r
         self.node.parent.extra_ref = None\r
         self.node.parent.save()\r
         self.node.marked = False\r
-        self.node.extra_action = None\r
+        self.node.nstate.accepted = None\r
         self.node.save()\r
 \r
     def describe(self, viewer=None):\r
         self.node.save()\r
 \r
     def describe(self, viewer=None):\r
@@ -149,7 +157,7 @@ class AcceptAnswerAction(ActionProxy):
 \r
         return _("%(user)s accepted %(answerer)s answer on %(asker)s question %(question)s") % {\r
             'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),\r
 \r
         return _("%(user)s accepted %(answerer)s answer on %(asker)s question %(question)s") % {\r
             'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),\r
-            'answerer': self.hyperlink(answer.author.get_profile_url(), self.friendly_username(viewer, answer.author)),\r
+            'answerer': self.hyperlink(answer.author.get_profile_url(), self.friendly_ownername(viewer, answer.author)),\r
             'asker': asker,\r
             'question': self.hyperlink(question.get_absolute_url(), question.title)\r
         }\r
             'asker': asker,\r
             'question': self.hyperlink(question.get_absolute_url(), question.title)\r
         }\r
@@ -183,9 +191,9 @@ class DeleteAction(ActionProxy):
             self.node.question.reset_answer_count_cache()\r
 \r
     def describe(self, viewer=None):\r
             self.node.question.reset_answer_count_cache()\r
 \r
     def describe(self, viewer=None):\r
-        return _("%(user)s deleted %(post_desc)s: %(reason)s") % {\r
+        return _("%(user)s deleted %(post_desc)s") % {\r
             'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),\r
             'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),\r
-            'post_desc': self.describe_node(viewer, self.node), 'reason': self.reason(),\r
+            'post_desc': self.describe_node(viewer, self.node)\r
         }\r
 \r
     def reason(self):\r
         }\r
 \r
     def reason(self):\r