示例#1
0
    def delete(self, instance_id):
        parser = reqparse.RequestParser()
        parser.add_argument("force", default=False, type=bool)
        args = parser.parse_args()

        project = self.get_model_or_404(instance_id)
        project_dict = project.serialize()
        if projects_service.is_open(project_dict):
            return {
                "error": True,
                "message": "Only closed projects can be deleted",
            }, 400
        else:
            self.check_delete_permissions(project_dict)
            if args["force"] is True:
                deletion_service.remove_project(instance_id)
            else:
                project.delete()
            self.post_delete(project_dict)
            return "", 204
示例#2
0
 def test_is_open(self):
     self.assertTrue(projects_service.is_open(self.project.serialize()))
     self.assertFalse(
         projects_service.is_open(self.project_closed.serialize()))