Пример #1
0
    def generate_human_readable_format(events, reading_user):
        # get vars
        assert len(
            events
        ) == 1, "combining ProposalLifeCycleEvents not (yet) supported"
        proposal = events[0].proposal.cast()
        new_voting_stage = events[0].new_voting_stage

        # prepare strings
        proposal_str = add_owner(proposal, reading_user)
        url = url_to(proposal)
        creator_str = unicode(
            proposal.creator) if proposal.creator != None else u'Someone'

        # return full combination
        if new_voting_stage == 'DISCUSSION':
            return u"{} made a new proposal: {}".format(
                creator_str, proposal.title), url

        elif new_voting_stage == 'VOTING':
            return u"Voting started for {}".format(proposal_str), url

        elif new_voting_stage == 'APPROVED':
            return u"{} was approved".format(proposal_str), url

        elif new_voting_stage == 'REJECTED':
            return u"{} was rejected".format(proposal_str), url

        elif new_voting_stage == 'EXPIRED':
            return u"{} expired".format(proposal_str), url

        else:
            raise NotImplementedError("Unknown voting stage " +
                                      new_voting_stage)
Пример #2
0
    def generate_human_readable_format(events, reading_user):
        # get vars
        assert len(events) == 1, "combining ProposalLifeCycleEvents not (yet) supported"
        proposal = events[0].proposal.cast()
        new_voting_stage = events[0].new_voting_stage

        # prepare strings
        proposal_str = add_owner(proposal, reading_user)
        url = url_to(proposal)
        creator_str = unicode(proposal.creator) if proposal.creator != None else u"Someone"

        # return full combination
        if new_voting_stage == "DISCUSSION":
            return u"{} made a new proposal: {}".format(creator_str, proposal.title), url

        elif new_voting_stage == "VOTING":
            return u"Voting started for {}".format(proposal_str), url

        elif new_voting_stage == "APPROVED":
            return u"{} was approved".format(proposal_str), url

        elif new_voting_stage == "REJECTED":
            return u"{} was rejected".format(proposal_str), url

        elif new_voting_stage == "EXPIRED":
            return u"{} expired".format(proposal_str), url

        else:
            raise NotImplementedError("Unknown voting stage " + new_voting_stage)
Пример #3
0
    def generate_human_readable_format(events, reading_user):
        # get vars
        origin_post = events[0].origin_post.cast()
        users = userjoin(e.reaction_post.creator for e in events)
        origin_post_str = add_owner(origin_post, reading_user)
        link_target_post = events[0].reaction_post.cast() if len(events) == 1 else origin_post

        # return description + url
        return u"{} reacted to {}".format(users, origin_post_str), url_to(link_target_post)
Пример #4
0
    def generate_human_readable_format(events, reading_user):
        # get vars
        origin_post = events[0].origin_post.cast()
        users = userjoin(e.reaction_post.creator for e in events)
        origin_post_str = add_owner(origin_post, reading_user)
        link_target_post = events[0].reaction_post.cast() if len(
            events) == 1 else origin_post

        # return description + url
        return u"{} reacted to {}".format(
            users, origin_post_str), url_to(link_target_post)
Пример #5
0
    def generate_human_readable_format(events, reading_user):
        # get vars
        post = events[0].updownvote.post.cast()
        post_str = add_owner(post, reading_user)
        users = userjoin(e.updownvote.user for e in events)
        url = url_to(post)

        # get net increase / decrease in score
        score_diff = sum(e.updownvote.value for e in events)

        # return full combination
        if isinstance(post, Proposal):
            return u"{} got {} endorsement{} by {}".format(post_str, score_diff, pluralize(score_diff), users), url
        elif score_diff >= 0:
            return u"{} got {} upvote{}".format(post_str, score_diff, pluralize(score_diff)), url
        else:
            score_diff = abs(score_diff)
            return u"{} got {} downvote{}".format(post_str, score_diff, pluralize(score_diff)), url
Пример #6
0
    def generate_human_readable_format(events, reading_user):
        # get vars
        post = events[0].updownvote.post.cast()
        post_str = add_owner(post, reading_user)
        users = userjoin(e.updownvote.user for e in events)
        url = url_to(post)

        # get net increase / decrease in score
        score_diff = sum(e.updownvote.value for e in events)

        # return full combination
        if isinstance(post, Proposal):
            return u"{} got {} endorsement{} by {}".format(
                post_str, score_diff, pluralize(score_diff), users), url
        elif score_diff >= 0:
            return u"{} got {} upvote{}".format(post_str, score_diff,
                                                pluralize(score_diff)), url
        else:
            score_diff = abs(score_diff)
            return u"{} got {} downvote{}".format(post_str, score_diff,
                                                  pluralize(score_diff)), url