Beispiel #1
0
    def delete(self, request, project_id, version_id, resource_name, resource_id):
        validate_resource_name(resource_name)

        serializer = VentityWithTemplateSLZ(data=self.kwargs)
        serializer.is_valid(raise_exception=True)
        validated_data = serializer.validated_data

        ventity = validated_data['ventity']
        template = validated_data['template']
        self.can_edit_template(request, template)

        # 关联关系检查
        can_delete_resource(ventity, resource_name, resource_id)

        new_ventity = VersionedEntity.update_for_delete_ventity(
            ventity.id, resource_name, resource_id,
            **{'creator': self.request.user.username}
        )
        return Response({'id': resource_id, 'version': new_ventity.id})
Beispiel #2
0
    def delete(self, request, project_id, version_id, resource_name,
               resource_id):
        validate_resource_name(resource_name)

        serializer = serializers_new.VentityWithTemplateSLZ(data=self.kwargs)
        serializer.is_valid(raise_exception=True)
        validated_data = serializer.validated_data

        ventity = validated_data["ventity"]
        template = validated_data["template"]
        self.can_edit_template(request, template)

        # 关联关系检查
        serializers_new.can_delete_resource(ventity, resource_name,
                                            resource_id)

        new_ventity = VersionedEntity.update_for_delete_ventity(
            ventity.id, resource_name, resource_id,
            **{"creator": self.request.user.username})
        return Response({"id": resource_id, "version": new_ventity.id})