def update_tag(ctx: rest.Context, params: Dict[str, str]) -> rest.Response: tag = _get_tag(params) versions.verify_version(tag, ctx) versions.bump_version(tag) if ctx.has_param('names'): auth.verify_privilege(ctx.user, 'tags:edit:names') tags.update_tag_names(tag, ctx.get_param_as_string_list('names')) if ctx.has_param('category'): auth.verify_privilege(ctx.user, 'tags:edit:category') tags.update_tag_category_name( tag, ctx.get_param_as_string('category')) if ctx.has_param('description'): auth.verify_privilege(ctx.user, 'tags:edit:description') tags.update_tag_description( tag, ctx.get_param_as_string('description')) if ctx.has_param('suggestions'): auth.verify_privilege(ctx.user, 'tags:edit:suggestions') suggestions = ctx.get_param_as_string_list('suggestions') _create_if_needed(suggestions, ctx.user) tags.update_tag_suggestions(tag, suggestions) if ctx.has_param('implications'): auth.verify_privilege(ctx.user, 'tags:edit:implications') implications = ctx.get_param_as_string_list('implications') _create_if_needed(implications, ctx.user) tags.update_tag_implications(tag, implications) tag.last_edit_time = datetime.utcnow() ctx.session.flush() snapshots.modify(tag, ctx.user) ctx.session.commit() return _serialize(ctx, tag)
def update_tag(ctx, params): tag = tags.get_tag_by_name(params['tag_name']) versions.verify_version(tag, ctx) versions.bump_version(tag) if ctx.has_param('names'): auth.verify_privilege(ctx.user, 'tags:edit:names') tags.update_tag_names(tag, ctx.get_param_as_list('names')) if ctx.has_param('category'): auth.verify_privilege(ctx.user, 'tags:edit:category') tags.update_tag_category_name( tag, ctx.get_param_as_string('category')) if ctx.has_param('description'): auth.verify_privilege(ctx.user, 'tags:edit:description') tags.update_tag_description( tag, ctx.get_param_as_string('description', default=None)) if ctx.has_param('suggestions'): auth.verify_privilege(ctx.user, 'tags:edit:suggestions') suggestions = ctx.get_param_as_list('suggestions') _create_if_needed(suggestions, ctx.user) tags.update_tag_suggestions(tag, suggestions) if ctx.has_param('implications'): auth.verify_privilege(ctx.user, 'tags:edit:implications') implications = ctx.get_param_as_list('implications') _create_if_needed(implications, ctx.user) tags.update_tag_implications(tag, implications) tag.last_edit_time = datetime.datetime.utcnow() ctx.session.flush() snapshots.modify(tag, ctx.user) ctx.session.commit() tags.export_to_json() return _serialize(ctx, tag)
def update_tag(ctx: rest.Context, params: Dict[str, str]) -> rest.Response: tag = _get_tag(params) versions.verify_version(tag, ctx) versions.bump_version(tag) if ctx.has_param("names"): auth.verify_privilege(ctx.user, "tags:edit:names") tags.update_tag_names(tag, ctx.get_param_as_string_list("names")) if ctx.has_param("category"): auth.verify_privilege(ctx.user, "tags:edit:category") tags.update_tag_category_name(tag, ctx.get_param_as_string("category")) if ctx.has_param("description"): auth.verify_privilege(ctx.user, "tags:edit:description") tags.update_tag_description(tag, ctx.get_param_as_string("description")) if ctx.has_param("suggestions"): auth.verify_privilege(ctx.user, "tags:edit:suggestions") suggestions = ctx.get_param_as_string_list("suggestions") _create_if_needed(suggestions, ctx.user) tags.update_tag_suggestions(tag, suggestions) if ctx.has_param("implications"): auth.verify_privilege(ctx.user, "tags:edit:implications") implications = ctx.get_param_as_string_list("implications") _create_if_needed(implications, ctx.user) tags.update_tag_implications(tag, implications) tag.last_edit_time = datetime.utcnow() ctx.session.flush() snapshots.modify(tag, ctx.user) ctx.session.commit() return _serialize(ctx, tag)
def create_tag( ctx: rest.Context, _params: Dict[str, str] = {}) -> rest.Response: auth.verify_privilege(ctx.user, 'tags:create') names = ctx.get_param_as_string_list('names') category = ctx.get_param_as_string('category') description = ctx.get_param_as_string('description', default='') suggestions = ctx.get_param_as_string_list('suggestions', default=[]) implications = ctx.get_param_as_string_list('implications', default=[]) _create_if_needed(suggestions, ctx.user) _create_if_needed(implications, ctx.user) tag = tags.create_tag(names, category, suggestions, implications) tags.update_tag_description(tag, description) ctx.session.add(tag) ctx.session.flush() snapshots.create(tag, ctx.user) ctx.session.commit() return _serialize(ctx, tag)
def create_tag(ctx: rest.Context, _params: Dict[str, str] = {}) -> rest.Response: auth.verify_privilege(ctx.user, "tags:create") names = ctx.get_param_as_string_list("names") category = ctx.get_param_as_string("category") description = ctx.get_param_as_string("description", default="") suggestions = ctx.get_param_as_string_list("suggestions", default=[]) implications = ctx.get_param_as_string_list("implications", default=[]) _create_if_needed(suggestions, ctx.user) _create_if_needed(implications, ctx.user) tag = tags.create_tag(names, category, suggestions, implications) tags.update_tag_description(tag, description) ctx.session.add(tag) ctx.session.flush() snapshots.create(tag, ctx.user) ctx.session.commit() return _serialize(ctx, tag)
def create_tag(ctx: rest.Context, _params: Dict[str, str] = {}) -> rest.Response: auth.verify_privilege(ctx.user, 'tags:create') names = ctx.get_param_as_string_list('names') category = ctx.get_param_as_string('category') description = ctx.get_param_as_string('description', default='') suggestions = ctx.get_param_as_string_list('suggestions', default=[]) implications = ctx.get_param_as_string_list('implications', default=[]) _create_if_needed(suggestions, ctx.user) _create_if_needed(implications, ctx.user) tag = tags.create_tag(names, category, suggestions, implications) tags.update_tag_description(tag, description) ctx.session.add(tag) ctx.session.flush() snapshots.create(tag, ctx.user) ctx.session.commit() tags.export_to_json() return _serialize(ctx, tag)
def create_tag(ctx, _params=None): auth.verify_privilege(ctx.user, 'tags:create') names = ctx.get_param_as_list('names', required=True) category = ctx.get_param_as_string('category', required=True) description = ctx.get_param_as_string( 'description', required=False, default=None) suggestions = ctx.get_param_as_list( 'suggestions', required=False, default=[]) implications = ctx.get_param_as_list( 'implications', required=False, default=[]) _create_if_needed(suggestions, ctx.user) _create_if_needed(implications, ctx.user) tag = tags.create_tag(names, category, suggestions, implications) tags.update_tag_description(tag, description) ctx.session.add(tag) ctx.session.flush() snapshots.create(tag, ctx.user) ctx.session.commit() tags.export_to_json() return _serialize(ctx, tag)
def test_update_tag_description(tag_factory): tag = tag_factory() tags.update_tag_description(tag, 'test') assert tag.description == 'test'