Exemplo n.º 1
0
def AGenerateCredentials():
    #POST/PUT parameters

    results = [{'label':'/VShowEvent', 'msg':[ur'Credenciales exitosamente generadas']}, {'label':'/VShowEvent', 'msg':[ur'Error al generar credenciales']}, ]
    eventid = request.args.get('eventId')

    if eventid is None:
        res = results[1]
    else:
        event = Event.get(eventid)
        user  = session.get('actor')
        if user is None:
            user = "******"
        pdf = create_pdf(render_template('credentials.html', event=event, user=user))
        
        if pdf is None:
            res = results[1]
        else:
            res = results[0]
            res['credentials'] = pdf

    if "actor" in res:
        if res['actor'] is None:
            session.pop("actor", None)
        else:
            session['actor'] = res['actor']
    return json.dumps(res)
Exemplo n.º 2
0
def AReserveEvent():

    eventid = request.args.get('eventId')
    if eventid is None:
        res = {'label':'/VShowEvent', 'msg':[ur'Error al reservar evento']}
    else:
        user = session.get('actor')
        if user is None:
            user = "******"

        event      = Event.get(eventid)
        assistance = Assistance.get(user, event.eventid)
        
        if assistance is None and event.update({ 'n_participants' : event.n_participants - 1 }):
            assistance = Assistance(user, event.eventid)
            if assistance.save():
                res = {'label':'/VShowEvent', 'msg':[ur'Evento reservado exitosamente']}
            else:
                res = {'label':'/VShowEvent', 'msg':[ur'Error al reservar evento']}
        else:
            res = {'label':'/VShowEvent', 'msg':[ur'Error al reservar evento']}


    res['reserved'] = 1
    #Action code ends here
    if "actor" in res:
        if res['actor'] is None:
            session.pop("actor", None)
        else:
            session['actor'] = res['actor']

    return json.dumps(res)
Exemplo n.º 3
0
def ADeleteEvent():
    #POST/PUT parameters
    eventid = request.args.get('eventId')

    event = Event.get(eventid)

    results = [
        {
            'label': '/VListEvents',
            'msg': [ur'Evento eliminado exitosamente']
        },
        {
            'label': '/VListEvents',
            'msg': [ur'Error al eliminar evento']
        },
    ]

    if event is not None and event.delete():
        res = results[0]
    else:
        res = results[1]
    #Action code goes here, res should be a list with a label and a message

    #Action code ends here
    if "actor" in res:
        if res['actor'] is None:
            session.pop("actor", None)
        else:
            session['actor'] = res['actor']
    return json.dumps(res)
Exemplo n.º 4
0
def AReserveEvent():

    eventid = request.args.get('eventId')
    if eventid is None:
        res = {'label': '/VShowEvent', 'msg': [ur'Error al reservar evento']}
    else:
        user = session.get('actor')
        if user is None:
            user = "******"

        event = Event.get(eventid)
        assistance = Assistance.get(user, event.eventid)

        if assistance is None and event.update(
            {'n_participants': event.n_participants - 1}):
            assistance = Assistance(user, event.eventid)
            if assistance.save():
                res = {
                    'label': '/VShowEvent',
                    'msg': [ur'Evento reservado exitosamente']
                }
            else:
                res = {
                    'label': '/VShowEvent',
                    'msg': [ur'Error al reservar evento']
                }
        else:
            res = {
                'label': '/VShowEvent',
                'msg': [ur'Error al reservar evento']
            }

    res['reserved'] = 1
    #Action code ends here
    if "actor" in res:
        if res['actor'] is None:
            session.pop("actor", None)
        else:
            session['actor'] = res['actor']

    return json.dumps(res)
Exemplo n.º 5
0
def VShowEvent():

    eventid = request.args.get('eventId')

    res = {}
    if eventid is not None:
        res['event'] = Event.get(eventid).__dict__

    if "actor" in session:
        res['actor'] = session['actor']
        assistance   = Assistance.get(res['actor'], eventid)
        if assistance is None:
            res['reserved'] = 0
        else:
            res['reserved'] = 1
            res['assisted'] = assistance.assisted
    #Action code goes here, res should be a JSON structure

    print res

    #Action code ends here
    return json.dumps(res)
Exemplo n.º 6
0
def ADeleteEvent():
    #POST/PUT parameters
    eventid = request.args.get('eventId')

    event = Event.get(eventid)

    results = [{'label':'/VListEvents', 'msg':[ur'Evento eliminado exitosamente']}, {'label':'/VListEvents', 'msg':[ur'Error al eliminar evento']}, ]

    if event is not None and event.delete():
        res = results[0]
    else:
        res = results[1]
    #Action code goes here, res should be a list with a label and a message


    #Action code ends here
    if "actor" in res:
        if res['actor'] is None:
            session.pop("actor", None)
        else:
            session['actor'] = res['actor']
    return json.dumps(res)
Exemplo n.º 7
0
def VShowEvent():

    eventid = request.args.get('eventId')

    res = {}
    if eventid is not None:
        res['event'] = Event.get(eventid).__dict__

    if "actor" in session:
        res['actor'] = session['actor']
        assistance = Assistance.get(res['actor'], eventid)
        if assistance is None:
            res['reserved'] = 0
        else:
            res['reserved'] = 1
            res['assisted'] = assistance.assisted
    #Action code goes here, res should be a JSON structure

    print res

    #Action code ends here
    return json.dumps(res)
Exemplo n.º 8
0
def AGenerateCredentials():
    #POST/PUT parameters

    results = [
        {
            'label': '/VShowEvent',
            'msg': [ur'Credenciales exitosamente generadas']
        },
        {
            'label': '/VShowEvent',
            'msg': [ur'Error al generar credenciales']
        },
    ]
    eventid = request.args.get('eventId')

    if eventid is None:
        res = results[1]
    else:
        event = Event.get(eventid)
        user = session.get('actor')
        if user is None:
            user = "******"
        pdf = create_pdf(
            render_template('credentials.html', event=event, user=user))

        if pdf is None:
            res = results[1]
        else:
            res = results[0]
            res['credentials'] = pdf

    if "actor" in res:
        if res['actor'] is None:
            session.pop("actor", None)
        else:
            session['actor'] = res['actor']
    return json.dumps(res)