def _process(self): canManageRegistration = self._conf.canManageRegistration(self._getUser()) if not canManageRegistration and not self._regForm.isActivated(): p = registrationForm.WPRegFormInactive(self, self._conf) return p.display() params = self._getRequestParams() email = self._regForm.getPersonalData().getValueFromParams(params, 'email') if email is None: raise FormValuesError(_("An email address has to be set in order to make the registration in the event.")) elif not validMail(email, False): raise FormValuesError(_("The given email address is not valid.")) matchedUsers = AvatarHolder().match({"email": email}, exact=1) if matchedUsers: user = matchedUsers[0] else: user = None # Check if the user can register if not canManageRegistration: # normal user registering. Managers can. if self._conf.getRegistrationForm().isFull(): self._redirect(urlHandlers.UHConfRegistrationFormDisplay.getURL(self._conf)) return elif not self._conf.getRegistrationForm().inRegistrationPeriod(): flash(_("Your registration couldn't be recorded."), 'error') return redirect(url_for('event.confRegistrationFormDisplay', self._conf)) if user is None: if self._conf.hasRegistrantByEmail(email): raise FormValuesError("There is already a user with the email \"%s\". Please choose another one" % email) else: if user.isRegisteredInConf(self._conf) or self._conf.hasRegistrantByEmail(email): if canManageRegistration: raise FormValuesError("There is already a user with the email \"%s\". Please choose another one" % email) else: raise FormValuesError("You have already registered with the email address \"%s\". If you need to modify your registration, please contact the managers of the conference." % email) rp = registration.Registrant() self._conf.addRegistrant(rp, user) rp.setValues(self._getRequestParams(), user) if user is not None: user.addRegistrant(rp) rp.setAvatar(user) notify_registration_confirmation(self._conf, rp) if canManageRegistration and user != self._getUser(): self._redirect(RHRegistrantListModif._uh.getURL(self._conf)) else: params = {} if not rp.doPay() or not payment_event_settings.get(self._conf, 'enabled'): flash(_(u"Your registration has been recorded successfully."), 'success') if not session.avatar: params.update(rp.getLocator(), **{'authkey': rp.getRandomId()}) else: params.update(self._conf.getLocator()) return redirect(url_for('event.confRegistrationFormDisplay', **params))
def _process( self ): canManageRegistration = self._conf.canManageRegistration(self._getUser()) if not canManageRegistration and not self._regForm.isActivated(): p = registrationForm.WPRegFormInactive( self, self._conf ) return p.display() params = self._getRequestParams() email = self._regForm.getPersonalData().getValueFromParams(params, 'email') if email is None: raise FormValuesError(_("An email address has to be set in order to make the registration in the event.")) elif not validMail(email, False): raise FormValuesError(_("The given email address is not valid.")) matchedUsers = AvatarHolder().match({"email": email}, exact=1) if matchedUsers: user = matchedUsers[0] else: user = None # Check if the user can register if not canManageRegistration: # normal user registering. Managers can. if self._conf.getRegistrationForm().isFull(): self._redirect(urlHandlers.UHConfRegistrationFormDisplay.getURL(self._conf)) return elif not self._conf.getRegistrationForm().inRegistrationPeriod(): p = registrationForm.WPRegistrationFormClosed(self, self._conf) return p.display() if user is None: if self._conf.hasRegistrantByEmail(email): raise FormValuesError("There is already a user with the email \"%s\". Please choose another one"%email) else: if user.isRegisteredInConf(self._conf): self._redirect(urlHandlers.UHConfRegistrationForm.getURL(self._conf)) return if self._conf.hasRegistrantByEmail(email): if canManageRegistration: raise FormValuesError("There is already a user with the email \"%s\". Please choose another one"%email) else: raise FormValuesError("You have already registered with the email address \"%s\". If you need to modify your registration, please contact the managers of the conference."%email) rp = registration.Registrant() self._conf.addRegistrant(rp) rp.setValues(self._getRequestParams(), user) rp.setSessionBillingEnabled(self._regForm.getSessionsForm().getType() != "2priorities") if user is not None: user.addRegistrant(rp) rp.setAvatar(user) # avoid multiple sending in case of db conflict email = self._regForm.getNotification().createEmailNewRegistrant(self._regForm, rp) if email: GenericMailer.send(email) if not canManageRegistration: self._redirect(urlHandlers.UHConfRegistrationFormCreationDone.getURL(rp)) else: self._redirect(RHRegistrantListModif._uh.getURL(self._conf))
def _process( self ): user = self._getUser() canManageRegistration = self._conf.canManageRegistration(user) if not canManageRegistration and (not self._regForm.isActivated() or not self._conf.hasEnabledSection("regForm")): p = registrationForm.WPRegFormInactive( self, self._conf ) return p.display() params = self._getRequestParams() if canManageRegistration: matchedUsers = AvatarHolder().match({"email": params["email"]}) if matchedUsers: user = matchedUsers[0] else: user = None else: if self._conf.getRegistrationForm().isFull(): self._redirect(urlHandlers.UHConfRegistrationFormDisplay.getURL(self._conf)) return elif not self._conf.getRegistrationForm().inRegistrationPeriod(): p = registrationForm.WPRegistrationFormClosed(self, self._conf) return p.display() if user is None: if self._conf.hasRegistrantByEmail(self._getRequestParams().get("email","")): raise FormValuesError("There is already a user with the email \"%s\". Please choose another one"%self._getRequestParams().get("email","--no email--")) else: if user.isRegisteredInConf(self._conf): self._redirect(urlHandlers.UHConfRegistrationForm.getURL(self._conf)) return rp = registration.Registrant() self._conf.addRegistrant(rp) rp.setValues(self._getRequestParams(), user) if user is not None: user.addRegistrant(rp) rp.setAvatar(user) #if not canManageRegistration: # avoid multiple sending in case of db conflict if not hasattr(self, "_emailsent"): self._regForm.getNotification().sendEmailNewRegistrant(self._regForm, rp) self._emailSent = True if not canManageRegistration: self._redirect(urlHandlers.UHConfRegistrationFormCreationDone.getURL(rp)) else: self._redirect(RHRegistrantListModif._uh.getURL(self._conf))
def _process(self): canManageRegistration = self._conf.canManageRegistration( self._getUser()) if not canManageRegistration and not self._regForm.isActivated(): p = registrationForm.WPRegFormInactive(self, self._conf) return p.display() params = self._getRequestParams() email = self._regForm.getPersonalData().getValueFromParams( params, 'email') if email is None: raise FormValuesError( _("An email address has to be set in order to make the registration in the event." )) elif not validMail(email, False): raise FormValuesError(_("The given email address is not valid.")) matchedUsers = AvatarHolder().match({"email": email}, exact=1) if matchedUsers: user = matchedUsers[0] else: user = None # Check if the user can register if not canManageRegistration: # normal user registering. Managers can. if self._conf.getRegistrationForm().isFull(): self._redirect( urlHandlers.UHConfRegistrationFormDisplay.getURL( self._conf)) return elif not self._conf.getRegistrationForm().inRegistrationPeriod(): p = registrationForm.WPRegistrationFormClosed(self, self._conf) return p.display() if user is None: if self._conf.hasRegistrantByEmail(email): raise FormValuesError( "There is already a user with the email \"%s\". Please choose another one" % email) else: if user.isRegisteredInConf( self._conf) or self._conf.hasRegistrantByEmail(email): if canManageRegistration: raise FormValuesError( "There is already a user with the email \"%s\". Please choose another one" % email) else: raise FormValuesError( "You have already registered with the email address \"%s\". If you need to modify your registration, please contact the managers of the conference." % email) rp = registration.Registrant() self._conf.addRegistrant(rp, user) rp.setValues(self._getRequestParams(), user) if user is not None: user.addRegistrant(rp) rp.setAvatar(user) # This creates the email to the new registrant and SENDS the email to the organizers if necessary... WTF. email = self._regForm.getNotification().createEmailNewRegistrant( self._regForm, rp) if self._regForm.isSendRegEmail() and rp.getEmail().strip(): modEticket = self._conf.getRegistrationForm().getETicket() if modEticket.isEnabled() and modEticket.isAttachedToEmail(): attachment = { 'name': "{0}-Ticket.pdf".format(self._target.getTitle()), 'binary': TicketToPDF(self._target, rp).getPDFBin(), } email["attachments"] = [attachment] GenericMailer.send(email) if canManageRegistration and user != self._getUser(): self._redirect(RHRegistrantListModif._uh.getURL(self._conf)) else: self._redirect( urlHandlers.UHConfRegistrationFormCreationDone.getURL(rp))