コード例 #1
0
def admin_set_parent_api_remove(request):
    """管理员开启用户api功能"""
    msg = ''
    status = False

    res = {'status': status, 'msg': msg}
    creator = request.user

    try:
        user = handle_request_user(request)
        if not user:
            msg = af.USER_NOT_EXIST
            assert False

        msg = set_user_api_remove(user)

        if not msg:
            log_msg = om.REMOVE_API % (creator.username, user.username)
            OperateLog.write_operate_log(request, om.ACCOUNTS, log_msg)

            status = True

    except AssertionError:
        res['msg'] = _(msg)

    res['status'] = status
    print(res)

    return json_response(res)
コード例 #2
0
def admin_cdn_domain_log_list(request):
    """域名日志列表"""
    msg = ''
    status = False

    res = {'status': status, 'msg': msg}

    try:
        user = handle_request_user(request)
        if not user:
            msg = af.USER_NOT_EXIST
            assert False

        msg, result_list, pagination = get_domain_log(request, user)
        if msg:
            assert False

        res['log_list'] = result_list
        res['page_info'] = pagination

        status = True
    except AssertionError:
        res['msg'] = _(msg)

    res['status'] = status

    return json_response(res)
コード例 #3
0
def admin_set_parent_api_status(request):
    """管理员设置父账号api状态"""
    msg = ''
    status = False

    res = {'status': status, 'msg': msg}
    creator = request.user

    try:
        user = handle_request_user(request)
        if not user:
            msg = af.USER_NOT_EXIST
            assert False

        msg = set_user_api_status(request, user)
        if msg:
            assert False

        log_msg = om.OPEN_SET_API_STATUS % (creator.username, user.username)
        OperateLog.write_operate_log(request, om.ACCOUNTS, log_msg)

        status = True

    except AssertionError:
        res['msg'] = _(msg)

    res['status'] = status

    return json_response(res)
コード例 #4
0
def admin_cdn_domain_preload_status(request):
    """管理员url预热查询"""
    msg = ''
    status = False

    res = {'status': status, 'msg': msg}

    try:
        user = handle_request_user(request)
        if not user:
            msg = af.USER_NOT_EXIST
            assert False

        msg, result_list, pagination = user_domain_preload_status(
            request, user)

        if msg:
            assert False

        res['preload_log_list'] = result_list
        res['page_info'] = pagination

        status = True
    except Exception as e:
        print(e)
        res['msg'] = _(msg)

    res['status'] = status

    return json_response(res)
コード例 #5
0
def admin_cdn_domain_preload(request):
    """管理员url预热"""
    msg = ''
    status = False

    res = {'status': status, 'msg': msg}

    try:
        user = handle_request_user(request)
        if not user:
            msg = af.USER_NOT_EXIST
            assert False

        msg = user_domain_preload(request, user)

        if msg:
            assert False

        status = True

    except Exception as e:
        print(e)
        res['msg'] = _(msg)

    res['status'] = status
    print(res)

    return json_response(res)
コード例 #6
0
def admin_cdn_domain_refresh(request):
    """管理员url刷新"""
    msg = ''
    status = False

    res = {'status': status, 'msg': msg}

    try:
        user = handle_request_user(request)
        if not user:
            msg = af.USER_NOT_EXIST
            assert False

        msg = user_domain_refresh(request, user)

        if msg:
            assert False

        if not msg:
            status = True
    except AssertionError:
        res['msg'] = _(msg)

    res['status'] = status

    print(res)

    return json_response(res)
コード例 #7
0
def admin_cdn_create_domain(request):
    """
    创建cdn域名
    """
    msg = ''
    status = False

    res = {'status': status, 'msg': msg}
    print(request.POST)

    opt_user = request.user

    try:
        user = handle_request_user(request)
        if not user:
            msg = af.USER_NOT_EXIST
            assert False

        msg, status = user_domain_create(request, user, opt_user)

        if not status:
            assert False

    except AssertionError:
        res['msg'] = _(msg)

    res['status'] = status

    return json_response(res)
コード例 #8
0
def admin_open_parent_api(request):
    """管理员开启用户api功能"""
    msg = ''
    status = False

    res = {'status': status, 'msg': msg}
    creator = request.user

    try:
        user = handle_request_user(request)
        # user = UserProfile.objects.get(id=93)
        if not user:
            msg = af.USER_NOT_EXIST
            assert False

        msg, api_res = user_open_parent_api(user)

        if not msg:
            api_info = list()

            api_info_dict = {
                'secret_id': api_res.get('secret_id', ''),
                'secret_key': api_res.get('secret_key', ''),
                'create_time': api_res.get('create_time', ''),
                'status': api_res.get('api_open', ''),
                'type': _(af.COMMON)
            }
            api_info.append(api_info_dict)
            res['api_info'] = api_info

            log_msg = om.OPEN_API % (creator.username, user.username)
            OperateLog.write_operate_log(request, om.ACCOUNTS, log_msg)

            status = True

    except AssertionError:
        res['msg'] = _(msg)

    res['status'] = status
    print(res)

    return json_response(res)