<commit_before>from flask import Blueprint, redirect, render_template, url_for, request, \
    jsonify, abort
from flask.ext.login import current_user

from math import ceil

from viaduct import db
from viaduct.models import Nominee, Nomination, Vote
from viaduct.api.group import GroupPermissionAPI

blueprint = Blueprint('elections', __name__, url_prefix='/verkiezing')


@blueprint.route('/', methods=['GET'])
def main():
    return redirect(url_for('elections.nominate'))


@blueprint.route('/nomineren/', methods=['GET'])
def nominate():
    if current_user is None or not current_user.has_payed:
        return abort(403)

    nominated_ids = [n.nominee.id for n in current_user.nominations.all()]

    nominees = Nominee.query.filter(Nominee.valid == True)\
        .filter(db.not_(Nominee.id.in_(nominated_ids)))\
        .order_by(Nominee.name).all()  # noqa

    return render_template('elections/nominate.htm',
                           title='Docent van het jaar IW/Nomineren',
                           nominations=current_user.nominations,
                           data={'nominees': nominees,
                                 'nominate_url': url_for('elections.'
                                                         'submit_nomination'),
                                 'remove_url': url_for('elections.'
                                                       'remove_nomination')})


@blueprint.route('/nomineren/', methods=['POST'])
def submit_nomination():
    if current_user is None:
        return jsonify(error='Je moet ingelogd zijn om een docent te '
                       'nomineren'), 500
    if not current_user.has_payed:
        return jsonify(error='Je moet betaald lid zijn om een docent te '
                       'nomineren'), 500

    nominee_id = request.form.get('id')

    if nominee_id is not None:
        nominee = Nominee.query.get(nominee_id)
    else:
        nominee = Nominee(request.form.get('name'))<commit_msg>Also display non-validated nominees<commit_after>from flask import Blueprint, redirect, render_template, url_for, request, \
    jsonify, abort
from flask.ext.login import current_user

from math import ceil

from viaduct import db
from viaduct.models import Nominee, Nomination, Vote
from viaduct.api.group import GroupPermissionAPI

blueprint = Blueprint('elections', __name__, url_prefix='/verkiezing')


@blueprint.route('/', methods=['GET'])
def main():
    return redirect(url_for('elections.nominate'))


@blueprint.route('/nomineren/', methods=['GET'])
def nominate():
    if current_user is None or not current_user.has_payed:
        return abort(403)

    nominated_ids = [n.nominee.id for n in current_user.nominations.all()]

    nominees = Nominee.query\
        .filter(db.or_(Nominee.valid == True, Nominee.valid == None))\
        .filter(db.not_(Nominee.id.in_(nominated_ids)))\
        .order_by(Nominee.name).all()  # noqa
    print(nominees)

    return render_template('elections/nominate.htm',
                           title='Docent van het jaar IW/Nomineren',
                           nominations=current_user.nominations,
                           data={'nominees': nominees,
                                 'nominate_url': url_for('elections.'
                                                         'submit_nomination'),
                                 'remove_url': url_for('elections.'
                                                       'remove_nomination')})


@blueprint.route('/nomineren/', methods=['POST'])
def submit_nomination():
    if current_user is None:
        return jsonify(error='Je moet ingelogd zijn om een docent te '
                       'nomineren'), 500
    if not current_user.has_payed:
        return jsonify(error='Je moet betaald lid zijn om een docent te '
                       'nomineren'), 500

    nominee_id = request.form.get('id')

    if nominee_id is not None:
        nominee = Nominee.query.get(nominee_id)
    else:
        nominee = Nominee(request.form.get('name'))
{'fraction_non_alphanumeric': 0.10773824334411546, 'fraction_numerical': 0.004478726051256532, 'mean_word_length': 2.2550607287449393, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4121340', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1128, 'n_words': 264}