def get(self, class_id=None, page=None, per_page=None): if (request.args.get("page") and request.args.get("per_page") and request.args.get("username")): page = int(request.args.get("page")) class_id = request.args.get("username") per_page = int(request.args.get("per_page")) list_class = ClasssModel.find_list_by_name(class_id, page, per_page) if list_class is None: return {"messages": err_404.format("list_class")}, 404 return ( { "list": ClasssModel.to_json(list_class), "count ": len(list_class) }, 200, ) if class_id is None: list = ClasssModel.to_json( ClasssModel.query.paginate(page, per_page, False).items) return {"list": list, "count": len(ClasssModel.query.all())}, 200 classs = ClasssModel.find_by_class_id(class_id) if classs is None: return {"messages": err_404.format("class")}, 404 return classs.json(), 200
def get(self, class_id=None, page=None, per_page=None): if (request.args.get("page") and request.args.get("per_page") and request.args.get("class_id")): page = int(request.args.get("page")) class_id = request.args.get("class_id") per_page = int(request.args.get("per_page")) list_class = Subject_And_ClassModel.find_list_by_class_id( class_id, page, per_page) if list_class is None: return {"messages": err_404.format("list_class")}, 404 return ( { "list": ClasssModel.to_json(list_class), "count ": len(list_class) }, 200, ) if class_id is None: list = [] for row in Subject_And_ClassModel.query.paginate( page, per_page, False).items: list.append(row.json()) return { "list": list, "count": len(Subject_And_ClassModel.query.all()) }, 200 if Subject_And_ClassModel.find_by_class_id(class_id): list2 = [] for row in Subject_And_ClassModel.find_by_class_id(class_id): list2.append(row.json()) return {"danh sách lớp": list2}, 200 return {"messages": err_404.format("class")}, 404