+class CommentToAnswerAction(ActionProxy):\r
+ verb = _("converted")\r
+\r
+ def process_data(self, question):\r
+ self.node.parent = question\r
+ self.node.node_type = "answer"\r
+ self.node.last_edited = self\r
+ self.node.update_last_activity(self.user, save=True)\r
+\r
+ # Now updated the cached data\r
+ question.reset_answer_count_cache()\r
+\r
+ def describe(self, viewer=None):\r
+ return _("%(user)s converted comment on %(question)s into an answer") % {\r
+ 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),\r
+ 'question': self.describe_node(viewer, self.node.abs_parent),\r
+ }\r
+\r
+class AnswerToQuestionAction(NodeEditAction):\r
+ verb = _("converted to question")\r
+\r
+ def process_data(self, **data):\r
+ revision_data = self.create_revision_data(**data)\r
+ revision = self.node.create_revision(self.user, **revision_data)\r
+\r
+ original_question = self.node.question\r
+\r
+ self.extra = {\r
+ 'covert_revision': revision.revision,\r
+ 'original_question': original_question\r
+ }\r
+\r
+ self.node.node_type = "question"\r
+ self.node.parent = None\r
+ self.node.abs_parent = None\r
+\r
+ original_question.reset_answer_count_cache()\r
+\r
+ def process_action(self):\r
+ self.node.last_edited = self\r
+ self.node.save()\r
+\r
+\r
+ def describe(self, viewer=None):\r
+ return _("%(user)s converted an answer to %(question)s into a separate question") % {\r
+ 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),\r
+ 'question': self.describe_node(viewer, self.node.abs_parent),\r
+ }\r
+\r