def count_hidden_registrations(event, is_participant): """Get the number of hidden registrations for an event. :param event: the `Event` to get registrations for :param is_participant: whether the user accessing the registrations is a participant of the event :return: number of registrations """ query = (Registration.query.with_parent(event).filter( Registration.is_state_publishable, ~Registration.is_publishable(is_participant), RegistrationForm.is_participant_list_visible(is_participant)).join( Registration.registration_form)) return query.count()
def get_published_registrations(event, is_participant): """Get a list of published registrations for an event. :param event: the `Event` to get registrations for :param is_participant: whether the user accessing the registrations is a participant of the event :return: list of `Registration` objects """ query = (Registration.query.with_parent(event).filter( Registration.is_publishable(is_participant), ~RegistrationForm.is_deleted, ~Registration.is_deleted).join(Registration.registration_form).options( contains_eager(Registration.registration_form)).order_by( db.func.lower(Registration.first_name), db.func.lower(Registration.last_name), Registration.friendly_id)) return query.all()
def _is_publishable_query(is_participant): return Registration.query.with_parent(reg.event).filter( Registration.is_publishable(is_participant)).has_rows()