Example #1
0
def admin_add_logros_screen():
    """ Screen for players' achievements administration and route for new achievement submision"""

    if request.method == 'POST':
        add_one(PUBLIC_DATABASE, 'logros', request)

    logros = get_items("logros", PUBLIC_DATABASE)
    atletas = get_items("atletas",
                        PUBLIC_DATABASE,
                        fields=['id', 'nombre', 'apellido'])
    options = {
        "atleta": atletas,
        "tipo":
        {element.get('tipo')
         for element in logros if element.get('tipo')},
        "nivel_torneo": {
            element.get('nivel_torneo')
            for element in logros if element.get('nivel_torneo')
        },
        "puesto":
        {element.get('puesto')
         for element in logros if element.get('puesto')},
        "categoria": {
            element.get('categoria')
            for element in logros if element.get('categoria')
        }
    }

    return render_template('admin_add_logros.html', options=options)
def admin_new_directiva_miembro_screen():
    """ Screen to add new trainer """
    _type = 'miembros_directiva'
    if request.method == 'POST':
        added = add_one(PUBLIC_DATABASE, _type, request)
        if not added:
            return jsonify({'message': 'Something went wrong'}), 500
        return '', 200

    return render_template('admin_persona.html', type='directiva')
Example #3
0
def admin_new_athlete_screen():
    """ Screen to add new player """

    _type = 'atletas'
    if request.method == 'POST':
        added = add_one(PUBLIC_DATABASE, _type, request)
        if not added:
            return jsonify({'message': 'Something went wrong'}), 500
        return '', 200

    return render_template('admin_persona.html', type=_type)
Example #4
0
def admin_new_achievement_screen(athlete_id):
    """ Screen to add new milestone """
    _type = 'hito'
    if request.method == 'POST':
        added = add_one(PUBLIC_DATABASE, _type, request)
        if not added:
            return jsonify({'message': 'Something went wrong'}), 500

    atleta = next(
        iter(
            get_items('atletas',
                      PUBLIC_DATABASE,
                      filters=[{
                          'field': 'id',
                          'values': [athlete_id]
                      }])))
    return render_template('admin_atleta_logro.html', atleta=atleta)