Exemple #1
0
    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
Exemple #2
0
    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
Exemple #3
0
    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
Exemple #4
0
    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
Exemple #5
0
    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
Exemple #6
0
    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
Exemple #7
0
 def get_i_am_owner(self, obj):
     if "request" in self.context:
         return is_project_owner(self.context["request"].user, obj)
     return False
Exemple #8
0
 def get_i_am_owner(self, obj):
     if "request" in self.context:
         return is_project_owner(self.context["request"].user, obj)
     return False
Exemple #9
0
 def check_permissions(self, request, view, obj=None):
     return is_project_owner(request.user, obj)
 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)
Exemple #11
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)
Exemple #12
0
 def check_permissions(self, request, view, obj=None):
     return is_project_owner(request.user, obj.webhook.project)