def _process(self): set_best_lang() # prevents from having a _LazyString when generating a pdf without session.lang set filename = "{0}-Ticket.pdf".format(self._target.getTitle()) pdf = TicketToPDF(self._target, self._registrant) return send_file(filename, StringIO(pdf.getPDFBin()), 'PDF')
def generate_ticket(registration): pdf = TicketToPDF(registration.registration_form.event, registration) return BytesIO(pdf.getPDFBin())
def _process(self): filename = "{0}-Ticket.pdf".format(self._target.getTitle()) pdf = TicketToPDF(self._target, self._registrant) return send_file(filename, StringIO(pdf.getPDFBin()), 'PDF')
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) 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) modEticket = self._conf.getRegistrationForm().getETicket() if modEticket.isEnabled() and modEticket.isAttachedToEmail(): attachment = {} filename = "{0}-Ticket.pdf".format(self._target.getTitle()) attachment["name"] = filename pdf = TicketToPDF(self._target, rp) attachment["binary"] = pdf.getPDFBin() email["attachments"] = [attachment] if email: GenericMailer.send(email) if canManageRegistration and user != self._getUser(): self._redirect(RHRegistrantListModif._uh.getURL(self._conf)) else: self._redirect(urlHandlers.UHConfRegistrationFormCreationDone.getURL(rp))