def magazines_mid_posts_id_update(mid, id): try: magazine_post = MagazinePost.get(MagazinePost.id == id) except MagazinePost.DoesNotExist: return error('magazine_post does not exist', 404) json_data = request.get_json() user_id = current_user.id magazine_id = mid post_id = id title = json_data.get('title') desc = json_data.get('desc') cover = json_data.get('cover') category = json_data.get('category') category_icon = json_data.get('category_icon') if not all( (magazine_id, post_id, title, desc, cover, category, category_icon)): return error('没有提供所有参数') magazine_post.update_magazine_post(user_id=user_id, magazine_id=magazine_id, post_id=post_id, title=title, desc=desc, cover=cover, category=category, category_icon=category_icon) return ok()
def magazines_mid_posts_id_update(mid, id): try: magazine_post = MagazinePost.get(MagazinePost.id == id) except MagazinePost.DoesNotExist: return error('magazine_post does not exist', 404) json_data = request.get_json() user_id = current_user.id magazine_id = mid post_id = id title = json_data.get('title') desc = json_data.get('desc') cover = json_data.get('cover') category = json_data.get('category') category_icon = json_data.get('category_icon') if not all((magazine_id, post_id, title, desc, cover, category, category_icon)): return error('没有提供所有参数') magazine_post.update_magazine_post( user_id=user_id, magazine_id=magazine_id, post_id=post_id, title=title, desc=desc, cover=cover, category=category, category_icon=category_icon) return ok()
def magazines_mid_posts_id_delete(mid, id): try: magazine_post = MagazinePost.get(MagazinePost.id == id) except MagazinePost.DoesNotExist: return error('magazine_post does not exist', 404) magazine_post.delete_instance() return ok()
def magazines_mid_posts_id(mid, id): try: magazine_post = MagazinePost.get(MagazinePost.id == id) except MagazinePost.DoesNotExist: return error('magazine_post does not exist', 404) return ok(dump_magazine_post(magazine_post))