当前位置: 首页>>代码示例>>Python>>正文


Python sites.has_site_permission函数代码示例

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


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

示例1: _can_edit_content

 def _can_edit_content(self, request, obj):
     if isinstance(obj, Content):
         owners = obj.get_root().node.versiontracker_set.get().owners
         any_owner_in_current_site = any(current_site_id() == o.site_id for o in owners)
         return has_site_permission(request.user) and any_owner_in_current_site
     else:
         return True
开发者ID:sigmundv,项目名称:django-widgy,代码行数:7,代码来源:site.py

示例2: editable_loader

def editable_loader(context):
    """
    Set up the required JS/CSS for the in-line editing toolbar and controls.
    """
    user = context["request"].user
    context["has_site_permission"] = has_site_permission(user)
    if settings.INLINE_EDITING_ENABLED and context["has_site_permission"]:
        t = get_template("includes/editable_toolbar.html")
        context["REDIRECT_FIELD_NAME"] = REDIRECT_FIELD_NAME
        context["toolbar"] = t.render(Context(context))
        context["richtext_media"] = RichTextField().formfield().widget.media
    return context
开发者ID:dfalk,项目名称:mezzanine,代码行数:12,代码来源:mezzanine_tags.py

示例3: is_editable

def is_editable(obj, request):
    """
    Returns ``True`` if the object is editable for the request. First
    check for a custom ``editable`` handler on the object, otherwise
    use the logged in user and check change permissions for the
    object's model.
    """
    if hasattr(obj, "is_editable"):
        return obj.is_editable(request)
    else:
        perm = obj._meta.app_label + "." + obj._meta.get_change_permission()
        return (request.user.is_authenticated() and
                has_site_permission(request.user) and
                request.user.has_perm(perm))
开发者ID:AdnanHodzic,项目名称:mezzanine,代码行数:14,代码来源:views.py

示例4: editable_loader

def editable_loader(context):
    """
    Set up the required JS/CSS for the in-line editing toolbar and controls.
    """
    user = context["request"].user
    template_vars = {"has_site_permission": has_site_permission(user), "request": context["request"]}
    if settings.INLINE_EDITING_ENABLED and template_vars["has_site_permission"]:
        t = get_template("includes/editable_toolbar.html")
        template_vars["REDIRECT_FIELD_NAME"] = REDIRECT_FIELD_NAME
        template_vars["editable_obj"] = context.get("editable_obj", context.get("page", None))
        template_vars["accounts_logout_url"] = context.get("accounts_logout_url", None)
        template_vars["toolbar"] = t.render(Context(template_vars))
        template_vars["richtext_media"] = RichTextField().formfield().widget.media
    return template_vars
开发者ID:sjdines,项目名称:mezzanine,代码行数:14,代码来源:mezzanine_tags.py

示例5: is_editable

def is_editable(obj, request):
    """
    Returns ``True`` if the object is editable for the request. First
    check for a custom ``editable`` handler on the object, otherwise
    use the logged in user and check change permissions for the
    object's model.
    """
    if hasattr(obj, "is_editable"):
        return obj.is_editable(request)
    else:
        codename = get_permission_codename("change", obj._meta)
        perm = "%s.%s" % (obj._meta.app_label, codename)
        return (is_authenticated(request.user) and
                has_site_permission(request.user) and
                request.user.has_perm(perm))
开发者ID:christianwgd,项目名称:mezzanine,代码行数:15,代码来源:views.py

示例6: edit

def edit(request):
    """
    Process the inline editing form.
    """
    model = apps.get_model(request.POST["app"], request.POST["model"])
    obj = model.objects.get(id=request.POST["id"])
    form = get_edit_form(obj, request.POST["fields"], data=request.POST, files=request.FILES)
    if not (is_editable(obj, request) and has_site_permission(request.user)):
        response = _("Permission denied")
    elif form.is_valid():
        form.save()
        model_admin = ModelAdmin(model, admin.site)
        message = model_admin.construct_change_message(request, form, None)
        model_admin.log_change(request, obj, message)
        response = ""
    else:
        response = list(form.errors.values())[0][0]
    return HttpResponse(response)
开发者ID:rhizomedotorg,项目名称:mezzanine,代码行数:18,代码来源:views.py


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