Esempio n. 1
0
def search(request, user_id):
    if request.method == 'GET':
        body = get_params(request)

        events = event_manager.search(body)

        return success({'events': events})
Esempio n. 2
0
def search_by_tag(request, user_id):
    if request.method == 'GET':
        body = get_params(request)

        req = require(body, ['tag_name'])
        if req:
            return error(req)
        events = event_manager.search_by_tag(body)
        return success({'events': events})
Esempio n. 3
0
def get_participant_by_event(request, user_id):
    if request.method == 'GET':
        body = get_params(request)

        req = require(body, ['last_time', 'event_id', 'limit'])
        if req:
            return error(req)

        participants = participant_manager.get_by_event(body)

        return success({'participants': participants})
Esempio n. 4
0
def get_like_by_event(request, user_id):
    if request.method == 'GET':
        body = get_params(request)

        req = require(body, ['last_time', 'event_id', 'limit'])
        if req:
            return error(req)

        likes = like_manager.get_by_event(body)

        return success({'likes': likes})
Esempio n. 5
0
def get_admin(request, admin_id):
    if request.method == 'GET':
        body = get_params(request)
        req = require(body, ['user_id'])
        if req:
            return error(req)

        user = user_manager.get(body)
        if not user:
            return error("can't find this event")

        return success({'user': user})
Esempio n. 6
0
def get_salt(request):
    if request.method == 'GET':
        body = get_params(request)

        req = require(body, ['user_name'])
        if req:
            return error(req)

        body['user_type'] = 'visitor'
        salt = user_manager.get_salt(body)

        return success({'salt': salt})
Esempio n. 7
0
def get_by_id(request, user_id):
    if request.method == 'GET':
        body = get_params(request)

        req = require(body, ['event_id'])
        if req:
            return error(req)

        event = event_manager.get(body)

        if not event:
            return error("can't find this event")

        return success({'event': event})
Esempio n. 8
0
def get_salt(request):
    if request.method == 'GET':
        body = get_params(request)

        req = require(body, ['user_name'])
        if req:
            return error(req)

        body['user_type'] = 'admin'
        salt = user_manager.get_salt(body)

        if not salt:
            return error('can not find this user')

        return success({'salt': salt})
Esempio n. 9
0
def refresh_token(request):
    if request.method == 'GET':
        body = get_params(request)

        req = require(body, ['access_token'])
        if req:
            return error(req)

        access_token = body['access_token']

        data_user = json.loads(
            json.dumps(
                jwt.decode(access_token,
                           Config.SECRET_KEY_VISITOR,
                           algorithms=['HS256'])))

        print(data_user)
        data_user['user_type'] = 'visitor'

        user = user_manager.verify(data_user)

        if not user:
            return error(Error.WRONG_USER_NAME_OR_PASSWORD)

        new_access_token = get_visitor_access_token({
            'id':
            user['id'],
            'user_name':
            user['user_name'],
            'password':
            user['password'],
            'expiration_date':
            (datetime.datetime.now() +
             datetime.timedelta(days=2)).strftime("%Y-%m-%d %H:%M:%S")
        })

        return success({'new_access_token': new_access_token})