Example #1
0
def package_update_rest(context, data_dict):

    model = context['model']
    id = data_dict.get("id")
    request_id = context['id']
    pkg = model.Package.get(request_id)

    if not pkg:
        raise NotFound

    if id and id != pkg.id:
        pkg_from_data = model.Package.get(id)
        if pkg_from_data != pkg:
            error_dict = {
                id: ('Cannot change value of key from %s to %s. '
                     'This key is read-only') % (pkg.id, id)
            }
            raise ValidationError(error_dict)

    context["package"] = pkg
    context["allow_partial_update"] = False
    dictized_package = model_save.package_api_to_dict(data_dict, context)

    _check_access('package_update_rest', context, dictized_package)

    dictized_after = _get_action('package_update')(context, dictized_package)

    pkg = context['package']

    package_dict = model_dictize.package_to_api(pkg, context)

    return package_dict
Example #2
0
def package_update_rest(context, data_dict):

    model = context['model']
    id = data_dict.get("id")
    request_id = context['id']
    pkg = model.Package.get(request_id)

    if not pkg:
        raise NotFound

    if id and id != pkg.id:
        pkg_from_data = model.Package.get(id)
        if pkg_from_data != pkg:
            error_dict = {id:('Cannot change value of key from %s to %s. '
                'This key is read-only') % (pkg.id, id)}
            raise ValidationError(error_dict)

    context["package"] = pkg
    context["allow_partial_update"] = False
    dictized_package = model_save.package_api_to_dict(data_dict, context)

    check_access('package_update_rest', context, dictized_package)

    dictized_after = get_action('package_update')(context, dictized_package)

    pkg = context['package']

    package_dict = model_dictize.package_to_api(pkg, context)

    return package_dict
Example #3
0
def package_create_rest(context, data_dict):
    _check_access('package_create_rest', context, data_dict)
    dictized_package = model_save.package_api_to_dict(data_dict, context)
    dictized_after = _get_action('package_create')(context, dictized_package)
    pkg = context['package']
    package_dict = model_dictize.package_to_api(pkg, context)
    data_dict['id'] = pkg.id
    return package_dict
Example #4
0
def package_create_rest(context, data_dict):
    _check_access('package_create_rest', context, data_dict)
    dictized_package = model_save.package_api_to_dict(data_dict, context)
    dictized_after = _get_action('package_create')(context, dictized_package)
    pkg = context['package']
    package_dict = model_dictize.package_to_api(pkg, context)
    data_dict['id'] = pkg.id
    return package_dict
Example #5
0
def package_create_rest(context, data_dict):
    _check_access("package_create_rest", context, data_dict)
    dictized_package = model_save.package_api_to_dict(data_dict, context)
    dictized_after = _get_action("package_create")(context, dictized_package)
    pkg = context["package"]
    package_dict = model_dictize.package_to_api(pkg, context)
    data_dict["id"] = pkg.id
    return package_dict
Example #6
0
def package_show_rest(context, data_dict):

    check_access('package_show_rest',context, data_dict)

    logic.get_action('package_show')(context, data_dict)

    pkg = context['package']

    package_dict = model_dictize.package_to_api(pkg, context)

    return package_dict
Example #7
0
def package_show_rest(context, data_dict):

    check_access('package_show_rest', context, data_dict)

    logic.get_action('package_show')(context, data_dict)

    pkg = context['package']

    package_dict = model_dictize.package_to_api(pkg, context)

    return package_dict
def hri_package_show_rest(context, data_dict):

    logic.check_access('package_show_rest',context, data_dict)

    logic.get_action('package_show')(context, data_dict)

    pkg = context['package']

    package_dict = model_dictize.package_to_api(pkg, context)
    
    if is_harvester(context, data_dict):
        for key in [u'search_info', u'Hakutieto', u'L\xc3hde', u'L\xe4hde', u'Lahde']:
            if key in package_dict['extras'].keys():
                package_dict['extras'].pop(key)

    return package_dict
Example #9
0
def hri_package_show_rest(context, data_dict):

    logic.check_access('package_show_rest', context, data_dict)

    logic.get_action('package_show')(context, data_dict)

    pkg = context['package']

    package_dict = model_dictize.package_to_api(pkg, context)

    if is_harvester(context, data_dict):
        for key in [
                u'search_info', u'Hakutieto', u'L\xc3hde', u'L\xe4hde',
                u'Lahde'
        ]:
            if key in package_dict['extras'].keys():
                package_dict['extras'].pop(key)

    return package_dict