Example #1
0
File: admin.py Project: njl/progcom
def add_batchgroup():
    name = request.values.get('name')
    id = l.create_group(request.values.get('name'), None)
    l.l('add_batchgroup', uid=request.user.id, name = name, id=id)
    if request.is_xhr:
        return jsonify(groups=l.raw_list_groups())
    return redirect(url_for('admin.list_batchgroups'))
Example #2
0
def screening(id):
    l.l('screening_view', uid=request.user.id, id=id)
    proposal = l.get_proposal(id)
    if not proposal or proposal.withdrawn:
        abort(404)

    if request.user.email in (x.email.lower() for x in proposal.authors):
        abort(404)

    unread = l.is_unread(request.user.id, id)
    discussion = l.get_discussion(id)

    standards = l.get_standards()

    existing_vote = l.get_user_vote(request.user.id, id)
    votes = l.get_votes(id)

    my_votes = l.get_my_votes(request.user.id)
    percent = l.get_vote_percentage(request.user.email, request.user.id)

    return render_template('screening_proposal.html',
                           proposal=proposal,
                           votes=votes,
                           discussion=discussion,
                           standards=standards,
                           existing_vote=existing_vote,
                           unread=unread,
                           percent=percent)
Example #3
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)
Example #4
0
def set_status(id):
    accepted = request.values.get('accepted', None)
    if accepted != None:
        accepted = (accepted == 'true')
    l.l('set_accepted_status', id=id, uid=request.user.id, accepted=accepted)
    l.change_acceptance(id, accepted)
    return jsonify(accepted=accepted)
Example #5
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)
Example #6
0
def screening(id):
    l.l('screening_view', uid=request.user.id, id=id)
    proposal = l.get_proposal(id)
    if not proposal or proposal.withdrawn:
        abort(404)

    if request.user.email in (x.email.lower() for x in proposal.authors):
        abort(404)

    unread = l.is_unread(request.user.id, id)
    discussion = l.get_discussion(id)

    standards = l.get_standards()
    bookmarked = l.has_bookmark(request.user.id, id)

    existing_vote = l.get_user_vote(request.user.id, id)
    votes = l.get_votes(id)

    my_votes = l.get_my_votes(request.user.id)
    percent = l.get_vote_percentage(request.user.email, request.user.id)

    return render_template('screening_proposal.html', proposal=proposal,
                            votes=votes, discussion=discussion,
                            standards=standards,
                            bookmarked=bookmarked,
                            existing_vote=existing_vote,
                            unread=unread,
                            percent=percent)
Example #7
0
File: admin.py Project: njl/progcom
def set_status(id):
    accepted = request.values.get('accepted', None)
    if accepted != None:
        accepted = (accepted == 'true')
    l.l('set_accepted_status', id=id, uid=request.user.id, accepted=accepted)
    l.change_acceptance(id, accepted)
    return jsonify(accepted=accepted)
Example #8
0
File: admin.py Project: njl/progcom
def rename_batch_group(id):
    name = request.values.get('name')
    l.l('rename_batch_group', uid=request.user.id, name=name, gid=id)
    l.rename_batch_group(id,name)
    if request.is_xhr:
        return jsonify(groups=l.raw_list_groups())
    return redirect(url_for('admin.list_batchgroups'))
Example #9
0
def rename_batch_group(id):
    name = request.values.get('name')
    l.l('rename_batch_group', uid=request.user.id, name=name, gid=id)
    l.rename_batch_group(id, name)
    if request.is_xhr:
        return jsonify(groups=l.raw_list_groups())
    return redirect(url_for('admin.list_batchgroups'))
Example #10
0
def add_batchgroup():
    name = request.values.get('name')
    id = l.create_group(request.values.get('name'), None)
    l.l('add_batchgroup', uid=request.user.id, name=name, id=id)
    if request.is_xhr:
        return jsonify(groups=l.raw_list_groups())
    return redirect(url_for('admin.list_batchgroups'))
Example #11
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)
Example #12
0
File: admin.py Project: njl/progcom
def assign_proposal():
    gid = request.values.get('gid', None)
    pid = request.values.get('pid')
    l.l('assign_proposal', uid=request.user.id, gid=gid, pid=pid)
    l.assign_proposal(gid, pid)
    return jsonify(status='ok')
Example #13
0
def lock_batch_group(id):
    lock = request.values.get('lock', None) == 't'
    l.l('lock_batch_group', user=request.user.id, lock=lock, id=id)
    l.toggle_lock_batch(id, lock)
    return jsonify(result='ok', status=lock)
Example #14
0
File: admin.py Project: njl/progcom
def list_batchgroups():
    l.l('list_batchgroups', user=request.user.id)
    return render_template('admin/batchgroups.html',
                            groups=l.raw_list_groups())
Example #15
0
File: admin.py Project: njl/progcom
def lock_batch_group(id):
    lock = request.values.get('lock', None) == 't'
    l.l('lock_batch_group', user=request.user.id, lock=lock, id=id)
    l.toggle_lock_batch(id, lock)
    return jsonify(result='ok', status=lock)
Example #16
0
def assign_proposal():
    gid = request.values.get('gid', None)
    pid = request.values.get('pid')
    l.l('assign_proposal', uid=request.user.id, gid=gid, pid=pid)
    l.assign_proposal(gid, pid)
    return jsonify(status='ok')
Example #17
0
def list_batchgroups():
    l.l('list_batchgroups', user=request.user.id)
    return render_template('admin/batchgroups.html',
                           groups=l.raw_list_groups())