本文整理匯總了Python中indico.modules.events.registration.models.registrations.Registration類的典型用法代碼示例。如果您正苦於以下問題:Python Registration類的具體用法?Python Registration怎麽用?Python Registration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Registration類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_registration
def create_registration(regform, data, invitation=None, management=False, notify_user=True):
registration = Registration(registration_form=regform, user=get_user_by_email(data['email']),
base_price=regform.base_price, currency=regform.currency)
for form_item in regform.active_fields:
if form_item.parent.is_manager_only:
with db.session.no_autoflush:
value = form_item.field_impl.default_value
else:
value = data.get(form_item.html_field_name)
with db.session.no_autoflush:
data_entry = RegistrationData()
registration.data.append(data_entry)
for attr, value in form_item.field_impl.process_form_data(registration, value).iteritems():
setattr(data_entry, attr, value)
if form_item.type == RegistrationFormItemType.field_pd and form_item.personal_data_type.column:
setattr(registration, form_item.personal_data_type.column, value)
if invitation is None:
# Associate invitation based on email in case the user did not use the link
with db.session.no_autoflush:
invitation = (RegistrationInvitation
.find(email=data['email'], registration_id=None)
.with_parent(regform)
.first())
if invitation:
invitation.state = InvitationState.accepted
invitation.registration = registration
registration.sync_state(_skip_moderation=management)
db.session.flush()
notify_registration_creation(registration, notify_user)
logger.info('New registration %s by %s', registration, session.user)
return registration
示例2: create_registration
def create_registration(regform, data, invitation=None, management=False, notify_user=True, skip_moderation=None):
user = session.user if session else None
registration = Registration(registration_form=regform, user=get_user_by_email(data['email']),
base_price=regform.base_price, currency=regform.currency)
if skip_moderation is None:
skip_moderation = management
for form_item in regform.active_fields:
if form_item.parent.is_manager_only:
value = form_item.field_impl.default_value
else:
value = data.get(form_item.html_field_name)
data_entry = RegistrationData()
registration.data.append(data_entry)
for attr, value in form_item.field_impl.process_form_data(registration, value).iteritems():
setattr(data_entry, attr, value)
if form_item.type == RegistrationFormItemType.field_pd and form_item.personal_data_type.column:
setattr(registration, form_item.personal_data_type.column, value)
if invitation is None:
# Associate invitation based on email in case the user did not use the link
invitation = (RegistrationInvitation
.find(email=data['email'], registration_id=None)
.with_parent(regform)
.first())
if invitation:
invitation.state = InvitationState.accepted
invitation.registration = registration
registration.sync_state(_skip_moderation=skip_moderation)
db.session.flush()
notify_registration_creation(registration, notify_user)
logger.info('New registration %s by %s', registration, user)
regform.event.log(EventLogRealm.management if management else EventLogRealm.participants,
EventLogKind.positive, 'Registration',
'New registration: {}'.format(registration.full_name), user, data={'Email': registration.email})
return registration
示例3: get_registrations_with_tickets
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()
示例4: _checkParams
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()
)
示例5: all_recipients
def all_recipients(self):
"""Returns all recipients of the notifications.
This includes both explicit recipients and, if enabled,
participants of the event.
"""
recipients = set(self.recipients)
if self.send_to_participants:
recipients.update(reg.email for reg in Registration.get_all_for_event(self.event))
recipients.discard('') # just in case there was an empty email address somewhere
return recipients
示例6: _visible_registration
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())
示例7: get_unique_published_registrations
def get_unique_published_registrations(event):
"""Get a list of unique published registrations for an event.
Uniqueness is determined by associated user, so if someone has
registered in more than one registration form in the event, they
will be included only once.
:param event: The Event to get registrations for
"""
registrations = Registration.find_all(Registration.is_active,
~RegistrationForm.is_deleted,
RegistrationForm.event_id == event.id,
RegistrationForm.publish_registrations_enabled,
_join=Registration.registration_form)
linked_participants = {reg.user_id: reg for reg in registrations if reg.user_id is not None}
non_linked_participants = {reg for reg in registrations if reg.user_id is None}
return sorted(set(linked_participants.viewvalues()) | non_linked_participants,
key=lambda x: (x.first_name.lower(), x.last_name.lower(), x.id))
示例8: _process
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,
)
示例9: _associate_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",
)
示例10: validate_email
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."))
示例11: _checkParams
def _checkParams(self):
self.token = request.args['token']
self.registration = Registration.find_first(uuid=self.token)
if not self.registration:
raise BadRequest