]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/actions/node.py
revert previous commit
[osqa.git] / forum / actions / node.py
index 79b7531657c1d096abe20e99d326eb9f379651b4..5ba6e2bfe0f1904f6571d6974bdecf5aff0ec5b9 100644 (file)
@@ -28,6 +28,8 @@ class AskAction(NodeEditAction):
         question.save()
         self.node = question
 
+        self.user.message_set.create(message=self.describe(self.user))
+
     def describe(self, viewer=None):
         return _("%(user)s asked %(question)s") % {
             'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
@@ -45,6 +47,9 @@ class AnswerAction(NodeEditAction):
     def process_action(self):
         self.node.question.reset_answer_count_cache()
 
+        self.user.message_set.create(message=self.describe(self.user))
+
+
     def describe(self, viewer=None):
         question = self.node.parent
         return _("%(user)s answered %(asker)s on %(question)s") % {
@@ -197,6 +202,30 @@ class CommentToAnswerAction(ActionProxy):
             'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
             'question': self.describe_node(viewer, self.node.abs_parent),
         }
+class CommentToQuestionAction(NodeEditAction):
+    verb = _("converted")
+
+    def process_data(self, **data):
+        revision_data = self.create_revision_data(**data)
+        revision = self.node.create_revision(self.user, **revision_data)
+
+        self.extra = {
+            'covert_revision': revision.revision,
+        }
+
+        self.node.node_type = "question"
+        self.node.parent = None
+        self.node.abs_parent = None
+
+    def process_action(self):
+        self.node.last_edited = self
+        self.node.save()
+
+    def describe(self, viewer=None):
+        return _("%(user)s converted comment on %(question)s to a new question") % {
+            'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
+            'question': self.describe_node(viewer, self.node.abs_parent),
+        }
 
 class AnswerToQuestionAction(NodeEditAction):
     verb = _("converted to question")