X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/22af493e06cfb09938f905d75d57d55519fec883..4b20a67ddb4ebea2c6e09d51ee48da5a856edef8:/forum/actions/node.py diff --git a/forum/actions/node.py b/forum/actions/node.py index be386fa..dbbb658 100644 --- a/forum/actions/node.py +++ b/forum/actions/node.py @@ -42,7 +42,7 @@ class AnswerAction(NodeEditAction): def describe(self, viewer=None): question = self.node.parent - return _("%(user)s answered %(asker)s %(question)s") % { + return _("%(user)s answered %(asker)s on %(question)s") % { 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)), 'asker': self.hyperlink(question.author.get_profile_url(), self.friendly_username(viewer, question.author)), 'question': self.hyperlink(self.node.get_absolute_url(), question.title) @@ -67,9 +67,13 @@ class ReviseAction(NodeEditAction): def process_data(self, **data): revision_data = self.create_revision_data(**data) - revision = self.node.create_revision(self.user, action=self, **revision_data) + revision = self.node.create_revision(self.user, **revision_data) self.extra = revision.revision + def process_action(self): + self.node.last_edited = self + self.node.save() + def describe(self, viewer=None): return _("%(user)s edited %(post_desc)s") % { 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)), @@ -85,7 +89,12 @@ class RetagAction(ActionProxy): def process_data(self, tagnames=''): active = self.node.active_revision revision_data = dict(summary=_('Retag'), title=active.title, tagnames=strip_tags(tagnames.strip()), body=active.body) - self.node.create_revision(self.user, action=self, **revision_data) + revision = self.node.create_revision(self.user, **revision_data) + self.extra = revision.revision + + def process_action(self): + self.node.last_edited = self + self.node.save() def describe(self, viewer=None): return _("%(user)s retagged %(post_desc)s") % { @@ -101,9 +110,13 @@ class RollbackAction(ActionProxy): def process_data(self, activate=None): previous = self.node.active_revision - self.node.activate_revision(self.user, activate, self) + self.node.activate_revision(self.user, activate) self.extra = "%d:%d" % (previous.revision, activate.revision) + def process_action(self): + self.node.last_edited = self + self.node.save() + def describe(self, viewer=None): revisions = [NodeRevision.objects.get(node=self.node, revision=int(n)) for n in self.extra.split(':')] @@ -121,18 +134,62 @@ class CloseAction(ActionProxy): verb = _("closed") def process_action(self): - self.node.extra_action = self self.node.marked = True - self.node.save() + self.node.nstate.closed = self + self.node.last_edited = self + self.node.update_last_activity(self.user, save=True) def cancel_action(self): - self.node.extra_action = None self.node.marked = False - self.node.save() + self.node.nstate.closed = None + self.node.update_last_activity(self.user, save=True) def describe(self, viewer=None): return _("%(user)s closed %(post_desc)s: %(reason)s") % { 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)), 'post_desc': self.describe_node(viewer, self.node), 'reason': self.extra - } \ No newline at end of file + } + +class AnswerToCommentAction(ActionProxy): + verb = _("converted") + + def process_data(self, new_parent=None): + self.node.parent = new_parent + self.node.node_type = "comment" + + for comment in self.node.comments.all(): + comment.parent = new_parent + comment.save() + + self.node.last_edited = self + self.node.update_last_activity(self.user, save=True) + try: + self.node.abs_parent.reset_answer_count_cache() + except AttributeError: + pass + + def describe(self, viewer=None): + return _("%(user)s converted an answer to %(question)s into a comment") % { + 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)), + 'question': self.describe_node(viewer, self.node.abs_parent), + } + +class WikifyAction(ActionProxy): + verb = _("wikified") + + def process_action(self): + self.node.nstate.wiki = self + self.node.last_edited = self + self.node.update_last_activity(self.user, save=True) + + def cancel_action(self): + self.node.nstate.wiki = None + self.node.update_last_activity(self.user, save=True) + + def describe(self, viewer=None): + return _("%(user)s marked %(node)s as community wiki.") % { + 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)), + 'node': self.describe_node(viewer, self.node), + } +