Example #1
0
    def lock(self, request, **kwargs):
        obj = self.get_object()

        if request.method == "POST":
            if not request.user.has_perm("component.lock", obj):
                raise PermissionDenied()

            serializer = LockRequestSerializer(data=request.data)
            serializer.is_valid(raise_exception=True)

            obj.do_lock(request.user, serializer.validated_data["lock"])

        return Response(data=LockSerializer(obj).data)
Example #2
0
    def lock(self, request, **kwargs):
        obj = self.get_object()

        if request.method == 'POST':
            if not can_lock_subproject(request.user, obj.project):
                raise PermissionDenied()

            serializer = LockRequestSerializer(data=request.data)
            serializer.is_valid(raise_exception=True)

            obj.do_lock(request.user, serializer.validated_data['lock'])

        return Response(data=LockSerializer(obj).data)
Example #3
0
    def lock(self, request, **kwargs):
        obj = self.get_object()

        if request.method == 'POST':
            if not request.user.has_perm('component.lock', obj):
                raise PermissionDenied()

            serializer = LockRequestSerializer(data=request.data)
            serializer.is_valid(raise_exception=True)

            obj.do_lock(request.user, serializer.validated_data['lock'])

        return Response(data=LockSerializer(obj).data)
Example #4
0
    def lock(self, request, **kwargs):
        obj = self.get_object()

        if request.method == 'POST':
            if not can_lock_subproject(request.user, obj.project):
                raise PermissionDenied()

            serializer = LockRequestSerializer(data=request.data)
            serializer.is_valid(raise_exception=True)

            if serializer.validated_data['lock']:
                obj.do_lock(request.user)
            else:
                obj.do_unlock(request.user)

        return Response(data=LockSerializer(obj).data)