def admin_get_pars(page_num: int) -> dict: session = db_session.create_session() query = session.query(History) page = SqlalchemyOrmPage(query, page=page_num, items_per_page=10) pars = sorted(page.items, key=lambda x: x.id, reverse=True) max_page = query.count() // 10 + 1 session.close() return {'pars': pars, 'max': max_page}
def admin_get_users(page_num: int) -> dict: session = db_session.create_session() query = session.query(User).filter(User.is_approved == True) page = SqlalchemyOrmPage(query, page=page_num, items_per_page=10) users = sorted(page.items, key=lambda x: x.id, reverse=True) max_page = query.count() // 10 + 1 for user in users: auth = user.auth user.auth = auth session.close() return {'users': users, 'max': max_page}
def admin_get_reg(page_num: int) -> dict: session = db_session.create_session() query = session.query(Applications) page = SqlalchemyOrmPage(query, page=page_num, items_per_page=10) users = sorted(page.items, key=lambda x: x.date) for application in users: user = application.user auth = user.auth user.auth = auth application.user = user max_page = query.count() // 10 + 1 session.close() return {'users': users, 'max': max_page}