本文整理汇总了Python中taiga.permissions.service.is_project_owner函数的典型用法代码示例。如果您正苦于以下问题:Python is_project_owner函数的具体用法?Python is_project_owner怎么用?Python is_project_owner使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_project_owner函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_serializer_class
def get_serializer_class(self):
use_admin_serializer = False
if self.action == "create":
use_admin_serializer = True
if self.action == "retrieve":
use_admin_serializer = permissions_service.is_project_owner(self.request.user, self.object.project)
project_id = self.request.QUERY_PARAMS.get("project", None)
if self.action == "list" and project_id is not None:
project = get_object_or_404(models.Project, pk=project_id)
use_admin_serializer = permissions_service.is_project_owner(self.request.user, project)
if use_admin_serializer:
return self.admin_serializer_class
else:
return self.serializer_class
示例2: get_serializer_class
def get_serializer_class(self):
project_id = self.request.QUERY_PARAMS.get("project", None)
if project_id is None:
# Creation
if self.request.method == 'POST':
return self.admin_serializer_class
return self.serializer_class
project = get_object_or_404(models.Project, pk=project_id)
if permissions_service.is_project_owner(self.request.user, project):
return self.admin_serializer_class
return self.serializer_class
示例3: get_i_am_owner
def get_i_am_owner(self, obj):
if "request" in self.context:
return is_project_owner(self.context["request"].user, obj)
return False
示例4: check_permissions
def check_permissions(self, request, view, obj=None):
model = get_model_from_key(obj.key)
pk = get_pk_from_key(obj.key)
project = model.objects.get(pk=pk)
return is_project_owner(request.user, project)
示例5: check_permissions
def check_permissions(self, request, view, obj=None):
return is_project_owner(request.user, obj.webhook.project)