コード例 #1
0
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
コード例 #2
0
def conversations_with_moderation(user, qs=None):
    perm = 'ej.can_moderate_conversation'
    kwargs = {
        'can_moderate': lambda x: user.has_perm(perm, x)
    }
    if qs is None:
        qs = Conversation.objects.filter(is_promoted=True)
    return proxy_seq(qs, user=user, **kwargs)
コード例 #3
0
def index(conversation):
    clusters = proxy_seq(
        conversation.clusters.all(),
        info=cluster_info,
    )
    return {
        'content_title': _('Clusters'),
        'conversation': conversation,
        'clusters': clusters,
    }
コード例 #4
0
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