Exemplo n.º 1
0
def batch_view(id):
    l.l('batch_view', uid=request.user.id, gid=id)
    group = l.get_group(id)
    if not group:
        abort(404)
    if request.user.email in group.author_emails:
        abort(404)
    raw_proposals = l.get_group_proposals(id)
    votes = l.get_group_votes(id)
    proposals = []
    for rp in raw_proposals:
        clean_prop = {'proposal': rp, 'discussion': l.get_discussion(rp.id)}
        voters = [v.display_name for v in votes if rp.id in v.accept]
        clean_prop['voters'] = ', '.join(voters)
        clean_prop['voters_count'] = len(voters)
        proposals.append(clean_prop)
    proposal_map = {x.id: x for x in raw_proposals}
    if group.locked:
        proposals.sort(key=lambda x: -x['voters_count'])
    else:
        random.shuffle(proposals)
    basics = {x['proposal'].id: x['proposal'].data['title'] for x in proposals}
    vote = l.get_batch_vote(id, request.user.id)
    msgs = l.get_batch_messages(id)
    l.mark_batch_read(id, request.user.id)
    return render_template('batch/batchgroup.html',
                           group=group,
                           proposals=proposals,
                           proposal_map=proposal_map,
                           basics=basics,
                           msgs=msgs,
                           all_votes=votes,
                           vote=vote._asdict() if vote else None)
Exemplo n.º 2
0
def batch_view(id):
    l.l('batch_view', uid=request.user.id, gid=id)
    group = l.get_group(id)
    if not group:
        abort(404)
    if request.user.email in group.author_emails:
        abort(404)
    raw_proposals = l.get_group_proposals(id)
    votes  = l.get_group_votes(id)
    proposals = []
    for rp in raw_proposals:
        clean_prop = {'proposal': rp, 'discussion': l.get_discussion(rp.id)}
        voters = [v.display_name for v in votes if rp.id in v.accept]
        clean_prop['voters'] = ', '.join(voters)
        clean_prop['voters_count'] = len(voters)
        proposals.append(clean_prop)
    proposal_map = {x.id:x for x in raw_proposals}
    if group.locked:
        proposals.sort(key=lambda x:-x['voters_count'])
    else:
        random.shuffle(proposals)
    basics = {x['proposal'].id:x['proposal'].title for x in proposals}
    vote = l.get_batch_vote(id, request.user.id)
    msgs = l.get_batch_messages(id)
    l.mark_batch_read(id, request.user.id)
    return render_template('batch/batchgroup.html', group=group,
                            proposals=proposals, proposal_map=proposal_map,
                            basics=basics, msgs=msgs,
                            all_votes=votes,
                            vote = vote._asdict() if vote else None)
Exemplo n.º 3
0
def batch_view(id):
    l.l('batch_view', uid=request.user.id, gid=id)
    group = l.get_group(id)
    if request.user.email in group.author_emails:
        abort(404)
    raw_proposals = l.get_group_proposals(id)
    proposals = [{'proposal':x, 'discussion':l.get_discussion(x.id)}
                    for x in raw_proposals]
    proposal_map = {x.id:x for x in raw_proposals}
    random.shuffle(proposals)
    basics = {x['proposal'].id:x['proposal'].title for x in proposals}
    vote = l.get_batch_vote(id, request.user.id)
    msgs = l.get_batch_messages(id)
    l.mark_batch_read(id, request.user.id)
    return render_template('batchgroup.html', group=group,
                            proposals=proposals, proposal_map=proposal_map,
                            basics=basics, msgs=msgs,
                            vote = vote._asdict() if vote else None)
Exemplo n.º 4
0
def batch_view(id):
    raw_proposals = l.get_group_proposals(id)
    proposals = [{"proposal": x, "discussion": l.get_discussion(x.id)} for x in raw_proposals]
    proposal_map = {x.id: x for x in raw_proposals}
    random.shuffle(proposals)
    basics = {x["proposal"].id: x["proposal"].title for x in proposals}
    vote = l.get_batch_vote(id, request.user.id)
    msgs = l.get_batch_messages(id)
    l.mark_batch_read(id, request.user.id)
    return render_template(
        "batchgroup.html",
        group=l.get_group(id),
        proposals=proposals,
        proposal_map=proposal_map,
        basics=basics,
        msgs=msgs,
        vote=vote._asdict() if vote else None,
    )