def tag_create(context, tag_dict): """Create a new tag and return a dictionary representation of it.""" model = context["model"] check_access("tag_create", context, tag_dict) schema = context.get("schema") or ckan.logic.schema.default_create_tag_schema() data, errors = validate(tag_dict, schema, context) if errors: raise ValidationError(errors) tag = model_save.tag_dict_save(tag_dict, context) if not context.get("defer_commit"): model.repo.commit() log.debug("Created tag '%s' " % tag) return model_dictize.tag_dictize(tag, context)
def tag_create(context, tag_dict): '''Create a new tag and return a dictionary representation of it.''' model = context['model'] check_access('tag_create', context, tag_dict) schema = context.get('schema') or default_create_tag_schema() data, errors = validate(tag_dict, schema, context) if errors: raise ValidationError(errors) tag = tag_dict_save(tag_dict, context) if not context.get('defer_commit'): model.repo.commit() log.debug("Created tag '%s' " % tag) return tag_dictize(tag, context)
def tag_create(context, tag_dict): '''Create a new tag and return a dictionary representation of it.''' model = context['model'] check_access('tag_create', context, tag_dict) schema = context.get( 'schema') or ckan.logic.schema.default_create_tag_schema() data, errors = validate(tag_dict, schema, context) if errors: raise ValidationError(errors) tag = model_save.tag_dict_save(tag_dict, context) if not context.get('defer_commit'): model.repo.commit() log.debug("Created tag '%s' " % tag) return model_dictize.tag_dictize(tag, context)
def tag_create(context, data_dict): '''Create a new vocabulary tag. You must be a sysadmin to create vocabulary tags. You can only use this function to create tags that belong to a vocabulary, not to create free tags. (To create a new free tag simply add the tag to a package, e.g. using the :py:func:`~ckan.logic.action.update.package_update` function.) :param name: the name for the new tag, a string between 2 and 100 characters long containing only alphanumeric characters and ``-``, ``_`` and ``.``, e.g. ``'Jazz'`` :type name: string :param vocabulary_id: the name or id of the vocabulary that the new tag should be added to, e.g. ``'Genre'`` :type vocabulary_id: string :returns: the newly-created tag :rtype: dictionary ''' model = context['model'] _check_access('tag_create', context, data_dict) schema = context.get('schema') or \ ckan.logic.schema.default_create_tag_schema() data, errors = _validate(data_dict, schema, context) if errors: raise ValidationError(errors) tag = model_save.tag_dict_save(data_dict, context) if not context.get('defer_commit'): model.repo.commit() log.debug("Created tag '%s' " % tag) return model_dictize.tag_dictize(tag, context)
def tag_create(context, data_dict): '''Create a new vocabulary tag. You must be a sysadmin to create vocabulary tags. You can only use this function to create tags that belong to a vocabulary, not to create free tags. (To create a new free tag simply add the tag to a package, e.g. using the :py:func:`~ckan.logic.action.update.package_update` function.) :param name: the name for the new tag, a string between 2 and 100 characters long containing only alphanumeric characters and ``-``, ``_`` and ``.``, e.g. ``'Jazz'`` :type name: string :param vocabulary_id: the name or id of the vocabulary that the new tag should be added to, e.g. ``'Genre'`` :type vocabulary_id: string :returns: the newly-created tag :rtype: dictionary ''' model = context['model'] _check_access('tag_create', context, data_dict) schema = context.get('schema') or \ ckan.logic.schema.default_create_tag_schema() data, errors = _validate(data_dict, schema, context) if errors: raise ValidationError(errors) tag = model_save.tag_dict_save(data_dict, context) if not context.get('defer_commit'): model.repo.commit() log.debug("Created tag '%s' " % tag) return model_dictize.tag_dictize(tag, context)