X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/aedb39383100b0ae2613c2f3beee6d397cd560d4..2cc0aa8a5d5c3b84c59598092c289d39b0cc4d3c:/forum/actions/meta.py diff --git a/forum/actions/meta.py b/forum/actions/meta.py index 1862cb3..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) } @@ -183,9 +191,9 @@ class DeleteAction(ActionProxy): 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):