Switch to unified view

a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
...
...
660
                          author_name=r.author_name,
660
                          author_name=r.author_name,
661
                          author_link=h.absurl(r.author_link))
661
                          author_link=h.absurl(r.author_link))
662
        return feed
662
        return feed
663
663
664
664
665
class VotableArtifact(object):
665
class VotableArtifact(MappedClass):
666
    """Voting support for the Artifact. Use as a mixin."""
666
    """Voting support for the Artifact. Use as a mixin."""
667
668
    class __mongometa__:
669
        session = artifact_orm_session
670
        name = 'vote'
671
667
    votes_up = FieldProperty(int, if_missing=0)
672
    votes_up = FieldProperty(int, if_missing=0)
668
    votes_down = FieldProperty(int, if_missing=0)
673
    votes_down = FieldProperty(int, if_missing=0)
669
    votes_up_users = FieldProperty([str])
674
    votes_up_users = FieldProperty([str], if_missing=list())
670
    votes_down_users = FieldProperty([str])
675
    votes_down_users = FieldProperty([str], if_missing=list())
671
676
672
    def vote_up(self, user):
677
    def vote_up(self, user):
673
        if not self.votes_up_users:
674
            self.votes_up_users = []
675
        if user.username in self.votes_up_users:
678
        if user.username in self.votes_up_users:
676
            return  # Can vote only once
679
            return  # Can vote only once
677
        if self.votes_down_users and user.username in self.votes_down_users:
680
        if user.username in self.votes_down_users:
678
            # Change vote negative
681
            # Change vote negative
679
            self.votes_down_users.remove(user.username)
682
            self.votes_down_users.remove(user.username)
680
            self.votes_down -= 1
683
            self.votes_down = self.votes_down - 1
681
        self.votes_up_users.append(user.username)
684
        self.votes_up_users.append(user.username)
682
        self.votes_up += 1
685
        self.votes_up += 1
683
686
684
    def vote_down(self, user):
687
    def vote_down(self, user):
685
        if not self.votes_down_users:
686
            self.votes_down_users = []
687
        if user.username in self.votes_down_users:
688
        if user.username in self.votes_down_users:
688
            return  # Can vote only once
689
            return  # Can vote only once
689
        if self.votes_up_users and user.username in self.votes_up_users:
690
        if user.username in self.votes_up_users:
690
            # Change vote to positive
691
            # Change vote to positive
691
            self.votes_up_users.remove(user.username)
692
            self.votes_up_users.remove(user.username)
692
            self.votes_up -= 1
693
            self.votes_up = self.votes_up - 1
693
        self.votes_down_users.append(user.username)
694
        self.votes_down_users.append(user.username)
694
        self.votes_down += 1
695
        self.votes_down += 1