コード例 #1
0
def get_master_timezone(timezone_id=None):
    try:
        master_timezone = MasterTimezoneDelegate(timezone_id)
        data = master_timezone.get()
    except:
        response = FAILURE_RESPONSE
        return response
    if data is not None:
        response_data = SUCCESS.copy()
        response_data["data"] = data
        response = generic_success_response(response_data)
    else:
        response_data = ERROR.copy()
        response_data["message"] = INVALID_ID
        response = generic_success_response(response_data)
    return response
コード例 #2
0
def search_master_timezone(q=None):
    try:
        master_timezone = MasterTimezoneDelegate()
        data = master_timezone.search(q)
    except:
        response = FAILURE_RESPONSE
        return response
    if data is not None:
        response_data = SUCCESS.copy()
        if data != EMPTY_LIST:
            response_data["data"] = data
        else:
            response_data["message"] = NO_DATA
        response = generic_success_response(response_data)
    else:
        response = ERROR_RESPONSE
    return response
コード例 #3
0
def update_master_timezone_active(timezone_id=None):
    data_request = request.get_json()
    schema = Schema({Required("is_active"): All(int, validate_is_active)})
    try:
        schema(data_request)
    except MultipleInvalid as e:
        return multiple_invalid_response(e)
    is_active = data_request.get('is_active')
    master_timezone = MasterTimezoneDelegate(timezone_id)
    if is_active != '':
        if master_timezone.update_timezone_is_active(is_active):
            response_data = SUCCESS.copy()
            response_data["message"] = UPDATED
            response = generic_success_response(response_data)
        else:
            response = ERROR_RESPONSE
    else:
        response = ERROR_RESPONSE
    return response