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)
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)
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)
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)