Esempio n. 1
0
def create_module():
    if not request.json:
        abort(400)
    module = { 'Id': module_set[-1]['Id'] + 1 if len(module_set) else 1 }
    create_record(module_class, request, module)
    module_set.append(module)
    return jsonify(module), 201
def create_employee():
    if not request.json:
        abort(400)
    employee = { 'Id': employee_set[-1]['Id'] + 1 if len(employee_set) else 1 }
    create_record(employee_class, request, employee)
    employee_set.append(employee)
    return jsonify(employee), 201
def create_stakeholder():
    if not request.json:
        abort(400)
    stakeholder = { 'Id': stakeholder_set[-1]['Id'] + 1 if len(stakeholder_set) else 1 }
    create_record(stakeholder_class, request, stakeholder)
    stakeholder_set.append(stakeholder)
    return jsonify(stakeholder), 201
Esempio n. 4
0
def create_content():
    if not request.json:
        abort(400)
    content = {'Id': content_set[-1]['Id'] + 1 if len(content_set) else 1}
    create_record(content_class, request, content)
    content_set.append(content)
    return jsonify(content), 201
Esempio n. 5
0
def create_test():
    if not request.json:
        abort(400)
    test = { 'Id': test_set[-1]['Id'] + 1 if len(test_set) else 1 }
    create_record(test_class, request, test)
    test_set.append(test)
    return jsonify(test), 201
Esempio n. 6
0
def create_manager():
    if not request.json:
        abort(400)
    manager = {'Id': manager_set[-1]['Id'] + 1 if len(manager_set) else 1}
    create_record(manager_class, request, manager)
    manager_set.append(manager)
    return jsonify(manager), 201
Esempio n. 7
0
def create_requirement():
    if not request.json:
        abort(400)
    requirement = { 'Id': requirement_set[-1]['Id'] + 1 if len(requirement_set) else 1 }
    create_record(requirement_class, request, requirement)
    requirement_set.append(requirement)
    return jsonify(requirement), 201
Esempio n. 8
0
def callback_inline(call):
    # try:
    if call.message:
        if call.data == 'buy':
            search_type = 'buy'
            print(call.message.chat)
            db.create_record(call.message.chat.username, search_type)

            bot.send_message(call.message.chat.id,
                             f'Ok. How many bedrooms do you want?')
            bot.register_next_step_handler(call.message, get_beds_num)

        elif call.data == 'rent':
            search_type = 'rent'
            print(call.message.chat.username)

            db.create_record(call.message.chat.username, search_type)

            bot.send_message(call.message.chat.id,
                             f'Ok. How many bedrooms do you want?')
            bot.register_next_step_handler(call.message, get_beds_num)

        elif call.data == 'correct':
            user = db.get_user(call.message.chat.username)
            search_type = user['search_type']
            beds = user['beds']
            baths = user['baths']
            min_price = user['min_price']
            max_price = user['max_price']

            data = scrapper.get_results(search_type, beds, baths, min_price,
                                        max_price)

            bot.send_message(call.message.chat.id,
                             f'Ok. Here is available variants')
            for el in data[0:10]:
                bot.send_message(
                    call.message.chat.id,
                    f'Price: {el["price"]}\nSize: {el["size"]}\nLocation: {el["location"]}\nLink: {el["link"]}'
                )

            bot.send_message(
                call.message.chat.id,
                'Thanks for using FindRealEstateBot.\nMade by Burik Sergio @sergioburik'
            )

        elif call.data == 'incorrect':
            bot.send_message(call.message.chat.id,
                             f'Ok. How many bedrooms do you want?')
            bot.register_next_step_handler(call.message, get_beds_num)
Esempio n. 9
0
def create_user():
    if not request.json:
        abort(400)
    user = {'Id': user_set[-1]['Id'] + 1 if len(user_set) else 1}
    if not create_record(user_class, request, user):
        abort(400)
    user_set.append(user)
    return jsonify(make_public_user(user)), 201
Esempio n. 10
0
def create_dose():
    if not request.json:
        abort(400)
    dose = {'Id': dose_set[-1]['Id'] + 1 if len(dose_set) else 1}
    dose['UserId'] = get_user_id(auth.username())
    if not create_record(dose_class, request, dose):
        abort(400)
    dose_set.append(dose)
    return jsonify(make_public_dose(dose)), 201