Example #1
0
def taxonomy_term_update(context, data_dict):
    """ Allows a taxonomy term to be updated.

    :returns: The newly updated term
    :rtype: A dictionary
    """
    _check_access('taxonomy_term_update', context, data_dict)
    model = context['model']

    id = logic.get_or_bust(data_dict, 'id')

    term = TaxonomyTerm.get(id)
    if not term:
        raise logic.NotFound()

    term.label = data_dict.get('label', term.label)
    term.parent_id = data_dict.get('parent_id', term.parent_id)
    term.uri = logic.get_or_bust(data_dict, 'uri')
    term.description = data_dict.get('description', '')
    term.extras = data_dict.get('extras', '')

    model.Session.add(term)
    model.Session.commit()

    return term.as_dict()
Example #2
0
def taxonomy_term_update(context, data_dict):
    """ Allows a taxonomy term to be updated.

    :returns: The newly updated term
    :rtype: A dictionary
    """
    _check_access('taxonomy_term_update', context, data_dict)
    model = context['model']

    id = logic.get_or_bust(data_dict, 'id')

    term = TaxonomyTerm.get(id)
    if not term:
        raise logic.NotFound()

    term.label = data_dict.get('label', term.label)
    term.parent_id = data_dict.get('parent_id', term.parent_id)
    term.uri = logic.get_or_bust(data_dict, 'uri')
    term.description = data_dict.get('description', '')
    term.extras = data_dict.get('extras', '')

    model.Session.add(term)
    model.Session.commit()

    return term.as_dict()
Example #3
0
def taxonomy_term_show(context, data_dict):
    """
    Shows a single taxonomy term and its children, the taxonomy id is not
    required, just a term_id.

    :returns: A single taxonomy term
    :rtype: A dictionary
    """
    _check_access('taxonomy_term_show', context, data_dict)
    model = context['model']

    id = data_dict.get('id')
    uri = data_dict.get('uri')

    if not id and not uri:
        raise logic.ValidationError("Either id or uri is required")

    term = TaxonomyTerm.get(id or uri)
    if not term:
        raise logic.NotFound()

    return term.as_dict()
Example #4
0
def taxonomy_term_show(context, data_dict):
    """
    Shows a single taxonomy term and its children, the taxonomy id is not
    required, just a term_id.

    :returns: A single taxonomy term
    :rtype: A dictionary
    """
    _check_access('taxonomy_term_show', context, data_dict)
    model = context['model']

    id = data_dict.get('id')
    uri = data_dict.get('uri')

    if not id and not uri:
        raise logic.ValidationError("Either id or uri is required")

    term = TaxonomyTerm.get(id or uri)
    if not term:
        raise logic.NotFound()

    return term.as_dict()