def __init__(self, template, config, event, registration_ids): super(RegistrantsListToBadgesPDF, self).__init__(template, config) self.event = event self.registrations = (Registration.find( Registration.id.in_(registration_ids), Registration.is_active, Registration.event_new == event).order_by( *Registration.order_by_name).all())
def _process(self): regforms = RegistrationForm.find_all( RegistrationForm.publish_registrations_enabled, event_id=int(self.event.id)) query = (Registration.find( Registration.event_id == self.event.id, RegistrationForm.publish_registrations_enabled, ~RegistrationForm.is_deleted, ~Registration.is_deleted, _join=Registration.registration_form).order_by( db.func.lower(Registration.last_name), db.func.lower(Registration.first_name))) registrations = [(reg.get_full_name(), reg.get_personal_data()) for reg in query] enabled_pd_fields = { field.personal_data_type for reg in regforms for field in reg.active_fields } affiliation_enabled = PersonalDataType.affiliation in enabled_pd_fields position_enabled = PersonalDataType.position in enabled_pd_fields published = bool( RegistrationForm.find( RegistrationForm.publish_registrations_enabled, RegistrationForm.event_id == int(self.event.id)).count()) return self.view_class.render_template( 'display/participant_list.html', self.event, event=self.event, regforms=regforms, show_affiliation=affiliation_enabled and any(pd.get('affiliation') for reg, pd in registrations), show_position=position_enabled and any(pd.get('position') for reg, pd in registrations), registrations=registrations, published=published)
def _associate_registrations(user, **kwargs): from indico.modules.events.registration.models.registrations import Registration reg_alias = db.aliased(Registration) subquery = db.session.query(reg_alias).filter( reg_alias.user_id == user.id, reg_alias.registration_form_id == Registration.registration_form_id, ~reg_alias.is_deleted) registrations = ( Registration.find( Registration.user_id == None, # noqa Registration.email.in_(user.all_emails), ~subquery.exists(), ~Registration.is_deleted).order_by( Registration.submitted_dt.desc()).all()) if not registrations: return done = set() for registration in registrations: if registration.registration_form_id in done: continue logger.info('Associating %s with %s', registration, user) registration.user = user done.add(registration.registration_form_id) db.session.flush() num = len(done) flash( ngettext("A registration has been linked to your account.", "{n} registrations have been linked to your account.", num).format(n=num), 'info')
def get_registrations_with_tickets(user, event): return Registration.find(Registration.user == user, Registration.state == RegistrationState.complete, RegistrationForm.event_id == event.id, RegistrationForm.tickets_enabled, RegistrationForm.ticket_on_event_page, ~RegistrationForm.is_deleted, ~Registration.is_deleted, _join=Registration.registration_form).all()
def _checkParams(self, params): RHManageRegFormBase._checkParams(self, params) ids = set(request.form.getlist("registration_id")) self.registrations = ( Registration.find(Registration.id.in_(ids), ~Registration.is_deleted) .with_parent(self.regform) .order_by(*Registration.order_by_name) .all() )
def validate_email(self, field): if RegistrationInvitation.find(email=field.data).with_parent( self.regform).count(): raise ValidationError( _("There is already an invitation with this email address.")) if Registration.find(email=field.data, is_active=True).with_parent(self.regform).count(): raise ValidationError( _("There is already a registration with this email address."))
def _checkParams(self, params): RHManageRegFormBase._checkParams(self, params) self.registration = (Registration.find( Registration.id == request.view_args['registration_id'], ~Registration.is_deleted, ~RegistrationForm.is_deleted).join( Registration.registration_form).options( contains_eager(Registration.registration_form). defaultload('form_items').joinedload('children')).options( defaultload( Registration.data).joinedload('field_data')).one())
def _visible_registration(event): if not event.has_feature('registration'): return False if RegistrationForm.find(RegistrationForm.is_scheduled, RegistrationForm.event_id == int(event.id)).count(): return True if not session.user: return False return bool(Registration.find(Registration.user == session.user, Registration.event_id == int(event.id), ~Registration.is_deleted, ~RegistrationForm.is_deleted, _join=Registration.registration_form).count())
def user_registered_in_event(user, event): """ Check whether there is a `Registration` entry for a user in any form tied to a particular event. :param user: the `User` object :param event: the event in question """ return bool( Registration.find(Registration.user == user, RegistrationForm.event_id == int(event.id), ~RegistrationForm.is_deleted, Registration.is_active).join( Registration.registration_form).count())
def _visible_registration(event): if not event.has_feature('registration'): return False if RegistrationForm.find(RegistrationForm.is_scheduled, RegistrationForm.event_id == int( event.id)).count(): return True if not session.user: return False return bool( Registration.find(Registration.user == session.user, Registration.event_id == int(event.id), ~Registration.is_deleted, ~RegistrationForm.is_deleted, _join=Registration.registration_form).count())
def get_published_registrations(event): """Get a list of published registrations for an event. :param event: the `Event` to get registrations for :return: list of `Registration` objects """ return (Registration.find(Registration.is_active, ~RegistrationForm.is_deleted, RegistrationForm.event_id == event.id, RegistrationForm.publish_registrations_enabled, _join=Registration.registration_form, _eager=Registration.registration_form).order_by( db.func.lower(Registration.first_name), db.func.lower(Registration.last_name), Registration.friendly_id).all())
def _process(self): regforms = RegistrationForm.find_all( RegistrationForm.publish_registrations_enabled, event_id=int(self.event.id) ) query = Registration.find( Registration.event_id == self.event.id, RegistrationForm.publish_registrations_enabled, ~RegistrationForm.is_deleted, ~Registration.is_deleted, _join=Registration.registration_form, ).order_by(db.func.lower(Registration.last_name), db.func.lower(Registration.first_name)) registrations = [(reg.get_full_name(), reg.get_personal_data()) for reg in query] return self.view_class.render_template( "display/participant_list.html", self.event, event=self.event, regforms=regforms, show_affiliation=any(pd.get("affiliation") for reg, pd in registrations), show_position=any(pd.get("position") for reg, pd in registrations), registrations=registrations, )
def _associate_registrations(user, **kwargs): from indico.modules.events.registration.models.registrations import Registration reg_alias = db.aliased(Registration) subquery = db.session.query(reg_alias).filter( reg_alias.user_id == user.id, reg_alias.registration_form_id == Registration.registration_form_id, ~reg_alias.is_deleted, ) registrations = ( Registration.find( Registration.user_id == None, # noqa Registration.email.in_(user.all_emails), ~subquery.exists(), ~Registration.is_deleted, ) .order_by(Registration.submitted_dt.desc()) .all() ) if not registrations: return done = set() for registration in registrations: if registration.registration_form_id in done: continue logger.info("Associating %s with %s", registration, user) registration.user = user done.add(registration.registration_form_id) db.session.flush() num = len(done) flash( ngettext( "A registration has been linked to your account.", "{n} registrations have been linked to your account.", num, ).format(n=num), "info", )
def _merged_participant_list_table(self): def _process_registration(reg, column_names): personal_data = reg.get_personal_data() columns = [{ 'text': personal_data.get(column_name, '') } for column_name in column_names] return { 'checked_in': self._is_checkin_visible(reg), 'columns': columns } column_names = registration_settings.get(self.event, 'participant_list_columns') headers = [ PersonalDataType[column_name].get_title() for column_name in column_names ] query = (Registration.find( Registration.event_id == self.event.id, Registration.state.in_( [RegistrationState.complete, RegistrationState.unpaid]), RegistrationForm.publish_registrations_enabled, ~RegistrationForm.is_deleted, ~Registration.is_deleted, _join=Registration.registration_form, _eager=Registration.registration_form).options( subqueryload('data').joinedload('field_data')).order_by( *Registration.order_by_name)) registrations = [ _process_registration(reg, column_names) for reg in query ] table = {'headers': headers, 'rows': registrations} table['show_checkin'] = any(registration['checked_in'] for registration in registrations) return table
def validate_email(self, field): if RegistrationInvitation.find(email=field.data).with_parent(self.regform).count(): raise ValidationError(_("There is already an invitation with this email address.")) if Registration.find(email=field.data, is_active=True).with_parent(self.regform).count(): raise ValidationError(_("There is already a registration with this email address."))
def _checkParams(self, params): RHManageRegFormBase._checkParams(self, params) ids = set(request.form.getlist('registration_id')) self.registrations = (Registration.find( Registration.id.in_(ids), ~Registration.is_deleted).with_parent( self.regform).order_by(*Registration.order_by_name).all())