• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python auth.verify_privilege函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中szurubooru.func.auth.verify_privilege函数的典型用法代码示例。如果您正苦于以下问题:Python verify_privilege函数的具体用法?Python verify_privilege怎么用?Python verify_privilege使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了verify_privilege函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: put

 def put(self, ctx, post_id):
     auth.verify_privilege(ctx.user, 'posts:score')
     post = posts.get_post_by_id(post_id)
     score = ctx.get_param_as_int('score', required=True)
     scores.set_score(post, ctx.user, score)
     ctx.session.commit()
     return posts.serialize_post_with_details(post, ctx.user)
开发者ID:hnamquoc,项目名称:szurubooru,代码行数:7,代码来源:post_api.py


示例2: put

 def put(self, ctx, user_name):
     user = users.get_user_by_name(user_name)
     infix = 'self' if ctx.user.user_id == user.user_id else 'any'
     if ctx.has_param('name'):
         auth.verify_privilege(ctx.user, 'users:edit:%s:name' % infix)
         users.update_user_name(user, ctx.get_param_as_string('name'))
     if ctx.has_param('password'):
         auth.verify_privilege(ctx.user, 'users:edit:%s:pass' % infix)
         users.update_user_password(
             user, ctx.get_param_as_string('password'))
     if ctx.has_param('email'):
         auth.verify_privilege(ctx.user, 'users:edit:%s:email' % infix)
         users.update_user_email(user, ctx.get_param_as_string('email'))
     if ctx.has_param('rank'):
         auth.verify_privilege(ctx.user, 'users:edit:%s:rank' % infix)
         users.update_user_rank(
             user, ctx.get_param_as_string('rank'), ctx.user)
     if ctx.has_param('avatarStyle'):
         auth.verify_privilege(ctx.user, 'users:edit:%s:avatar' % infix)
         users.update_user_avatar(
             user,
             ctx.get_param_as_string('avatarStyle'),
             ctx.get_file('avatar'))
     ctx.session.commit()
     return users.serialize_user_with_details(user, ctx.user)
开发者ID:hnamquoc,项目名称:szurubooru,代码行数:25,代码来源:user_api.py


示例3: delete_comment_score

def delete_comment_score(
        ctx: rest.Context, params: Dict[str, str]) -> rest.Response:
    auth.verify_privilege(ctx.user, 'comments:score')
    comment = _get_comment(params)
    scores.delete_score(comment, ctx.user)
    ctx.session.commit()
    return _serialize(ctx, comment)
开发者ID:rr-,项目名称:szurubooru,代码行数:7,代码来源:comment_api.py


示例4: delete

 def delete(self, ctx, user_name):
     user = users.get_user_by_name(user_name)
     infix = 'self' if ctx.user.user_id == user.user_id else 'any'
     auth.verify_privilege(ctx.user, 'users:delete:%s' % infix)
     ctx.session.delete(user)
     ctx.session.commit()
     return {}
开发者ID:hnamquoc,项目名称:szurubooru,代码行数:7,代码来源:user_api.py


示例5: update_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)
开发者ID:rr-,项目名称:szurubooru,代码行数:30,代码来源:tag_api.py


示例6: put

 def put(self, ctx, comment_id):
     auth.verify_privilege(ctx.user, 'comments:score')
     score = ctx.get_param_as_int('score', required=True)
     comment = comments.get_comment_by_id(comment_id)
     scores.set_score(comment, ctx.user, score)
     ctx.session.commit()
     return comments.serialize_comment_with_details(comment, ctx.user)
开发者ID:hnamquoc,项目名称:szurubooru,代码行数:7,代码来源:comment_api.py


示例7: get

 def get(self, ctx):
     auth.verify_privilege(ctx.user, 'tag_categories:list')
     categories = tag_categories.get_all_categories()
     return {
         'tagCategories': [
             _serialize_category(category) for category in categories],
     }
开发者ID:princessGasmask,项目名称:szurubooru,代码行数:7,代码来源:tag_category_api.py


