def delete_projects(projects_id): from models import db try: a_projects = db.Project.find_one({'_id': ObjectId(projects_id)}) image_url = a_projects.get('image') image_key = image_url.split('/')[-1] delete_image_from_bucket(image_key) db.Project.collection.remove({'_id': ObjectId(projects_id)}) update_rank_reverse(a_projects['rank']) except Exception as exp: return {'fail_msg': 'Unable to delete the projects item with that id'}, 404 return {'pass_msg': 'successfully deleted'}, 204
def delete_image(image_url): image_key = image_url.split('/')[-1] delete_image_from_bucket(image_key) return True