def get_events_for_bloc(bloc_uid, page, per_page): bloc = Bloc.get(uid=bloc_uid) if bloc is None: raise errors.ResourceNotFound('Bloc not found') events_query = Event.query_for_active(bloc_id=bloc.id, _desc=True) page = prep_paginate_query(events_query, page=page, per_page=per_page) meta = get_pagination_meta(page) return page.items, meta
def get_bloc_projects(bloc_uid, page, per_page): bloc = Bloc.get(uid=bloc_uid) if bloc is None: raise errors.ResourceNotFound projects = Project.query_for_active(bloc_id=bloc.id, _desc=True) page = prep_paginate_query(projects, page=page, per_page=per_page) meta = get_pagination_meta(page) return page.items, meta
def get_jobs_for_bloc(bloc_uid, page, per_page): bloc = Bloc.get(uid=bloc_uid) if bloc is None: raise errors.ResourceNotFound('Bloc not found') jobs_query = Job.query_for_active(bloc_id=bloc.id).order(bloc.id.desc()) page = prep_paginate_query(jobs_query, page=page, per_page=per_page) meta = get_pagination_meta(page) return page.items, meta
def get_bloc_members(bloc_uid, page, per_page): bloc = Bloc.get(uid=bloc_uid) if bloc is None: raise errors.ResourceNotFound bloc_memberships = BlocMembership.query.filter_by(bloc_id=bloc.id) paginated_query = prep_paginate_query( bloc_memberships, page=page, per_page=per_page) meta = get_pagination_meta(paginated_query) return page.items, meta
def render_all_project_likes(project_id): project_likes = ProjectLike.query.filter_by(project_id=project_id) project_likes = prep_paginate_query(project_likes, **get_request_pagination_params()) return render_template('users_list.html', title='People that also liked it', users=[ project_like.created_by.as_json() for project_like in project_likes.items ])
def render_all_event_interests(event_id): event_interests = EventInterest.query.filter_by(event_id=event_id) page = (prep_paginate_query(event_interests, **get_request_pagination_params())) meta = get_pagination_meta(page) users = [event_interest.user.as_json() for event_interest in page.items] return render_template('users_list.html', title='People also interested', users=users, meta=meta)
def render_all_course_students(course_id): course_students = Course.query.filter_by(course_id=course_id) page = (prep_paginate_query(course_students, **get_request_pagination_params())) meta = get_pagination_meta(page) users = [course_student.user.as_json() for course_student in page.items] return render_template('users_list.html', title='People also take this', users=users, meta=meta)