Example #1
0
def vote_all():
    if 'osm_token' not in session or config.STAGE != 'voting':
        return redirect(url_for('login'))
    uid = session['osm_uid']
    # Delete current votes to replace by with the new ones
    q = Vote.delete().where((Vote.user == uid) & (~Vote.preliminary))
    q.execute()
    for nom in config.NOMINATIONS:
        votes = request.form.getlist('vote_{}'.format(nom))
        for vote in votes:
            v = Vote()
            v.nominee = Nominee.get(Nominee.id == int(vote))
            v.user = uid
            v.preliminary = False
            v.save()
    flash(g.lang['thanksvoted'])
    return redirect(url_for('voting'))
Example #2
0
def vote_all():
    if 'osm_token' not in session or config.STAGE != 'voting':
        return redirect(url_for('login'))
    uid = session['osm_uid']
    # Delete current votes to replace by with the new ones
    q = Vote.delete().where((Vote.user == uid) & (~Vote.preliminary))
    q.execute()
    for nom in config.NOMINATIONS:
        votes = request.form.getlist('vote_{}'.format(nom))
        for vote in votes:
            v = Vote()
            v.nominee = Nominee.get(Nominee.id == int(vote))
            v.user = uid
            v.preliminary = False
            v.save()
    flash(g.lang['thanksvoted'])
    return redirect(url_for('voting'))
Example #3
0
def vote(nid):
    if 'osm_token' not in session or config.STAGE != 'voting':
        return redirect(url_for('login'))
    uid = session['osm_uid']
    n = Nominee.get(Nominee.id == nid)
    try:
        # Delete votes from the same category by this voter
        v = Vote.select().where((Vote.user == uid) & (~Vote.preliminary)).join(Nominee).where(
            Nominee.nomination == n.nomination).get()
        v.delete_instance()
    except Vote.DoesNotExist:
        pass
    v = Vote()
    v.nominee = n
    v.user = uid
    v.preliminary = False
    v.save()
    return redirect(url_for('voting'))
Example #4
0
def prevote(nid):
    if 'osm_token' not in session:
        return redirect(url_for('login'))
    uid = session['osm_uid']
    if config.STAGE != 'call' and not isteam(uid):
        return redirect(url_for('login'))
    n = Nominee.get(Nominee.id == nid)
    try:
        v = Vote.get((Vote.user == uid) & (Vote.nominee == n) & (Vote.preliminary))
        v.delete_instance()
    except Vote.DoesNotExist:
        if canvote(uid):
            v = Vote()
            v.nominee = n
            v.user = uid
            v.preliminary = True
            v.save()
    return redirect(url_for('edit_nominees'))
Example #5
0
def vote(nid):
    if 'osm_token' not in session or config.STAGE != 'voting':
        return redirect(url_for('login'))
    uid = session['osm_uid']
    n = Nominee.get(Nominee.id == nid)
    try:
        # Delete votes from the same category by this voter
        v = Vote.select().where((Vote.user == uid) & (~Vote.preliminary)).join(Nominee).where(
            Nominee.category == n.category).get()
        v.delete_instance()
    except Vote.DoesNotExist:
        pass
    v = Vote()
    v.nominee = n
    v.user = uid
    v.preliminary = False
    v.save()
    return redirect(url_for('voting'))
Example #6
0
def prevote(nid):
    if 'osm_token' not in session:
        return redirect(url_for('login'))
    uid = session['osm_uid']
    if config.STAGE != 'call' and not isteam(uid):
        return redirect(url_for('login'))
    n = Nominee.get(Nominee.id == nid)
    try:
        v = Vote.get((Vote.user == uid) & (Vote.nominee == n) & (Vote.preliminary))
        v.delete_instance()
    except Vote.DoesNotExist:
        if canvote(uid):
            v = Vote()
            v.nominee = n
            v.user = uid
            v.preliminary = True
            v.save()
    return redirect(url_for('edit_nominees'))
Example #7
0
def vote_all():
    if 'osm_token' not in session or config.STAGE != 'voting':
        return redirect(url_for('login'))
    uid = session['osm_uid']
    for nom in range(len(config.NOMINATIONS)):
        vote = request.form.get('vote{}'.format(nom), -1, type=int)
        if vote < 0:
            continue
        try:
            # Delete votes from the same category by this voter
            v = Vote.select().where((Vote.user == uid) & (~Vote.preliminary)).join(Nominee).where(
                Nominee.nomination == nom).get()
            v.delete_instance()
        except Vote.DoesNotExist:
            pass
        if vote > 0:
            v = Vote()
            v.nominee = Nominee.get(Nominee.id == vote)
            v.user = uid
            v.preliminary = False
            v.save()
    flash(g.lang['thanksvoted'])
    return redirect(url_for('voting'))
Example #8
0
def vote_all():
    if 'osm_token' not in session or config.STAGE != 'voting':
        return redirect(url_for('login'))
    uid = session['osm_uid']
    for nom in range(len(config.NOMINATIONS)):
        vote = request.form.get('vote{}'.format(nom), -1, type=int)
        if vote < 0:
            continue
        try:
            # Delete votes from the same category by this voter
            v = Vote.select().where((Vote.user == uid)
                                    & (~Vote.preliminary)).join(Nominee).where(
                                        Nominee.nomination == nom).get()
            v.delete_instance()
        except Vote.DoesNotExist:
            pass
        if vote > 0:
            v = Vote()
            v.nominee = Nominee.get(Nominee.id == vote)
            v.user = uid
            v.preliminary = False
            v.save()
    flash(g.lang['thanksvoted'])
    return redirect(url_for('voting'))