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


Python ProjectPermission.private方法代码示例

本文整理汇总了Python中transifex.projects.permissions.project.ProjectPermission.private方法的典型用法代码示例。如果您正苦于以下问题:Python ProjectPermission.private方法的具体用法?Python ProjectPermission.private怎么用?Python ProjectPermission.private使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在transifex.projects.permissions.project.ProjectPermission的用法示例。


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

示例1: _has_perm

# 需要导入模块: from transifex.projects.permissions.project import ProjectPermission [as 别名]
# 或者: from transifex.projects.permissions.project.ProjectPermission import private [as 别名]
 def _has_perm(self, user, project):
     """
     Check that the user has access to this resource.
     """
     perm = ProjectPermission(user)
     if not perm.private(project):
         return False
     return True
开发者ID:tymofij,项目名称:adofex,代码行数:10,代码来源:__init__.py

示例2: tab_suggestions_snippet

# 需要导入模块: from transifex.projects.permissions.project import ProjectPermission [as 别名]
# 或者: from transifex.projects.permissions.project.ProjectPermission import private [as 别名]
def tab_suggestions_snippet(request, entity_id, lang_code):
    """Return a template snippet with entity & translation details."""

    source_entity = get_object_or_404(SourceEntity, pk=entity_id)

    check = ProjectPermission(request.user)
    if not check.private(source_entity.resource.project):
        return permission_denied(request)

    current_translation = source_entity.get_translation(lang_code)

    return render_to_response("tab_suggestions_snippet.html", {
        'source_entity': source_entity,
        'lang_code': lang_code,
        'current_translation': current_translation
        },
    context_instance = RequestContext(request))
开发者ID:rvanlaar,项目名称:easy-transifex,代码行数:19,代码来源:views.py

示例3: tab_details_snippet

# 需要导入模块: from transifex.projects.permissions.project import ProjectPermission [as 别名]
# 或者: from transifex.projects.permissions.project.ProjectPermission import private [as 别名]
def tab_details_snippet(request, entity_id, lang_code):
    """Return a template snippet with entity & translation details."""

    source_entity = get_object_or_404(SourceEntity, pk=entity_id)

    check = ProjectPermission(request.user)
    if not check.private(source_entity.resource.project):
        return permission_denied(request)

    language = get_object_or_404(Language, code=lang_code)
    translation = source_entity.get_translation(language.code)

    return list_detail.object_detail(request,
        queryset=SourceEntity.objects.all(),
        object_id=entity_id,
        template_name="tab_details_snippet.html",
        template_object_name='source_entity',
        extra_context={"translation": translation,
            "project": source_entity.resource.project})
开发者ID:rvanlaar,项目名称:easy-transifex,代码行数:21,代码来源:views.py

示例4: _read

# 需要导入模块: from transifex.projects.permissions.project import ProjectPermission [as 别名]
# 或者: from transifex.projects.permissions.project.ProjectPermission import private [as 别名]
 def _read(self, request, project_slug):
     """
     Return a list of projects or the details for a specific project.
     """
     if project_slug is None:
         # Use pagination
         p = Project.objects.for_user(request.user)
         res, msg = paginate(p, request.GET.get("start"), request.GET.get("end"))
         if res is None:
             return BAD_REQUEST(msg)
         return res
     else:
         try:
             p = Project.objects.get(slug=project_slug)
             perm = ProjectPermission(request.user)
             if not perm.private(p):
                 return rc.FORBIDDEN
         except Project.DoesNotExist:
             return rc.NOT_FOUND
         return p
开发者ID:hfeeki,项目名称:transifex,代码行数:22,代码来源:api.py

示例5: suggestion_vote

# 需要导入模块: from transifex.projects.permissions.project import ProjectPermission [as 别名]
# 或者: from transifex.projects.permissions.project.ProjectPermission import private [as 别名]
def suggestion_vote(request, entity_id, lang_code, suggestion_id, direction):
    
    """Vote up or down for a suggestion."""

    suggestion = get_object_or_404(Suggestion, pk=suggestion_id)

    # Permissions handling
    check = ProjectPermission(request.user)
    if not check.private(suggestion.source_entity.resource.project):
        return permission_denied(request)

    #FIXME: All basic POST checks could be done in a decorator.
    if not request.method == "POST":
        return HttpResponseBadRequest(_("POST method only allowed."))

    if direction == 'up':
        suggestion.vote_up(request.user)
    elif direction == 'down':
        suggestion.vote_down(request.user)

    return HttpResponse(status=200)
开发者ID:593in,项目名称:transifex,代码行数:23,代码来源:views.py

示例6: suggestion_create

# 需要导入模块: from transifex.projects.permissions.project import ProjectPermission [as 别名]
# 或者: from transifex.projects.permissions.project.ProjectPermission import private [as 别名]
def suggestion_create(request, entity_id, lang_code):
    """Create a suggestion for an entity and a language."""

    source_entity = get_object_or_404(SourceEntity, pk=entity_id)

    # Permissions handling
    check = ProjectPermission(request.user)
    if not check.private(source_entity.resource.project):
        return permission_denied(request)

    #FIXME: All basic POST checks could be done in a decorator.
    if not request.method == "POST":
        return HttpResponseBadRequest(_("POST method only allowed."))
    suggestion_string = request.POST['suggestion_string']
    if not suggestion_string:
        return HttpResponseBadRequest(_("POST variable 'suggestion_string' missing."))

    language = Language.objects.by_code_or_alias(lang_code)
    source_entity.suggestions.create(language=language,
                                     string=request.POST['suggestion_string'],
                                     user=request.user)
    return HttpResponse(status=200)
开发者ID:593in,项目名称:transifex,代码行数:24,代码来源:views.py


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