def generate_fixture_milestone(self): self.milestone = Milestone.create( name="Test Milestone", project_id=self.project.id, task_type_id=self.task_type.id, ) return self.milestone.serialize()
def remove_project(project_id): from zou.app.services import playlists_service tasks = Task.query.filter_by(project_id=project_id) for task in tasks: remove_task(task.id, force=True) query = EntityLink.query.join(Entity, EntityLink.entity_in_id == Entity.id).filter( Entity.project_id == project_id) for link in query: link.delete_no_commit() EntityLink.commit() query = EntityVersion.query.join( Entity, EntityVersion.entity_id == Entity.id).filter( Entity.project_id == project_id) for version in query: version.delete_no_commit() EntityLink.commit() playlists = Playlist.query.filter_by(project_id=project_id) for playlist in playlists: playlists_service.remove_playlist(playlist.id) ApiEvent.delete_all_by(project_id=project_id) Entity.delete_all_by(project_id=project_id) MetadataDescriptor.delete_all_by(project_id=project_id) Milestone.delete_all_by(project_id=project_id) ScheduleItem.delete_all_by(project_id=project_id) SearchFilter.delete_all_by(project_id=project_id) for news in News.query.join(Task).filter_by(project_id=project_id).all(): news.delete_no_commit() News.commit() project = Project.get(project_id) project.delete() events.emit("project:delete", {"project_id": project.id}) return project_id