Example #1
0
    def generate_html_string_for(events, reading_user):
        # get vars
        assert len(
            events
        ) == 1, "combining ProposalLifeCycleEvents not (yet) supported"
        proposal = events[0].proposal
        new_voting_stage = events[0].new_voting_stage

        # prepare strings
        link_with_owner = link_and_add_owner(proposal, reading_user)
        creator_str = unicode(
            proposal.creator) if proposal.creator != None else u'Someone'

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

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

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

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

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

        else:
            raise NotImplementedError("Unknown voting stage " +
                                      new_voting_stage)
Example #2
0
    def generate_html_string_for(events, reading_user):
        # get vars
        assert len(events) == 1, "combining ProposalLifeCycleEvents not (yet) supported"
        proposal = events[0].proposal
        new_voting_stage = events[0].new_voting_stage

        # prepare strings
        link_with_owner = link_and_add_owner(proposal, reading_user)
        creator_str = unicode(proposal.creator) if proposal.creator != None else u"Someone"

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

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

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

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

        elif new_voting_stage == "EXPIRED":
            return u"{} expired".format(link_with_owner)

        else:
            raise NotImplementedError("Unknown voting stage " + new_voting_stage)
Example #3
0
    def generate_html_string_for(events, reading_user):
        # get vars
        origin_post = events[0].origin_post.cast()
        users = userjoin(e.reaction_post.creator for e in events)

        # get link
        target_post = events[0].reaction_post.cast() if len(events) == 1 else origin_post
        link = link_and_add_owner(displayed_post=origin_post, reading_user=reading_user, target_post=target_post)

        # return full combination
        return u"{} reacted to {}".format(users, link)
Example #4
0
    def generate_html_string_for(events, reading_user):
        # get vars
        origin_post = events[0].origin_post.cast()
        users = userjoin(e.reaction_post.creator for e in events)

        # get link
        target_post = events[0].reaction_post.cast() if len(
            events) == 1 else origin_post
        link = link_and_add_owner(displayed_post=origin_post,
                                  reading_user=reading_user,
                                  target_post=target_post)

        # return full combination
        return u"{} reacted to {}".format(users, link)
Example #5
0
    def generate_html_string_for(events, reading_user):
        # get vars
        post = events[0].updownvote.post.cast()
        link_with_owner = link_and_add_owner(post, reading_user)
        users = userjoin(e.updownvote.user for e in events)

        # 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(link_with_owner, score_diff, pluralize(score_diff), users)
        elif score_diff >= 0:
            return u"{} got {} upvote{}".format(link_with_owner, score_diff, pluralize(score_diff))
        else:
            score_diff = abs(score_diff)
            return u"{} got {} downvote{}".format(link_with_owner, score_diff, pluralize(score_diff))
Example #6
0
    def generate_html_string_for(events, reading_user):
        # get vars
        post = events[0].updownvote.post.cast()
        link_with_owner = link_and_add_owner(post, reading_user)
        users = userjoin(e.updownvote.user for e in events)

        # 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(
                link_with_owner, score_diff, pluralize(score_diff), users)
        elif score_diff >= 0:
            return u"{} got {} upvote{}".format(link_with_owner, score_diff,
                                                pluralize(score_diff))
        else:
            score_diff = abs(score_diff)
            return u"{} got {} downvote{}".format(link_with_owner, score_diff,
                                                  pluralize(score_diff))