X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/23e2bb68c4bc35f1b9f4280630b2d0284e9ae2a8..2cc0aa8a5d5c3b84c59598092c289d39b0cc4d3c:/forum/actions/meta.py diff --git a/forum/actions/meta.py b/forum/actions/meta.py index f5d1394..ccdaa75 100644 --- a/forum/actions/meta.py +++ b/forum/actions/meta.py @@ -27,6 +27,14 @@ class VoteAction(ActionProxy): except: return None + @classmethod + def get_action_for(cls, user, node): + try: + vote = Vote.objects.get(user=user, node=node) + return vote.action + except: + return None + def describe_vote(self, vote_desc, viewer=None): return _("%(user)s %(vote_desc)s %(post_desc)s") % { 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)), @@ -94,7 +102,7 @@ class FlagAction(ActionProxy): if self.node.flag_count == int(settings.FLAG_COUNT_TO_DELETE_POST): self.repute(self.node.author, -int(settings.REP_LOST_BY_FLAGGED_5_TIMES)) - if not self.node.deleted: + if not self.node.nis.deleted: DeleteAction(node=self.node, user=self.user, extra="BYFLAGGED").save() def cancel_action(self): @@ -128,14 +136,14 @@ class AcceptAnswerAction(ActionProxy): self.node.parent.extra_ref = self.node self.node.parent.save() self.node.marked = True - self.node.extra_action = self + self.node.nstate.accepted = self self.node.save() def cancel_action(self): self.node.parent.extra_ref = None self.node.parent.save() self.node.marked = False - self.node.extra_action = None + self.node.nstate.accepted = None self.node.save() def describe(self, viewer=None): @@ -149,7 +157,7 @@ class AcceptAnswerAction(ActionProxy): return _("%(user)s accepted %(answerer)s answer on %(asker)s question %(question)s") % { 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)), - 'answerer': self.hyperlink(answer.author.get_profile_url(), self.friendly_username(viewer, answer.author)), + 'answerer': self.hyperlink(answer.author.get_profile_url(), self.friendly_ownername(viewer, answer.author)), 'asker': asker, 'question': self.hyperlink(question.get_absolute_url(), question.title) } @@ -171,23 +179,21 @@ class FavoriteAction(ActionProxy): class DeleteAction(ActionProxy): def process_action(self): - self.node.deleted = self - self.node.save() + self.node.mark_deleted(self) if self.node.node_type == "answer": self.node.question.reset_answer_count_cache() def cancel_action(self): - self.node.deleted = None - self.node.save() + self.node.mark_deleted(None) if self.node.node_type == "answer": self.node.question.reset_answer_count_cache() def describe(self, viewer=None): - return _("%(user)s deleted %(post_desc)s: %(reason)s") % { + return _("%(user)s deleted %(post_desc)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.reason(), + 'post_desc': self.describe_node(viewer, self.node) } def reason(self): @@ -196,6 +202,9 @@ class DeleteAction(ActionProxy): else: return _("flagged by multiple users: ") + "; ".join([f.extra for f in FlagAction.objects.filter(node=self.node)]) +class UnknownAction(ActionProxy): + pass + class QuestionViewAction(DummyActionProxy): def __init__(self, node, user, ip=None):