示例#1
0
def grant_channel_access(request, agent_id, shop_id, channel_id):
    logger = logging.getLogger(__name__)
    correlation_id = get_correlation_id_from_username(request.user)
    logger = setup_logger(request, logger, correlation_id)
    logger.info(
        "Checking permission for [{}] username with [{}] permission".format(
            request.user, 'CAN_BLOCK_AGENT_CHANNELS'))
    if not check_permissions_by_user(request.user, 'CAN_BLOCK_AGENT_CHANNELS'):
        return {"status": 1, "msg": ''}
    logger.info('========== Start grant access to channel ==========')
    url = settings.DOMAIN_NAMES + api_settings.CHANNEL_GRANT_PERMISSION.format(
        channel_id=channel_id)
    params = {
        'shop_id': shop_id,
        'user_id': agent_id,
        'user_type': {
            'id': 2,
            'name': 'agent'
        }
    }

    result = ajax_functions._post_method(request, url, "", logger, params)
    logger.info('========== Finish grant access to channel ==========')

    return result
示例#2
0
def reset_password(request, agent_id, identity_id):

    if not check_permissions_by_user(request.user, 'CAN_RESETPASSWORD_AGENT'):
        return

    logger = logging.getLogger(__name__)
    correlation_id = get_correlation_id_from_username(request.user)
    logger = setup_logger(request, logger, correlation_id)
    logger.info('========== Start reset password==========')
    url = settings.DOMAIN_NAMES + api_settings.AGENT_IDENTITY_RESET_PASSWORD.format(agent_id, identity_id)
    params = {}
    result = ajax_functions._post_method(request, url, "", logger, params, timeout=settings.GLOBAL_TIMEOUT)
    logger.info('========== Finish reset password ==========')
    return result
示例#3
0
def unbind_device(request, device_id):
    logger = logging.getLogger(__name__)
    correlation_id = get_correlation_id_from_username(request.user)
    logger = setup_logger(request, logger, correlation_id)
    logger.info(
        "Checking permission for [{}] username with [{}] permission".format(
            request.user, 'CAN_UNBIND_AGENT_DEVICE'))
    if not check_permissions_by_user(request.user, 'CAN_UNBIND_AGENT_DEVICE'):
        return {"status": 1, "msg": ''}
    logger.info('========== Start delete device ==========')
    url = settings.DOMAIN_NAMES + api_settings.DELETE_AGENT_DEVICE.format(
        device_id=device_id)

    result = ajax_functions._delete_method(request, url, "", logger)
    logger.info('========== Finish delete device ==========')
    return result
示例#4
0
def delete_amount_limit(request, rule_id, rule_limit_id):
    logger = logging.getLogger(__name__)
    correlation_id = get_correlation_id_from_username(request.user)
    logger = setup_logger(request, logger, correlation_id)
    logger.info('========== Start delete campaign amount limit ==========')

    if request.method == 'POST':
        url = settings.DOMAIN_NAMES + api_settings.DELETE_RULE_AMOUNT_LIMIT.format(
            rule_id=rule_id, rule_limit_id=rule_limit_id)
        result = ajax_functions._delete_method(request=request,
                                               api_path=url,
                                               func_description="",
                                               logger=logger)
        logger.info(
            '========== Finish delete campaign amount limit ==========')
        return result
示例#5
0
def delete_customer(request, customer_id):
    logger = logging.getLogger(__name__)
    correlation_id = get_correlation_id_from_username(request.user)
    logger = setup_logger(request, logger, correlation_id)
    logger.info('========== Start delete customer ==========')

    if request.method == 'POST':
        logger.info('Sending request to backend service')
        url = settings.DOMAIN_NAMES + api_settings.ADMIN_DELETE_CUSTOMER_URL.format(
            customer_id)

        result = ajax_functions._delete_method(request=request,
                                               api_path=url,
                                               func_description="",
                                               logger=logger)
        logger.info('========== Finish activating customer ==========')
        return result
示例#6
0
def activate(request, customer_id):
    if not check_permissions_by_user(request.user, 'CAN_SUSPEND_CUSTOMER'):
        return

    logger = logging.getLogger(__name__)
    correlation_id = get_correlation_id_from_username(request.user)
    logger = setup_logger(request, logger, correlation_id)
    logger.info('========== Start activating customer ==========')
    url = settings.DOMAIN_NAMES + api_settings.ACTIVATE_CUSTOMER.format(
        customer_id)
    params = {
        'is_suspended': 'false',
    }

    result = ajax_functions._put_method(request, url, "", logger, params)
    logger.info('========== Finish activating customer ==========')
    return result
示例#7
0
def enable_device(request, device_id):
    logger = logging.getLogger(__name__)
    correlation_id = get_correlation_id_from_username(request.user)
    logger = setup_logger(request, logger, correlation_id)
    logger.info(
        "Checking permission for [{}] username with [{}] permission".format(
            request.user, 'CAN_DISABLE_AGENT_DEVICE'))
    if not check_permissions_by_user(request.user, 'CAN_DISABLE_AGENT_DEVICE'):
        return {"status": 1, "msg": ''}
    logger.info('========== Start enable device ==========')
    url = settings.DOMAIN_NAMES + api_settings.UPDATE_AGENT_DEVICE_STATUS.format(
        device_id=device_id)
    params = {
        'is_active': True,
    }

    result = ajax_functions._put_method(request, url, "", logger, params)
    logger.info('========== Finish enable device ==========')
    return result
示例#8
0
def revoke_channel_access(request, customerId, channelId):
    logger = logging.getLogger(__name__)
    correlation_id = get_correlation_id_from_username(request.user)
    logger = setup_logger(request, logger, correlation_id)
    logger.info(
        "Checking permission for [{}] username with [{}] permission".format(
            request.user, 'CAN_BLOCK_CUSTOMER_CHANNELS'))
    if not check_permissions_by_user(request.user,
                                     'CAN_BLOCK_CUSTOMER_CHANNELS'):
        return {"status": 1, "msg": ''}
    logger.info('========== Start block access to channel ==========')
    url = settings.DOMAIN_NAMES + api_settings.CUSTOMER_CHANNEL_REVOKE_URL.format(
        channelId)
    params = {
        'user_id': customerId,
        'user_type': {
            "id": 1,
            'name': 'customer'
        }
    }

    result = ajax_functions._post_method(request, url, "", logger, params)
    logger.info('========== Finish block access to channel ==========')
    return result
 def dispatch(self, request, *args, **kwargs):
     correlation_id = get_correlation_id_from_username(self.request.user)
     self.logger = setup_logger(self.request, logger, correlation_id)
     return super(CustomerIdentitiesListView,
                  self).dispatch(request, *args, **kwargs)
示例#10
0
 def dispatch(self, request, *args, **kwargs):
     correlation_id = get_correlation_id_from_username(self.request.user)
     self.logger = setup_logger(self.request, logger, correlation_id)
     return super(SelfChangePassword,
                  self).dispatch(request, *args, **kwargs)
 def dispatch(self, request, *args, **kwargs):
     correlation_id = get_correlation_id_from_username(self.request.user)
     self.logger = setup_logger(self.request, logger, correlation_id)
     return super(PartnerFileList, self).dispatch(request, *args, **kwargs)