示例8: delete

 def delete(self, ctx, comment_id):
     comment = comments.get_comment_by_id(comment_id)
     infix = 'self' if ctx.user.user_id == comment.user_id else 'any'
     auth.verify_privilege(ctx.user, 'comments:delete:%s' % infix)
     ctx.session.delete(comment)
     ctx.session.commit()
     return {}
开发者ID:hnamquoc,项目名称:szurubooru,代码行数:7,代码来源:comment_api.py


示例9: post

    def post(self, ctx):
        auth.verify_privilege(ctx.user, 'posts:create')
        content = ctx.get_file('content', required=True)
        tag_names = ctx.get_param_as_list('tags', required=True)
        safety = ctx.get_param_as_string('safety', required=True)
        source = ctx.get_param_as_string('source', required=False, default=None)
        if ctx.has_param('contentUrl') and not source:
            source = ctx.get_param_as_string('contentUrl')
        relations = ctx.get_param_as_list('relations', required=False) or []
        notes = ctx.get_param_as_list('notes', required=False) or []
        flags = ctx.get_param_as_list('flags', required=False) or []

        post = posts.create_post(content, tag_names, ctx.user)
        posts.update_post_safety(post, safety)
        posts.update_post_source(post, source)
        posts.update_post_relations(post, relations)
        posts.update_post_notes(post, notes)
        posts.update_post_flags(post, flags)
        if ctx.has_file('thumbnail'):
            posts.update_post_thumbnail(post, ctx.get_file('thumbnail'))
        ctx.session.add(post)
        snapshots.save_entity_creation(post, ctx.user)
        ctx.session.commit()
        tags.export_to_json()
        return posts.serialize_post_with_details(post, ctx.user)
开发者ID:hnamquoc,项目名称:szurubooru,代码行数:25,代码来源:post_api.py


示例10: get_tag_categories

def get_tag_categories(
        ctx: rest.Context, _params: Dict[str, str] = {}) -> rest.Response:
    auth.verify_privilege(ctx.user, 'tag_categories:list')
    categories = tag_categories.get_all_categories()
    return {
        'results': [_serialize(ctx, category) for category in categories],
    }
开发者ID:rr-,项目名称:szurubooru,代码行数:7,代码来源:tag_category_api.py


示例11: get_posts_around

def get_posts_around(
        ctx: rest.Context, params: Dict[str, str]) -> rest.Response:
    auth.verify_privilege(ctx.user, 'posts:list')
    _search_executor_config.user = ctx.user
    post_id = _get_post_id(params)
    return _search_executor.get_around_and_serialize(
        ctx, post_id, lambda post: _serialize_post(ctx, post))
开发者ID:rr-,项目名称:szurubooru,代码行数:7,代码来源:post_api.py


示例12: delete_post_from_favorites

def delete_post_from_favorites(
        ctx: rest.Context, params: Dict[str, str]) -> rest.Response:
    auth.verify_privilege(ctx.user, 'posts:favorite')
    post = _get_post(params)
    favorites.unset_favorite(post, ctx.user)
    ctx.session.commit()
    return _serialize_post(ctx, post)
开发者ID:rr-,项目名称:szurubooru,代码行数:7,代码来源:post_api.py


示例13: delete_post_score

def delete_post_score(
        ctx: rest.Context, params: Dict[str, str]) -> rest.Response:
    auth.verify_privilege(ctx.user, 'posts:score')
    post = _get_post(params)
    scores.delete_score(post, ctx.user)
    ctx.session.commit()
    return _serialize_post(ctx, post)
开发者ID:rr-,项目名称:szurubooru,代码行数:7,代码来源:post_api.py


