def index(request, conversation): statistics = conversation.statistics() votes = get_raw_votes(conversation) comments = comments_table(conversation, votes) participants = participants_table(conversation, votes) clusters = proxy_seq( conversation.clusters.all(), all_votes=votes, comment_table=cluster_comments_table, size=lambda x: x.users.count(), ) # Change agree and disagree comments to add up to 100% with skipped remaining = 100 - comments['skipped'] comments['agree'] = 0.01 * comments['agree'] * remaining comments['disagree'] = 0.01 * comments['disagree'] * remaining # Change agree and disagree participants to add up to 100% with skipped remaining = 100 - participants['skipped'] participants['agree'] = 0.01 * participants['agree'] * remaining participants['disagree'] = 0.01 * participants['disagree'] * remaining response = { 'page_title': _('Report'), 'content_title': hyperlink(conversation), 'conversation': conversation, 'statistics': statistics, 'vote_data': map_to_html_table(statistics['votes']), 'comment_data': map_to_html_table(statistics['comments']), 'comments_table': df_to_table(comments), 'participants_table': df_to_table(participants), 'clusters': clusters, } return response
def index(conversation): statistics = conversation.statistics() votes = get_raw_votes(conversation) math = VoteStats(votes) return { 'title': _('Report'), 'content_title': hyperlink(conversation), 'conversation': conversation, 'statistics': statistics, 'vote_data': map_to_table(statistics['votes']), 'comment_data': map_to_table(statistics['comments']), 'comments_table': df_to_table(math.comments(pc=True)), 'participants_table': df_to_table(math.users(pc=True)), }
def index(request, conversation): statistics = conversation.statistics() votes = get_raw_votes(conversation) comments = comments_table(conversation, votes) participants = participants_table(conversation, votes) clusters = proxy_seq( conversation.clusters.all(), all_votes=votes, comment_table=cluster_comments_table, size=lambda x: x.users.count(), ) # Change agree and disagree comments to add up to 100% with skipped remaining = 100 - comments["skipped"] comments["agree"] = 0.01 * comments["agree"] * remaining comments["disagree"] = 0.01 * comments["disagree"] * remaining # Change agree and disagree participants to add up to 100% with skipped remaining = 100 - participants["skipped"] participants["agree"] = 0.01 * participants["agree"] * remaining participants["disagree"] = 0.01 * participants["disagree"] * remaining if request.GET.get('action') == 'generate_csv': response = generate_csv(conversation, statistics, votes, comments, participants, clusters) elif request.GET.get('action') == 'generate_json': response = generate_json(conversation, statistics, votes, comments, participants, clusters) elif request.GET.get('action') == 'generate_msgpack': response = generate_msgpack(conversation, statistics, votes, comments, participants, clusters) else: response = { 'page_title': _('Report'), 'content_title': hyperlink(conversation), 'conversation': conversation, 'statistics': statistics, 'vote_data': map_to_html_table(statistics['votes']), 'comment_data': map_to_html_table(statistics['comments']), 'comments_table': df_to_table(comments), 'participants_table': df_to_table(participants), 'clusters': clusters, } return response
def menu_item(item): # add role="menuitem" in the future? if hasattr(item, "__html__"): return item else: return hyperlink(item)
def menu_item(item): if hasattr(item, "__html__"): return item else: return hyperlink(item)
def test_hyperlink_not_supported(self): with pytest.raises(TypeError): hyperlink(hyperlink)
def test_hyperlink_examples(self): link = '<a href="bar">foo</a>' assert hyperlink('foo<#>').render() == '<a href="#">foo</a>' assert hyperlink('foo', 'bar').render() == link assert hyperlink({'href': 'bar', 'content': 'foo'}).render() == link assert hyperlink('foo', **{'href': 'bar'}).render() == link