Esempio n. 1
0
def get_logs(request):
    user = header_checker(request)
    if user and user.position > 1:
        all_log = logs.Log.find_logs()
        return response(response_code['OK'],
                        serializers.serialize('json', all_log))
    return response(response_code['BAD_REQUEST'])
Esempio n. 2
0
def get_all_info(request):
    user = header_checker(request)
    if user and (user.position > 1):
        users = persons.Person.find_all_person_info()
        return response(response_code['OK'],
                        serializers.serialize('json', users))
    else:
        return response(response_code['BAD_REQUEST'])
Esempio n. 3
0
def remove_menu_item(request):
    user = header_checker(request)
    if user and user.position > 1:
        req = request.POST
        item_id = req.get('item_id')
        menus.Menu.remove_item(item_id)
        return response(response_code['OK'])
    return response(response_code['BAD_REQUEST'])
Esempio n. 4
0
def remove_other(request):
    user = header_checker(request)
    if user and user.position > 1:
        req = request.POST
        worker_id = req.get('worker_id')
        other = persons.Person.find_by_worker_id(worker_id)
        other.delete()
        return response(response_code['OK'])
    return response(response_code['BAD_REQUEST'])
Esempio n. 5
0
def create(request):
    user = header_checker(request)
    if user:
        new_order = Order.objects.create()
        new_order.menu_list = '([],)'
        new_order.table_id = (-1, )
        new_order.status = "('ing',)"
        new_order.save()
        return response(response_code['OK'], new_order.order_id)
    return response(response_code['BAD_REQUEST'])
Esempio n. 6
0
def change_password(request):
    user = header_checker(request)
    if user:
        req = request.POST
        old_password = req.get('old_password')
        new_password = req.get('new_password')
        if user.password == old_password:
            user.password = new_password
            user.save()
            return response(response_code['OK'])
    return response(response_code['BAD_REQUEST'])
Esempio n. 7
0
def get_self_info(request):
    user = header_checker(request)
    if user:
        return response(
            response_code['OK'], {
                'person_id': user.person_id,
                'worker_id': user.worker_id,
                'name': user.name,
                'phone': user.phone,
                'address': user.address
            })
    return response(response_code['BAD_REQUEST'])
Esempio n. 8
0
def finish_order(request):
    user = header_checker(request)
    if user:
        req = request.POST
        order_id = req.get('order_id')
        order = Order.find_item(order_id)
        status = req.get('status')
        order.status = status,
        order.save()
        logs.Log.create_order(order_id, user.worker_id, user.name)
        return response(response_code['OK'])
    return response(response_code['BAD_REQUEST'])
Esempio n. 9
0
def set_self_info(request):
    user = header_checker(request)
    if user:
        req = request.POST
        name = req.get('name')
        address = req.get('address')
        phone = req.get('phone')
        user.name = name
        user.address = address
        user.phone = phone
        user.save()
        return response(response_code['OK'])
    return response(response_code['BAD_REQUEST'])
Esempio n. 10
0
def modify_order(request):
    user = header_checker(request)
    if user:
        req = request.POST
        order_id = req.get('order_id')
        table_id = req.get('table_id')
        menu_list = req.get('menu_list')
        status = req.get('status')
        order = Order.find_item(order_id)
        order.table_id = table_id,
        order.status = status,
        order.person_id = user.person_id
        order.menu_list = menu_list,
        order.save()
        return response(response_code['OK'])
    return response(response_code['BAD_REQUEST'])
Esempio n. 11
0
def set_others_info(request):
    user = header_checker(request)
    if user and user.position > 1:
        req = request.POST
        worker_id = req.get('worker_id')
        other = persons.Person.find_by_worker_id(worker_id)
        name = req.get('name')
        address = req.get('address')
        phone = req.get('phone')
        position = req.get('position')
        other.name = name
        other.address = address
        other.phone = phone
        other.position = position
        other.save()
        return response(response_code['OK'])
    return response(response_code['BAD_REQUEST'])
Esempio n. 12
0
def create_item(request):
    user = header_checker(request)
    if user and user.position > 1:
        req = request.POST
        new_item = menus.Menu.create_new_item()
        new_name = req.get('name')
        new_price = req.get('price')
        new_offset = req.get('offset')
        new_status = req.get('status')
        new_item.name = new_name
        new_item.price = new_price
        new_item.offset = new_offset
        if str(new_status) == 'true':
            new_item.status = True
        else:
            new_item.status = False
        new_item.save()
        return response(response_code['OK'])
Esempio n. 13
0
def create(request):
    user = header_checker(request)
    if user and user.position > 1:
        req = request.POST
        person = persons.Person.create()
        worker_id = req.get('worker_id')
        res = persons.Person.find_by_worker_id(worker_id)
        if not res:
            name = req.get('name')
            address = req.get('address')
            phone = req.get('phone')
            position = req.get('position')
            person.worker_id = worker_id
            person.name = name
            person.address = address
            person.phone = phone
            person.position = position
            person.save()
            return response(response_code['OK'])
    return response(response_code['BAD_REQUEST'])
Esempio n. 14
0
def modify_menu_item(request):
    user = header_checker(request)
    if user and user.position > 1:
        req = request.POST
        item_id = req.get('item_id')
        item = menus.Menu.find_item(item_id)
        if item:
            new_name = req.get('name')
            new_price = req.get('price')
            new_offset = req.get('offset')
            new_status = req.get('status')
            item.name = new_name
            item.price = new_price
            item.offset = new_offset
            if str(new_status) == 'true':
                item.status = True
            else:
                item.status = False
            item.save()
            return response(response_code['OK'])
    return response(response_code['BAD_REQUEST'])
Esempio n. 15
0
def get_menu(request):
    if header_checker(request):
        req = request.GET
        item = menus.Menu.find_item(req.get('item_id'))
        return response(response_code['OK'], item)
    return response(response_code['BAD_REQUEST'])
Esempio n. 16
0
def get_menus_on_sell(request):
    if header_checker(request):
        items = menus.Menu.find_all_on_sell()
        return response(response_code['OK'],
                        serializers.serialize('json', items))
    return response(response_code['BAD_REQUEST'])
Esempio n. 17
0
def verify(request):
    user = header_checker(request)
    if user:
        return response(response_code['OK'])
    return response(response_code['BAD_REQUEST'])
Esempio n. 18
0
def change_log(request):
    user = header_checker(request)
    if user:
        logs.Log.change_log(user['person_id'])
        return response(response_code['OK'])
    return response(response_code['BAD_REQUEST'])
Esempio n. 19
0
def logout(request):
    user = header_checker(request)
    if user:
        logs.Log.change_log(person_id=user.person_id)
        return response(response_code['OK'])
    return response(response_code['BAD_REQUEST'])