Example #1
0
        return json(data)

async def pre_get_many_service(search_params=None, request=None, **kw):
    # print(search_params)
    if search_params.get('order_by') is None:
        search_params['order_by'] = [{"field":"created_at","direction":"asc"}]
    else:
        search_params['order_by'].append({"field":"created_at","direction":"asc"})
        

apimanager.create_api(Service,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/v1',
    preprocess=dict(GET_SINGLE=[verify_access, pre_filter_by_tenant],
                    GET_MANY=[verify_access, pre_filter_by_tenant, pre_get_many_service],
                    POST=[verify_access, pre_post_set_tenant_id, pre_process_save_service],
                    PUT_SINGLE=[verify_access, pre_process_save_service]),
    postprocess=dict(GET_SINGLE=[],
                     GET_MANY=[],
                     PUT_SINGLE=[],
                     DELETE_SINGLE=[]),
    collection_name='service')

apimanager.create_api(ServicesProviders,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/v1',
    preprocess=dict(GET_SINGLE=[verify_access, pre_filter_by_tenant],
                    GET_MANY=[verify_access, pre_filter_by_tenant],
                    POST=[verify_access, pre_post_set_tenant_id],
                    PUT_SINGLE=[verify_access]),
    # postprocess=dict(GET_SINGLE=[post_process_get_item],
    #                  GET_MANY=[post_process_get_item],
Example #2
0
            exclude_attrs = ['tenant_id']
            for key in exclude_attrs:
                if key in data:
                    del data[key]

            if 'password' in data and data.get('password') == None:
                del data['password']


apimanager.create_api(
    User,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/v1',
    preprocess=dict(GET_SINGLE=[verify_access],
                    GET_MANY=[verify_access],
                    POST=[verify_access, pre_process_create_user],
                    PUT_SINGLE=[verify_access, pre_process_create_user]),
    exclude_columns=[
        'password', 'salt', 'created_at', 'created_by', 'created_by_name',
        'updated_at', 'updated_by', 'updated_by_name', 'deleted_at',
        'deleted_by', 'deleted_by_name'
    ],
    collection_name='user')

apimanager.create_api(Role,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/v1',
                      preprocess=dict(
                          GET_SINGLE=[verify_access, pre_filter_by_tenant],
                          GET_MANY=[verify_access, pre_filter_by_tenant],
                          POST=[verify_access, pre_post_set_tenant_id],
                          PUT_SINGLE=[verify_access]),
Example #3
0
def get_task_schedule(request):
    id_schedule = request.args.get("id", None)
    task_schedule = db.session.query(TaskSchedule).filter(
        TaskSchedule.id == id_schedule).first()
    result = to_dict(task_schedule)
    result['task_scheduledetail'] = []
    for task_scheduledetail in task_schedule.task_scheduledetail:
        obj = to_dict(task_scheduledetail)
        obj['tasks_info'] = [
            to_dict(task_info) for task_info in task_scheduledetail.tasks_info
        ]
        result['task_scheduledetail'].append(obj)

    return json(result)


apimanager.create_api(collection_name='task_schedule',
                      model=TaskSchedule,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(
                          GET_SINGLE=[auth_func],
                          GET_MANY=[auth_func, filter_taskschedule],
                          POST=[auth_func, create_taskschedule],
                          PUT_SINGLE=[auth_func],
                          DELETE_SINGLE=[auth_func]),
                      postprocess=dict(POST=[],
                                       PUT_SINGLE=[],
                                       DELETE_SINGLE=[],
                                       GET_MANY=[]))
Example #4
0
from application.controllers.user import *


def auth_func(request=None, **kw):
    #uid = auth.current_user(request)
    #if uid is None:
    #    raise ServerError("abc")

    pass


apimanager.create_api(
    collection_name='users',
    model=User,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[auth_func],
                    GET_MANY=[auth_func],
                    POST=[auth_func],
                    PUT_SINGLE=[auth_func]),
)
apimanager.create_api(
    collection_name='employee',
    model=Employee,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[auth_func],
                    GET_MANY=[auth_func],
                    PUT_SINGLE=[auth_func],
                    POST=[auth_func]),
    postprocess=dict(POST=[user_register],
                     PUT_SINGLE=[],
Example #5
0
# @app.route('/v1/update_thumbnail', methods=['GET'])
# async def update(request):
#     current_tenant = get_current_tenant(request)
#     if current_tenant is None or 'error_code' in current_tenant:
#         return json({
#             'error_code': 'TENANT_UNKNOWN',
#             'error_message': 'Thông tin request không xác định'
#         }, status=523)

#     tenant_id = current_tenant.get('id')
#     posts = db.session.query(Post).filter(Post.tenant_id == tenant_id).all()
#     for post in posts:
#         if post.thumbnail == "https://s3-alpha-sig.figma.com/img/00a2/767a/c209c3bef75a57f4fcaa03551dd31bcb?Expires=1605484800&Signature=REC4tR0yrtdUOwMSO5lXGPcY~ijrCvuhBN4Jl~I1oFrzHNtyxKA00Y5M4zkDc2tVSeRCqM835Qzk5EiXrZHiCc8hWCEPrXEYYXh2ebenlMDIiemlDJbiu8gGssnZO~cqkZI3A8c-YjFZm5sGhf4FsPjfV7ji7yfAPoZtXyN6oB6EMMt3vwQTepalDEN-MWnz3OmeF~NLqFE694d-q7sLjYEKah~LNPwQnXobm9cLhKbf3Wny8~oeHRJJ97w412f9hzr9sKmXNwN3BG6LPtztDTuxY8p0wbn45T249Z9AH~y1Mux2hEocstgk27JJ1mVA5DGRIiUqLLPz7pbFIHfbNg__&Key-Pair-Id=APKAINTVSUGEWH5XD5UA":
#             post.thumbnail = "https://upstart.vn/static/upload/upinstantpage/830526101231606202260215.jpg"
#             db.session.add(post)
#     db.session.commit()
#     return json({"ok": True})
apimanager.create_api(Post,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/v1',
                      preprocess=dict(
                          GET_SINGLE=[verify_access, pre_filter_by_tenant],
                          GET_MANY=[verify_access, pre_filter_by_tenant],
                          POST=[verify_access, pre_post_set_tenant_id],
                          PUT_SINGLE=[verify_access]),
                      postprocess=dict(GET_SINGLE=[],
                                       GET_MANY=[],
                                       POST=[],
                                       PUT=[]),
                      collection_name='post')
        nguoikedon["updated_at"] = floor(time.time())

        list_nguoikedon.append(nguoikedon)
        prescription.nguoikedon = list_nguoikedon
        prescription.thuoc = data["thuoc"]
        flag_modified(prescription, "nguoikedon")
        db.session.commit()
        return json(to_dict(prescription), status=200)


apimanager.create_api(Medicine,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(GET_SINGLE=[validate_admin],
                                      GET_MANY=[validate_admin],
                                      POST=[validate_admin],
                                      PUT_SINGLE=[validate_admin]),
                      postprocess=dict(GET_SINGLE=[],
                                       GET_MANY=[],
                                       POST=[],
                                       PUT_SINGLE=[]),
                      collection_name='medicine')

apimanager.create_api(
    Prescription,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[validate_user],
                    GET_MANY=[validate_user],
                    POST=[validate_user, preprocess_prescription],
                    PUT_SINGLE=[validate_user,
                                preprocess_prescription_update]),
Example #7
0
@app.route('/tenant/set_current_tenant', methods=['POST'])
async def set_current_tenant(request):
    verify_access(request)

    body_data = request.json

    tenant_id = body_data.get('tenant_id', None)
    if tenant_id is None:
        return json({
            'error_code': 'DATA_ERROR',
            'error_message': 'Dữ liệu không hợp lệ'
        }, status=520)

    request['session']['current_tenant_id'] = tenant_id

    return json({}, status=200)


apimanager.create_api(
    Tenant,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(
        GET_SINGLE=[],
        GET_MANY=[],
        POST=[],
        PUT_SINGLE=[]),
    collection_name='tenant'
)
Example #8
0
                    db.session.add(booking_spa_item_relations)
                    db.session.flush()
                    db.session.commit()
        return json(data)


# @app.route("/api/v1/fake_data_spa", methods=["GET", "POST"])
# async def fake(request):
apimanager.create_api(
    BookingSpaItem,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/v1',
    preprocess=dict(GET_SINGLE=[verify_access, pre_filter_by_tenant],
                    GET_MANY=[verify_access, pre_filter_by_tenant],
                    POST=[
                        verify_access, pre_post_set_tenant_id,
                        pre_process_save_booking_spa_item
                    ],
                    PUT_SINGLE=[verify_access]),
    # postprocess=dict(GET_SINGLE=[post_process_get_item],
    #                  GET_MANY=[post_process_get_item],
    #                  PUT_SINGLE=[],
    #                  DELETE_SINGLE=[]),
    collection_name='booking_spa_item')

apimanager.create_api(
    BookingSpaItemRelations,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/v1',
    preprocess=dict(GET_SINGLE=[verify_access, pre_filter_by_tenant],
                    GET_MANY=[verify_access, pre_filter_by_tenant],
                    POST=[verify_access, pre_post_set_tenant_id],
Example #9
0
            db.session.delete(check_donvi)
            db.session.commit()
        except:
            return json(
                {
                    "error_code": "PARAMS_ERROR",
                    "error_message": "Không thể xóa đơn vị đã tạo báo cáo"
                },
                status=520)


apimanager.create_api(UserDonvi,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(
                          GET_SINGLE=[auth_func],
                          GET_MANY=[auth_func, dangkydonvi_pregetmany],
                          POST=[auth_func],
                          PUT_SINGLE=[auth_func, pre_put_user_donvi],
                          DELETE_SINGLE=[auth_func, predelete_userdonvi]),
                      collection_name='user_donvi')

apimanager.create_api(TuyenDonVi,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(
                          GET_SINGLE=[auth_func],
                          GET_MANY=[auth_func, tuyendonvi_pregetmany],
                          POST=[auth_func],
                          PUT_SINGLE=[auth_func]),
                      collection_name='tuyendonvi')
            if "content" in result["objects"][i]:
                result["objects"][i]["content"] = ""
            i = i + 1

        sort_post = sorted(result["objects"],
                           key=lambda k: (k['priority'], -k['created_at']),
                           reverse=False)
        result["objects"] = sort_post


apimanager.create_api(Category,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(GET_SINGLE=[validate_user],
                                      GET_MANY=[validate_user],
                                      POST=[validate_admin],
                                      PUT_SINGLE=[validate_admin]),
                      postprocess=dict(GET_SINGLE=[],
                                       GET_MANY=[postprocess_category],
                                       POST=[],
                                       PUT_SINGLE=[]),
                      collection_name='category')

apimanager.create_api(Post,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(GET_SINGLE=[validate_user],
                                      GET_MANY=[validate_user],
                                      POST=[validate_admin],
                                      PUT_SINGLE=[validate_admin]),
                      postprocess=dict(GET_SINGLE=[],
                                       GET_MANY=[postprocess_post],
Example #11
0
from application.extensions import apimanager
from application.models.model import User, AssigningWork
from application.extensions import auth
from gatco.exceptions import ServerError


def auth_func(request=None, **kw):
    # uid = auth.current_user(request)
    # if uid is None:
    #    raise ServerError("abc")

    pass


# def user_register(request=None, **kw):
#     pass

apimanager.create_api(
    collection_name='assigningwork',
    model=AssigningWork,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[auth_func],
                    GET_MANY=[auth_func],
                    PUT_SINGLE=[auth_func],
                    POST=[auth_func]),
)
Example #12
0
        for obj in objects:
            if obj is not None:
                obj_tmp = to_dict(obj)
                obj_tmp["stt"] = i
                i = i + 1
                datas.append(obj_tmp)
        result = datas


apimanager.create_api(QuocGia,
                      max_results_per_page=1000000,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(GET_SINGLE=[auth_func],
                                      GET_MANY=[],
                                      POST=[auth_func, prepost_danhmuc],
                                      PUT_SINGLE=[auth_func, preput_danhmuc]),
                      postprocess=dict(POST=[],
                                       PUT_SINGLE=[],
                                       DELETE_SINGLE=[],
                                       GET_MANY=[postprocess_add_stt]),
                      collection_name='quocgia')

apimanager.create_api(
    TinhThanh,
    max_results_per_page=1000000,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(
        GET_SINGLE=[auth_func],
        GET_MANY=[],
Example #13
0
        
        del category_item_relations_dict['id']
        del category_item_relations_dict['category_id']
        del category_item_relations_dict['item_id']
        topping.append({**category_dict, **category_item_relations_dict})
    
    return json({"categories": topping}, status = 200)

apimanager.create_api(Item,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/v1',
    preprocess=dict(GET_SINGLE=[verify_access, pre_filter_by_tenant],
                    GET_MANY=[verify_access, pre_filter_by_tenant],
                    POST=[verify_access, pre_post_set_tenant_id, pre_process_save_item],
                    PUT_SINGLE=[verify_access, pre_process_save_item]),
    # postprocess=dict(GET_SINGLE=[post_process_get_item],
    #                  GET_MANY=[post_process_get_item],
    #                  PUT_SINGLE=[],
    #                  DELETE_SINGLE=[]),
    postprocess=dict(
        GET_SINGLE=[post_process_get_item],
        GET_MANY=[post_process_get_item]
    ),
    collection_name='item')

apimanager.create_api(ItemCategory,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/v1',
    preprocess=dict(GET_SINGLE=[verify_access, pre_filter_by_tenant],
                    GET_MANY=[verify_access, pre_filter_by_tenant],
                    POST=[verify_access, pre_post_set_tenant_id],
                    PUT_SINGLE=[verify_access]),
            data['id'] = record.id
            return json(to_dict(record))


async def update_name_khongdau(request=None, data=None, Model=None, **kw):
    if "ten" in data:
        data["tenkhongdau"] = convert_text_khongdau(data["ten"])
    elif "name" in data:
        data["tenkhongdau"] = convert_text_khongdau(data["name"])


apimanager.create_api(Brands,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(
                          GET_SINGLE=[validate_user],
                          GET_MANY=[validate_user],
                          POST=[validate_user, check_exist_danhmuc],
                          PUT_SINGLE=[validate_user]),
                      postprocess=dict(POST=[], PUT_SINGLE=[]),
                      collection_name='brands')
apimanager.create_api(GroupSupplies,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(
                          GET_SINGLE=[validate_user],
                          GET_MANY=[validate_user],
                          POST=[validate_user, check_exist_danhmuc],
                          PUT_SINGLE=[validate_user]),
                      postprocess=dict(POST=[], PUT_SINGLE=[]),
                      collection_name='group_supplies')
apimanager.create_api(CodeSupplies,
Example #15
0
from application.extensions import apimanager
from .model import Contact
# from gatco.exceptions import ServerError
from application.components.base.view import verify_access

apimanager.create_api(
    Contact,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api',
    # preprocess=dict(GET_SINGLE=[verify_access],
    #                 GET_MANY=[verify_access],
    #                 POST=[verify_access],
    #                 PUT_SINGLE=[verify_access]),
    collection_name='contact')
Example #16
0
                            role.role_name = role_name
                            role.display_name = role_display
                        user.roles.append(role)
    
                db.session.add(user)
                db.session.commit()
    
    return json({"message": "success"})



apimanager.create_api(User,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[verify_access],
                    GET_MANY=[verify_access],
                    POST=[verify_access],
                    PUT_SINGLE=[verify_access]),
    exclude_columns = ['password'],
    collection_name='user')

apimanager.create_api(Role,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[verify_access],
                    GET_MANY=[verify_access],
                    POST=[verify_access],
                    PUT_SINGLE=[verify_access]),
    collection_name='role')

apimanager.create_api(Permission,
Example #17
0
import uuid, copy
from application.extensions import apimanager
from sqlalchemy import or_, and_, func, literal
from sqlalchemy.sql.expression import cast
from gatco_restapi.helpers import to_dict
from gatco.response import json, text, html
from application.server import app
from application.database import db
from application.common.helpers import now_timestamp
from application.components.base import verify_access, get_current_tenant,\
    pre_filter_by_tenant, pre_post_set_tenant_id
from application.components.item.model import Item, ItemCategory, ItemCategoryRelation, PriceList, ItemPriceList, ItemVariants

# MODELS
from .model import CleaningRoomBooking

apimanager.create_api(
    CleaningRoomBooking,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/v1',
    preprocess=dict(GET_SINGLE=[verify_access, pre_filter_by_tenant],
                    GET_MANY=[verify_access, pre_filter_by_tenant],
                    POST=[verify_access, pre_post_set_tenant_id],
                    PUT_SINGLE=[verify_access]),
    # postprocess=dict(GET_SINGLE=[post_process_get_item],
    #                  GET_MANY=[post_process_get_item],
    #                  PUT_SINGLE=[],
    #                  DELETE_SINGLE=[]),
    collection_name='cleaning_room_booking')
Example #18
0
from gatco.exceptions import ServerError


def auth_func(request=None, **kw):
    #uid = auth.current_user(request)
    #if uid is None:
    #    raise ServerError("abc")

    pass


apimanager.create_api(collection_name='user',
                      model=User,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(GET_SINGLE=[auth_func],
                                      GET_MANY=[auth_func],
                                      POST=[auth_func],
                                      PUT_SINGLE=[auth_func]),
                      include_columns=['id', 'birthday', 'email', 'is_active'])

apimanager.create_api(
    collection_name='quocgia',
    model=QuocGia,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[auth_func],
                    GET_MANY=[auth_func],
                    POST=[auth_func],
                    PUT_SINGLE=[auth_func]),
)
        for obj in objects:
            if obj is not None:
                obj_tmp = to_dict(obj)
                obj_tmp["stt"] = i
                i = i + 1
                datas.append(obj_tmp)
        result = datas


apimanager.create_api(DanhMucHoatDong,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(
                          GET_SINGLE=[auth_func],
                          GET_MANY=[auth_func],
                          POST=[auth_func, prepost_put_danhmuchoatdong],
                          PUT_SINGLE=[auth_func, prepost_put_danhmuchoatdong],
                          DELETE_SINGLE=[auth_func]),
                      postprocess=dict(POST=[],
                                       PUT_SINGLE=[],
                                       DELETE_SINGLE=[],
                                       GET_MANY=[postprocess_add_stt]),
                      collection_name='danhmuchoatdong')

apimanager.create_api(TienDoKeHoachBCC,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(
                          GET_SINGLE=[auth_func],
                          GET_MANY=[auth_func],
                          POST=[auth_func, preprocess_kehoachbcc],
                          PUT_SINGLE=[auth_func, preprocess_kehoachbcc],
Example #20
0
        return json(
            {
                "error_code": "USER_NOT_FOUND",
                "error_message": "USER_NOT_FOUND"
            },
            status=520)


apimanager.create_api(collection_name='filter_group',
                      model=Group,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(GET_SINGLE=[auth_func],
                                      GET_MANY=[auth_func],
                                      POST=[
                                          auth_func,
                                      ],
                                      PUT_SINGLE=[auth_func],
                                      DELETE_SINGLE=[auth_func]),
                      postprocess=dict(POST=[auth_func],
                                       PUT_SINGLE=[],
                                       DELETE_SINGLE=[],
                                       GET_MANY=[]),
                      exclude_columns=['members', 'checklists', 'tasks_info'])

apimanager.create_api(
    collection_name='groups_users',
    model=GroupsUsers,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[auth_func],
                    GET_MANY=[auth_func, getManyGroup],
Example #21
0
from application.extensions import apimanager
from application.models.model import User, QuocGia, TinhThanh
from application.extensions import auth
from gatco.exceptions import ServerError


def auth_func(request=None, **kw):
    #uid = auth.current_user(request)
    #if uid is None:
    #    raise ServerError("abc")

    pass


apimanager.create_api(
    collection_name='tinhthanh',
    model=TinhThanh,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[auth_func],
                    GET_MANY=[auth_func],
                    POST=[auth_func],
                    PUT_SINGLE=[auth_func]),
)
Example #22
0
from application.extensions import apimanager

from .model import Port

apimanager.create_api(Port,
                      methods=["GET", "POST", "PUT", "DELETE"],
                      url_prefix='/api',
                      collection_name="port")
Example #23
0
    except:
        pass

    if exid is not None:
        workstation = Workstation.query.filter(
            Workstation.workstation_exid == exid).first()
        return json(to_dict(workstation))

    return json(None)


apimanager.create_api(Workstation,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(
                          GET_SINGLE=[verify_access, pre_filter_by_tenant],
                          GET_MANY=[verify_access, pre_filter_by_tenant],
                          POST=[verify_access, pre_post_set_tenant_id],
                          PUT_SINGLE=[verify_access]),
                      collection_name='workstation')

apimanager.create_api(PointOfSale,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(
                          GET_SINGLE=[verify_access, pre_filter_by_tenant],
                          GET_MANY=[verify_access, pre_filter_by_tenant],
                          POST=[verify_access, pre_post_set_tenant_id],
                          PUT_SINGLE=[verify_access]),
                      collection_name='pointofsale')
Example #24
0
    data = ujson.dumps({ "data": {"type":"has_user_checkin"}, "app": "upgo_furama", "device_ids": list_device_ids})
    headers = {
                'content-type': 'application/json',
                'UPSTART-FIREBASE-KEY': '07jZNydE4C9OXqC4IjNcMyBk7hCpivz9qIW37ZvZsuBdK35gdIhN4IY1NqfTJCSZ'
            }
    requests.post(url_notify, data = data, headers=headers)

apimanager.create_api(
    Contact,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/v1',
    preprocess=dict(
        GET_SINGLE=[verify_access, pre_filter_by_tenant],
        GET_MANY=[verify_access, pre_filter_by_tenant],
        POST=[verify_access, pre_post_set_tenant_id],
        PUT_SINGLE=[verify_access]),
    postprocess=dict(
        GET_SINGLE=[],
        GET_MANY=[],
        POST=[],
        PUT=[]
    ),
    collection_name='contact'
)

apimanager.create_api(
    ContactRoomSession,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/v1',
    preprocess=dict(
        GET_SINGLE=[verify_access, pre_filter_by_tenant],
    return res


def generation_id():
    time_gen = floor(time.time()) - 1577811600
    id = int_to_base36(time_gen)
    number_rd = random.randint(1, 1295)
    print('-----', time_gen)
    id += int_to_base36(number_rd)
    return id


def tokhaiyte_gen_id(request=None, Model=None, data=None, **kw):
    data["id"] = generation_id()


apimanager.create_api(
    ToKhaiYTe,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    #preprocess=dict(GET_SINGLE=[auth_func], GET_MANY=[auth_func], POST=[auth_func], PUT_SINGLE=[auth_func], DELETE_SINGLE=[auth_func]),
    preprocess=dict(GET_SINGLE=[auth_func],
                    GET_MANY=[auth_func],
                    POST=[auth_func, tokhaiyte_gen_id],
                    PUT_SINGLE=[auth_func],
                    DELETE_SINGLE=[auth_func]),

    #results_per_page=30,
    collection_name='tokhaiyte')
Example #26
0
from .model import Country, City

from application.extensions import apimanager


apimanager.create_api(
    Country,
    methods = ["GET", "POST", "PUT", "DELETE"],
    url_prefix='/api/v1',
    collection_name = "country"
)

apimanager.create_api(
    City,
    methods = ["GET", "POST", "PUT", "DELETE"],
    url_prefix='/api/v1',
    collection_name = "city"
)
        "text": "Số người cách ly tập trung"
    },
    # {"name":"songuoidangcachlytaptrung_cotrieuchung", "text": "Số người cách ly tập trung, có triệu chứng"},
    {
        "name": "sochuyenbay",
        "text": "Số lượng chuyến bay nhập"
    },
]

apimanager.create_api(
    BaoCaoNghiNgoNhiemBenh,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    #preprocess=dict(GET_SINGLE=[auth_func], GET_MANY=[auth_func], POST=[auth_func], PUT_SINGLE=[auth_func], DELETE_SINGLE=[auth_func]),
    preprocess=dict(GET_SINGLE=[auth_func],
                    GET_MANY=[auth_func],
                    POST=[auth_func],
                    PUT_SINGLE=[auth_func],
                    DELETE_SINGLE=[auth_func]),

    #results_per_page=30,
    collection_name='baocaonghingonhiembenh')

apimanager.create_api(
    BaoCaoNghiNgoNhiemBenhXetNghiem,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    #preprocess=dict(GET_SINGLE=[auth_func], GET_MANY=[auth_func], POST=[auth_func], PUT_SINGLE=[auth_func], DELETE_SINGLE=[auth_func]),
    preprocess=dict(GET_SINGLE=[auth_func],
                    GET_MANY=[auth_func],
                    POST=[auth_func],
Example #28
0
        user['display_name_server'] = user['display_name']
        user['id'] = str(user['id'])
        # print(contact)
        response.append(user)
    # return response
    # print(result)
    # print(response)


apimanager.create_api(collection_name='search_user',
                      model=User,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(GET_SINGLE=[auth_func],
                                      GET_MANY=[auth_func],
                                      POST=[auth_func],
                                      PUT_SINGLE=[auth_func],
                                      DELETE_SINGLE=[auth_func]),
                      postprocess=dict(POST=[],
                                       PUT_SINGLE=[],
                                       DELETE_SINGLE=[],
                                       GET_MANY=[post_search_user]),
                      exclude_columns=['password', 'salt'])
apimanager.create_api(collection_name='user',
                      model=User,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(GET_SINGLE=[auth_func],
                                      GET_MANY=[auth_func],
                                      POST=[auth_func],
                                      PUT_SINGLE=[auth_func],
                                      DELETE_SINGLE=[auth_func]),
Example #29
0
from application.extensions import apimanager
from application.server import app
from application.database import db
from sqlalchemy.orm import aliased, joinedload_all
from gatco.response import json, text, html

from .helpers import *
from application.models.model_hdhgd import *
from sqlalchemy import or_
from application.client import HTTPClient

apimanager.create_api(KiemTraTinhTrangVSS,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(GET_SINGLE=[auth_func],
                                      GET_MANY=[auth_func],
                                      POST=[auth_func],
                                      PUT_SINGLE=[auth_func],
                                      DELETE_SINGLE=[auth_func]),
                      collection_name='kiemtratinhtrangvss')

apimanager.create_api(NhaTieuThamNuoc,
                      methods=['GET', 'POST', 'DELETE', 'PUT'],
                      url_prefix='/api/v1',
                      preprocess=dict(GET_SINGLE=[auth_func],
                                      GET_MANY=[auth_func],
                                      POST=[auth_func],
                                      PUT_SINGLE=[auth_func],
                                      DELETE_SINGLE=[auth_func]),
                      collection_name='nhatieuthamnuoc')
Example #30
0
    return json({"message": "success"}, status=STATUS_CODE['OK'])


#     except:
#         return json({
#             "error_code": ERROR_CODE['EXCEPTION'],
#             "error_message": ERROR_MSG['EXCEPTION']
#         }, status=STATUS_CODE['ERROR'])



apimanager.create_api(Configuration,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[verify_access],\
                    GET_MANY=[verify_access],\
                    POST=[verify_access],\
                    PUT_SINGLE=[verify_access]),
    collection_name='configuration')


apimanager.create_api(ConnectionApp,
    methods=['GET', 'POST', 'DELETE', 'PUT'],
    url_prefix='/api/v1',
    preprocess=dict(GET_SINGLE=[verify_access],\
                    GET_MANY=[verify_access],\
                    POST=[veridy_app_data],\
                    PUT_SINGLE=[veridy_app_data]),
    collection_name='connection_app')