コード例 #1
0
ファイル: api.py プロジェクト: ka7eh/taiga-back
    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
0
ファイル: api.py プロジェクト: sfrias/taiga-back
    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
コード例 #3
0
ファイル: api.py プロジェクト: bootinge/taiga-back
    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
コード例 #4
0
ファイル: api.py プロジェクト: osule/taiga-back
    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
コード例 #5
0
ファイル: api.py プロジェクト: bootinge/taiga-back
    def get_serializer_class(self):
        if self.action == "list":
            return self.list_serializer_class
        elif self.action == "create":
            return self.serializer_class

        if self.action == "by_slug":
            slug = self.request.QUERY_PARAMS.get("slug", None)
            project = get_object_or_404(models.Project, slug=slug)
        else:
            project = self.get_object()

        if permissions_service.is_project_owner(self.request.user, project):
            return self.admin_serializer_class

        return self.serializer_class
コード例 #6
0
ファイル: api.py プロジェクト: osule/taiga-back
    def get_serializer_class(self):
        if self.action == "list":
            return self.list_serializer_class
        elif self.action == "create":
            return self.serializer_class

        if self.action == "by_slug":
            slug = self.request.QUERY_PARAMS.get("slug", None)
            project = get_object_or_404(models.Project, slug=slug)
        else:
            project = self.get_object()

        if permissions_service.is_project_owner(self.request.user, project):
            return self.admin_serializer_class

        return self.serializer_class
コード例 #7
0
ファイル: serializers.py プロジェクト: Sheshtawy/taiga-back
 def get_i_am_owner(self, obj):
     if "request" in self.context:
         return is_project_owner(self.context["request"].user, obj)
     return False
コード例 #8
0
ファイル: serializers.py プロジェクト: laomouzi/taiga-back
 def get_i_am_owner(self, obj):
     if "request" in self.context:
         return is_project_owner(self.context["request"].user, obj)
     return False
コード例 #9
0
 def check_permissions(self, request, view, obj=None):
     return is_project_owner(request.user, obj)
コード例 #10
0
 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)
コード例 #11
0
ファイル: permissions.py プロジェクト: testmana2/taiga-back
 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)
コード例 #12
0
ファイル: permissions.py プロジェクト: cubettech/taiga-back
 def check_permissions(self, request, view, obj=None):
     return is_project_owner(request.user, obj.webhook.project)