示例14: put

    def put(self, ctx, user_name):
        user = users.get_user_by_name(user_name)
        if not user:
            raise users.UserNotFoundError('User %r not found.' % user_name)

        if ctx.user.user_id == user.user_id:
            infix = 'self'
        else:
            infix = 'any'

        if ctx.has_param('name'):
            auth.verify_privilege(ctx.user, 'users:edit:%s:name' % infix)
            users.update_name(user, ctx.get_param_as_string('name'), ctx.user)

        if ctx.has_param('password'):
            auth.verify_privilege(ctx.user, 'users:edit:%s:pass' % infix)
            users.update_password(user, ctx.get_param_as_string('password'))

        if ctx.has_param('email'):
            auth.verify_privilege(ctx.user, 'users:edit:%s:email' % infix)
            users.update_email(user, ctx.get_param_as_string('email'))

        if ctx.has_param('rank'):
            auth.verify_privilege(ctx.user, 'users:edit:%s:rank' % infix)
            users.update_rank(user, ctx.get_param_as_string('rank'), ctx.user)

        if ctx.has_param('avatarStyle'):
            auth.verify_privilege(ctx.user, 'users:edit:%s:avatar' % infix)
            users.update_avatar(
                user,
                ctx.get_param_as_string('avatarStyle'),
                ctx.get_file('avatar'))

        ctx.session.commit()
        return {'user': _serialize_user(ctx.user, user)}
开发者ID:princessGasmask,项目名称:szurubooru,代码行数:35,代码来源:user_api.py


示例15: delete_post

def delete_post(ctx: rest.Context, params: Dict[str, str]) -> rest.Response:
    auth.verify_privilege(ctx.user, 'posts:delete')
    post = _get_post(params)
    versions.verify_version(post, ctx)
    snapshots.delete(post, ctx.user)
    posts.delete(post)
    ctx.session.commit()
    return {}
开发者ID:rr-,项目名称:szurubooru,代码行数:8,代码来源:post_api.py


示例16: delete_comment

def delete_comment(ctx: rest.Context, params: Dict[str, str]) -> rest.Response:
    comment = _get_comment(params)
    versions.verify_version(comment, ctx)
    infix = 'own' if ctx.user.user_id == comment.user_id else 'any'
    auth.verify_privilege(ctx.user, 'comments:delete:%s' % infix)
    ctx.session.delete(comment)
    ctx.session.commit()
    return {}
开发者ID:rr-,项目名称:szurubooru,代码行数:8,代码来源:comment_api.py


示例17: delete_user

def delete_user(ctx: rest.Context, params: Dict[str, str]) -> rest.Response:
    user = users.get_user_by_name(params['user_name'])
    versions.verify_version(user, ctx)
    infix = 'self' if ctx.user.user_id == user.user_id else 'any'
    auth.verify_privilege(ctx.user, 'users:delete:%s' % infix)
    ctx.session.delete(user)
    ctx.session.commit()
    return {}
开发者ID:rr-,项目名称:szurubooru,代码行数:8,代码来源:user_api.py


示例18: delete_tag

def delete_tag(ctx: rest.Context, params: Dict[str, str]) -> rest.Response:
    tag = _get_tag(params)
    versions.verify_version(tag, ctx)
    auth.verify_privilege(ctx.user, 'tags:delete')
    snapshots.delete(tag, ctx.user)
    tags.delete(tag)
    ctx.session.commit()
    return {}
开发者ID:rr-,项目名称:szurubooru,代码行数:8,代码来源:tag_api.py


示例19: delete

 def delete(self, ctx, post_id):
     auth.verify_privilege(ctx.user, 'posts:delete')
     post = posts.get_post_by_id(post_id)
     snapshots.save_entity_deletion(post, ctx.user)
     ctx.session.delete(post)
     ctx.session.commit()
     tags.export_to_json()
     return {}
开发者ID:hnamquoc,项目名称:szurubooru,代码行数:8,代码来源:post_api.py


示例20: get_user_tokens

def get_user_tokens(
        ctx: rest.Context, params: Dict[str, str] = {}) -> rest.Response:
    user = users.get_user_by_name(params['user_name'])
    infix = 'self' if ctx.user.user_id == user.user_id else 'any'
    auth.verify_privilege(ctx.user, 'user_tokens:list:%s' % infix)
    user_token_list = user_tokens.get_user_tokens(user)
    return {
        'results': [_serialize(ctx, token) for token in user_token_list]
    }
开发者ID:rr-,项目名称:szurubooru,代码行数:9,代码来源:user_token_api.py



注:本文中的szurubooru.func.auth.verify_privilege函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python t.eq函数代码示例发布时间:2022-05-27
下一篇:
Python systray.Systray类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap