]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/actions/meta.py
Several improvements in full text search operations.
[osqa.git] / forum / actions / meta.py
index 7c951101f8954885e1ed811b3561b65d47142d87..a964ef1db289ca0ec9171441046434c2d8f75c98 100644 (file)
@@ -97,12 +97,12 @@ class FlagAction(ActionProxy):
         flag.save()\r
         self.node.reset_flag_count_cache()\r
 \r
-        if self.node.flag_count == int(settings.FLAG_COUNT_TO_HIDE_POST):\r
+        if self.node.flag_count >= int(settings.FLAG_COUNT_TO_HIDE_POST):\r
             self.repute(self.node.author, -int(settings.REP_LOST_BY_FLAGGED_3_TIMES))\r
 \r
-        if self.node.flag_count == int(settings.FLAG_COUNT_TO_DELETE_POST):\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
@@ -133,18 +133,16 @@ class AcceptAnswerAction(ActionProxy):
             self.repute(self.node.author, int(settings.REP_GAIN_BY_ACCEPTED))\r
 \r
     def process_action(self):\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
+        self.node.question.reset_accepted_count_cache()\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
+        self.node.question.reset_accepted_count_cache()\r
 \r
     def describe(self, viewer=None):\r
         answer = self.node\r
@@ -157,7 +155,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
-            '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