Example #1
0
    def _process(self):
        form = make_registration_form(self.regform)()
        if form.validate_on_submit():
            registration = create_registration(self.regform, form.data, self.invitation)
            return redirect(url_for(".display_regform", registration.locator.registrant))
        elif form.is_submitted():
            # not very pretty but usually this never happens thanks to client-side validation
            for error in form.error_list:
                flash(error, "error")

        user_data = {t.name: getattr(session.user, t.name, None) if session.user else "" for t in PersonalDataType}
        if self.invitation:
            user_data.update((attr, getattr(self.invitation, attr)) for attr in ("first_name", "last_name", "email"))
        return self.view_class.render_template(
            "display/regform_display.html",
            self.event,
            event=self.event,
            sections=get_event_section_data(self.regform),
            regform=self.regform,
            payment_conditions=payment_event_settings.get(self.event, "conditions"),
            payment_enabled=self.event.has_feature("payment"),
            currency=payment_event_settings.get(self.event, "currency"),
            user_data=user_data,
            invitation=self.invitation,
            registration=self.registration,
            login_required=self.regform.require_login and not session.user,
        )
Example #2
0
def notify_registration_modification(event, registrant):
    reg_form = registrant.getRegistrationForm()
    from_address = reg_form.getNotificationSender()
    reg_details = _get_reg_details(reg_form, registrant)

    # Send email to organizers
    notification = reg_form.getNotification()
    to_list = notification.getToList()
    cc_list = notification.getCCList()
    if to_list or cc_list:
        reg_page = url_for('event_mgmt.confModifRegistrants-modification', registrant, _external=True, _secure=True)
        tpl = get_template_module('events/registration/emails/registration_modification_organizers.html', event=event,
                                  registrant=registrant, reg_page=reg_page, reg_details=reg_details)
        yield make_email(to_list, cc_list, from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body(),
                         html=True)

    # Send email to the registrant
    if reg_form.isSendRegEmail():
        needs_to_pay = registrant.doPay() and payment_event_settings.get(event, 'enabled')
        params = {}
        if not registrant.getAvatar():
            params = {'registrantId': registrant.getId(), 'authkey': registrant.getRandomId()}
        reg_page = url_for('event.confRegistrationFormDisplay', event, _external=True, _secure=True, **params)
        tpl = get_template_module('events/registration/emails/registration_modification_registrant.html', event=event,
                                  registrant=registrant, payment_enabled=payment_event_settings.get(event, 'enabled'),
                                  reg_page=reg_page, needs_to_pay=needs_to_pay, reg_details=reg_details)

        yield make_email(registrant.getEmail(), from_address=from_address, subject=tpl.get_subject(),
                         body=tpl.get_body(), html=True)
Example #3
0
def notify_registration_modification(event, registrant):
    reg_form = registrant.getRegistrationForm()
    from_address = reg_form.getNotificationSender()
    reg_details = _get_reg_details(reg_form, registrant)

    # Send email to organizers
    notification = reg_form.getNotification()
    to_list = notification.getToList()
    cc_list = notification.getCCList()
    if to_list or cc_list:
        reg_page = url_for('event_mgmt.confModifRegistrants-modification', registrant, _external=True, _secure=True)
        tpl = get_template_module('events/registration/emails/registration_modification_organizers.html', event=event,
                                  registrant=registrant, reg_page=reg_page, reg_details=reg_details)
        yield make_email(to_list, cc_list, from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body(),
                         html=True)

    # Send email to the registrant
    if reg_form.isSendRegEmail():
        needs_to_pay = registrant.doPay() and payment_event_settings.get(event, 'enabled')
        params = {}
        if not registrant.getAvatar():
            params = {'registrantId': registrant.getId(), 'authkey': registrant.getRandomId()}
        reg_page = url_for('event.confRegistrationFormDisplay', event, _external=True, _secure=True, **params)
        tpl = get_template_module('events/registration/emails/registration_modification_registrant.html', event=event,
                                  registrant=registrant, payment_enabled=payment_event_settings.get(event, 'enabled'),
                                  reg_page=reg_page, needs_to_pay=needs_to_pay, reg_details=reg_details)

        yield make_email(registrant.getEmail(), from_address=from_address, subject=tpl.get_subject(),
                         body=tpl.get_body(), html=True)
Example #4
0
def notify_payment_confirmation(registrant, amount):
    event = registrant.getConference()
    reg_form = registrant.getRegistrationForm()
    from_address = reg_form.getNotificationSender()
    currency = payment_event_settings.get(event, 'currency')

    # Send email to organizers
    notification = reg_form.getNotification()
    to_list = notification.getToList()
    cc_list = notification.getCCList()
    if to_list or cc_list:
        reg_page = url_for('event_mgmt.confModifRegistrants-modification', registrant, _external=True, _secure=True)
        tpl = get_template_module('payment/emails/payment_confirmation_organizers.txt', event=event,
                                  registrant=registrant, amount=amount, currency=currency, reg_page=reg_page)
        yield make_email(to_list, cc_list, from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body())

    # Send email to the registrant
    if reg_form.isSendPaidEmail():
        success_email_msg = payment_event_settings.get(event, 'success_email')
        params = {}
        if not registrant.getAvatar():
            params = {'registrantId': registrant.getId(), 'authkey': registrant.getRandomId()}
        reg_page = url_for('event.confRegistrationFormDisplay', event, _external=True, _secure=True, **params)
        tpl = get_template_module('payment/emails/payment_confirmation_registrant.txt', event=event,
                                  registrant=registrant, amount=amount, currency=currency,
                                  success_email_msg=success_email_msg, reg_page=reg_page)
        yield make_email(registrant.getEmail(), from_address=from_address, subject=tpl.get_subject(),
                         body=tpl.get_body())
Example #5
0
def notify_payment_confirmation(registrant, amount):
    event = registrant.getConference()
    reg_form = registrant.getRegistrationForm()
    from_address = reg_form.getNotificationSender()
    currency = payment_event_settings.get(event, 'currency')

    # Send email to organizers
    notification = reg_form.getNotification()
    to_list = notification.getToList()
    cc_list = notification.getCCList()
    if to_list or cc_list:
        reg_page = url_for('event_mgmt.confModifRegistrants-modification',
                           registrant,
                           _external=True,
                           _secure=True)
        tpl = get_template_module(
            'payment/emails/payment_confirmation_organizers.txt',
            event=event,
            registrant=registrant,
            amount=amount,
            currency=currency,
            reg_page=reg_page)
        yield make_email(to_list,
                         cc_list,
                         from_address=from_address,
                         subject=tpl.get_subject(),
                         body=tpl.get_body())

    # Send email to the registrant
    if reg_form.isSendPaidEmail():
        success_email_msg = payment_event_settings.get(event, 'success_email')
        params = {}
        if not registrant.getAvatar():
            params = {
                'registrantId': registrant.getId(),
                'authkey': registrant.getRandomId()
            }
        reg_page = url_for('event.confRegistrationFormDisplay',
                           event,
                           _external=True,
                           _secure=True,
                           **params)
        tpl = get_template_module(
            'payment/emails/payment_confirmation_registrant.txt',
            event=event,
            registrant=registrant,
            amount=amount,
            currency=currency,
            success_email_msg=success_email_msg,
            reg_page=reg_page)
        yield make_email(registrant.getEmail(),
                         from_address=from_address,
                         subject=tpl.get_subject(),
                         body=tpl.get_body())
Example #6
0
    def _getPaymentInfo(self):
        enabled = payment_event_settings.get(self._conf, 'enabled')
        if not self._registrant or not enabled:
            return
        html = []
        if enabled and self._registrant.getTotal():
            total = {}
            total["value"] = 0
            html.append(
                i18nformat(""" <tr><td colspan="2">
                        <table width="100%" cellpadding="3" cellspacing="0">
                            <tr>
                                <td class="regform-done-table-title">
                                    _("Item")
                                </td>
                                <td align="right" class="regform-done-table-title">
                                    _("Quantity")
                                </td>
                                <td align="right" class="regform-done-table-title" nowrap>
                                    _("Unit Price")
                                </td>
                                <td align="right" class="regform-done-table-title">
                                    _("Cost")
                                </td>
                            </tr>
                        """))
            for gsf in self._registrant.getMiscellaneousGroupList():
                html.append("""%s""" %
                            (self._getMiscInfoItemsHTMLBillable(gsf, total)))
            for bf in self._registrant.getBilledForms():
                html.append("""%s""" %
                            (self._getFormItemsHTMLBillable(bf, total)))

            html.append(
                i18nformat("""
                                <tr>
                                    <td align="right" class="regform-done-table-total" colspan="3">
                                        _("TOTAL")
                                    </td>
                                    <td align="right" class="regform-done-table-total" nowrap>
                                        %s <em>%s</em>
                                    </td>
                                </tr>
                            </table></td></tr>
                            """) %
                (total["value"],
                 payment_event_settings.get(self._conf, 'currency')))
        return "".join(html)
Example #7
0
 def _process(self):
     if self._registrant.getPayed():
         flash(_('You have already paid for your registration.'), 'info')
         return redirect(
             url_for('event.confRegistrationFormDisplay', self._conf,
                     **get_registrant_params()))
     checkout_attempt_delta = None
     if not self._registrant.isCheckoutSessionAlive():
         self._registrant._checkout_attempt_dt = datetime.now()
     else:
         checkout_attempt_dt = self._registrant.getCheckoutAttemptDt()
         checkout_attempt_delta = int(
             math.ceil(
                 (datetime.now() - checkout_attempt_dt).total_seconds() /
                 60))
     event = self._conf
     amount = self._registrant.getTotal()
     currency = event_settings.get(event, 'currency')
     plugins = get_active_payment_plugins(event)
     force_plugin = plugins.items()[0] if len(
         plugins) == 1 else None  # only one plugin available
     return WPPaymentEvent.render_template(
         'event_checkout.html',
         event,
         event=event,
         registrant=self._registrant,
         plugins=plugins.items(),
         force_plugin=force_plugin,
         amount=amount,
         currency=currency,
         checkout_attempt_delta=checkout_attempt_delta,
         registrant_params=get_registrant_params())
Example #8
0
    def _check_currencies(self, form):
        """Checks if the currencies are valid.

        :return: `(auto_currency, invalid_currency)` - tuple containing the currency that should
                 be automatically set on the event and a flag if the currency issues cannot be resolved
                 automatically and require user interaction (i.e. saving the plugin settings is disallowed)
        """
        messages = []
        event = self._conf
        valid_currencies = self.plugin.valid_currencies
        currency = event_settings.get(event, 'currency')
        if valid_currencies is None or currency in valid_currencies:
            return None, False, messages

        if len(valid_currencies) == 1:
            auto_currency = list(valid_currencies)[0]
            for plugin in get_active_payment_plugins(event).itervalues():
                if plugin.valid_currencies is not None and auto_currency not in plugin.valid_currencies:
                    messages.append(('error', _("This payment method only supports {}, but the payment method "
                                                "'{}' doesn't.").format(auto_currency, plugin.title)))
                    return None, True, messages
            if not form.is_submitted():
                messages.append(('warning', _("This payment method only supports {0}. Enabling it will automatically "
                                              "change the currency of the event to {0}!").format(auto_currency)))
            return auto_currency, False, messages

        if not form.is_submitted():
            messages.append(('error', _("To enable this payment method, please use one of the following "
                                        "currencies: {}").format(', '.join(valid_currencies))))
        return None, True, messages
Example #9
0
def notify_amount_inconsistency(registration, amount):
    event = registration.registration_form.event
    currency = payment_event_settings.get(event, 'currency')
    to = event.as_event.creator.email
    body = render_template('payment/emails/payment_inconsistency_email_to_manager.txt',
                           event=event, registration=registration, amount=amount, currency=currency)
    return make_email(to, subject='Payment inconsistency', body=body)
Example #10
0
def notify_amount_inconsistency(registrant, amount):
    event = registrant.getConference()
    currency = payment_event_settings.get(event, 'currency')
    to = event.getCreator().getEmail()
    body = render_template('payment/emails/payment_inconsistency_email_to_manager.txt', event=event,
                           registrant=registrant, amount=amount, currency=currency)
    return make_email(to, subject='Payment inconsistency', body=body)
    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."))

        # Check if the email matches an existing user
        user = get_user_by_email(email)
        avatar = user.as_avatar if user else 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 avatar.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, avatar)
        rp.setValues(self._getRequestParams(), avatar)

        if avatar is not None:
            rp.setAvatar(avatar)

        notify_registration_confirmation(self._conf, rp)
        self._conf.log(EventLogRealm.management if self.is_manager else EventLogRealm.participants,
                       EventLogKind.positive, u'Registration',
                       u'User registered: {}'.format(to_unicode(rp.getFullName(title=False, firstNameFirst=True))),
                       session.user,
                       data={u'Indico user': u'{} ({})'.format(user.full_name, user.id) if user else u'None'})

        if self.is_manager:
            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.user or session.user != user:
                params.update(rp.getLocator(), **{'authkey': rp.getRandomId()})
            else:
                params.update(self._conf.getLocator())
            return redirect(url_for('event.confRegistrationFormDisplay', **params))
Example #12
0
 def _getParams(self):
     super(SetPaidHook, self)._getParams()
     self.auth_key = get_query_parameter(self._queryParams, ["auth_key"])
     self.is_paid = get_query_parameter(self._queryParams, ["is_paid"]) == "yes"
     registrant_id = self._pathParams["registrant_id"]
     self._conf = ConferenceHolder().getById(self._pathParams['event'])
     self._registrant = self._conf.getRegistrantById(registrant_id)
     if not payment_event_settings.get(self._conf, 'enabled'):
         raise HTTPAPIError('E-payment is not enabled')
Example #13
0
 def _getParams(self):
     super(SetPaidHook, self)._getParams()
     self.auth_key = get_query_parameter(self._queryParams, ["auth_key"])
     self.is_paid = get_query_parameter(self._queryParams, ["is_paid"]) == "yes"
     registrant_id = self._pathParams["registrant_id"]
     self._conf = ConferenceHolder().getById(self._pathParams['event'])
     self._registrant = self._conf.getRegistrantById(registrant_id)
     if not payment_event_settings.get(self._conf, 'enabled'):
         raise HTTPAPIError('E-payment is not enabled')
Example #14
0
 def getVars(self):
     wvars = wcomponents.WTemplated.getVars(self)
     regForm = self._conf.getRegistrationForm()
     wvars["body_title"] = self._getTitle()
     wvars["title_regform"] = regForm.getTitle()
     wvars["currency"] = payment_event_settings.get(self._conf, 'currency')
     wvars["postURL"] = quoteattr(str(urlHandlers.UHConfRegistrationFormCreation.getURL(self._conf)))
     wvars["conf"] = self._conf
     wvars['sections'] = fossilize(section for section in self.getSections() if section.isEnabled())
     return wvars
Example #15
0
    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))
Example #16
0
    def _getPaymentInfo(self):
        enabled = payment_event_settings.get(self._conf, 'enabled')
        if not self._registrant or not enabled:
            return
        html = []
        if enabled and self._registrant.getTotal():
            total = {}
            total["value"] = 0
            html.append(i18nformat(""" <tr><td colspan="2">
                        <table width="100%" cellpadding="3" cellspacing="0">
                            <tr>
                                <td class="regform-done-table-title">
                                    _("Item")
                                </td>
                                <td align="right" class="regform-done-table-title">
                                    _("Quantity")
                                </td>
                                <td align="right" class="regform-done-table-title" nowrap>
                                    _("Unit Price")
                                </td>
                                <td align="right" class="regform-done-table-title">
                                    _("Cost")
                                </td>
                            </tr>
                        """))
            for gsf in self._registrant.getMiscellaneousGroupList():
                html.append("""%s""" % (self._getMiscInfoItemsHTMLBillable(gsf, total)))
            for bf in self._registrant.getBilledForms():
                html.append("""%s""" % (self._getFormItemsHTMLBillable(bf, total)))

            html.append(i18nformat("""
                                <tr>
                                    <td align="right" class="regform-done-table-total" colspan="3">
                                        _("TOTAL")
                                    </td>
                                    <td align="right" class="regform-done-table-total" nowrap>
                                        %s <em>%s</em>
                                    </td>
                                </tr>
                            </table></td></tr>
                            """) % (total["value"], payment_event_settings.get(self._conf, 'currency')))
        return "".join(html)
Example #17
0
def notify_amount_inconsistency(registrant, amount):
    event = registrant.getConference()
    currency = payment_event_settings.get(event, 'currency')
    to = event.getCreator().getEmail()
    body = render_template(
        'payment/emails/payment_inconsistency_email_to_manager.txt',
        event=event,
        registrant=registrant,
        amount=amount,
        currency=currency)
    return make_email(to, subject='Payment inconsistency', body=body)
Example #18
0
 def _process(self):
     event = self._conf
     enabled = request.form['enabled'] == '1'
     if enabled and not get_payment_plugins():
         flash(_('There are no payment methods available. Please contact your Indico administrator.'), 'error')
         return redirect(url_for('.event_settings', event))
     if event_settings.get(event, 'enabled', None) is None:
         copy_settings = {'currency', 'conditions', 'register_email', 'success_email'}
         data = {k: v for k, v in settings.get_all().iteritems() if k in copy_settings}
         event_settings.set_multi(event, data)
     event_settings.set(event, 'enabled', enabled)
     return redirect(url_for('.event_settings', event))
Example #19
0
 def _process(self):
     if self.registration.state != RegistrationState.unpaid:
         flash(_("The registration doesn't need to be paid"), 'error')
         return redirect(url_for('event_registration.display_regform', self.registration.locator.registrant))
     currency = event_settings.get(self.event, 'currency')
     plugins = get_active_payment_plugins(self.event)
     force_plugin = plugins.items()[0] if len(plugins) == 1 else None  # only one plugin available
     return WPPaymentEvent.render_template('event_checkout.html', self.event, event=self.event,
                                           registration=self.registration,
                                           regform=self.registration.registration_form,
                                           plugins=plugins.items(), force_plugin=force_plugin,
                                           amount=self.registration.price, currency=currency)
Example #20
0
    def getVars(self):
        wvars = wcomponents.WTemplated.getVars(self)
        regForm = self._conf.getRegistrationForm()

        wvars["conf"] = self._conf
        wvars["confId"] = self._conf.getId()
        wvars["registrant"] = self._registrant
        wvars["authparams"] = self._authparams
        wvars["body_title"] = self._getTitle()
        wvars["in_registration_period"] = regForm.inRegistrationPeriod()
        wvars["is_full"] = regForm.isFull()
        wvars["startDate"] = regForm.getStartRegistrationDate()
        wvars["endDate"] = regForm.getEndRegistrationDate()
        wvars["nowutc"] = nowutc()
        wvars["actions"] = self._getActions()
        wvars["announcement"] = regForm.getAnnouncement()
        wvars["title"] = regForm.getTitle()
        wvars["usersLimit"] = ""
        wvars["TransactionStatus"] = TransactionStatus

        if regForm.getUsersLimit() > 0:
            wvars["usersLimit"] = regForm.getUsersLimit()
        wvars["contactInfo"] = ""
        if regForm.getContactInfo().strip() != "":
            wvars["contactInfo"] = regForm.getContactInfo()

        if self._registrant:
            wvars["payment_info"] = self._getPaymentInfo()
            wvars["payment_enabled"] = payment_event_settings.get(
                self._conf, 'enabled')
            wvars["payment_conditions"] = payment_event_settings.get(
                self._conf, 'conditions')
            wvars["payment_done"] = self._registrant.getPayed()
            wvars["registration_info"] = self._getFormSections()
            if self._registrant.getRegistrationDate() is not None:
                wvars[
                    "registration_date"] = self._registrant.getAdjustedRegistrationDate(
                    ).strftime('%d %b %Y')

        return wvars
Example #21
0
def notify_registration_confirmation(event, registrant):
    reg_form = registrant.getRegistrationForm()
    from_address = reg_form.getNotificationSender()
    reg_details = _get_reg_details(reg_form, registrant)

    # Send email to organizers
    notification = reg_form.getNotification()
    to_list = notification.getToList()
    cc_list = notification.getCCList()
    if to_list or cc_list:
        reg_page = url_for('event_mgmt.confModifRegistrants-modification', registrant, _external=True, _secure=True)
        tpl = get_template_module('events/registration/emails/registration_confirmation_organizers.html', event=event,
                                  registrant=registrant, reg_page=reg_page, reg_details=reg_details)
        yield make_email(to_list, cc_list, from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body(),
                         html=True)

    # Send email to the registrant
    if reg_form.isSendRegEmail():
        needs_to_pay = registrant.doPay() and payment_event_settings.get(event, 'enabled')
        registration_email_msg = payment_event_settings.get(event, 'register_email')
        params = {}
        if not registrant.getAvatar():
            params = {'registrantId': registrant.getId(), 'authkey': registrant.getRandomId()}
        reg_page = url_for('event.confRegistrationFormDisplay', event, _external=True, _secure=True, **params)
        tpl = get_template_module('events/registration/emails/registration_confirmation_registrant.html', event=event,
                                  registrant=registrant, payment_enabled=payment_event_settings.get(event, 'enabled'),
                                  reg_page=reg_page, needs_to_pay=needs_to_pay, reg_details=reg_details,
                                  registration_email_msg=registration_email_msg)

        ticket = reg_form.getETicket()
        attachments = []
        if ticket.isEnabled() and ticket.isAttachedToEmail():
            attachments.append({
                'name': 'Ticket.pdf',
                'binary': TicketToPDF(event, registrant).getPDFBin()
            })

        yield make_email(registrant.getEmail(), from_address=from_address, subject=tpl.get_subject(),
                         body=tpl.get_body(), attachments=attachments, html=True)
Example #22
0
def notify_registration_confirmation(event, registrant):
    reg_form = registrant.getRegistrationForm()
    from_address = reg_form.getNotificationSender()
    reg_details = _get_reg_details(reg_form, registrant)

    # Send email to organizers
    notification = reg_form.getNotification()
    to_list = notification.getToList()
    cc_list = notification.getCCList()
    if to_list or cc_list:
        reg_page = url_for('event_mgmt.confModifRegistrants-modification', registrant, _external=True, _secure=True)
        tpl = get_template_module('events/registration/emails/registration_confirmation_organizers.html', event=event,
                                  registrant=registrant, reg_page=reg_page, reg_details=reg_details)
        yield make_email(to_list, cc_list, from_address=from_address, subject=tpl.get_subject(), body=tpl.get_body(),
                         html=True)

    # Send email to the registrant
    if reg_form.isSendRegEmail():
        needs_to_pay = registrant.doPay() and payment_event_settings.get(event, 'enabled')
        registration_email_msg = payment_event_settings.get(event, 'register_email')
        params = {}
        if not registrant.getAvatar():
            params = {'registrantId': registrant.getId(), 'authkey': registrant.getRandomId()}
        reg_page = url_for('event.confRegistrationFormDisplay', event, _external=True, _secure=True, **params)
        tpl = get_template_module('events/registration/emails/registration_confirmation_registrant.html', event=event,
                                  registrant=registrant, payment_enabled=payment_event_settings.get(event, 'enabled'),
                                  reg_page=reg_page, needs_to_pay=needs_to_pay, reg_details=reg_details,
                                  registration_email_msg=registration_email_msg)

        ticket = reg_form.getETicket()
        attachments = []
        if ticket.isEnabled() and ticket.isAttachedToEmail():
            attachments.append({
                'name': 'Ticket.pdf',
                'binary': TicketToPDF(event, registrant).getPDFBin()
            })

        yield make_email(registrant.getEmail(), from_address=from_address, subject=tpl.get_subject(),
                         body=tpl.get_body(), attachments=attachments, html=True)
Example #23
0
 def getVars(self):
     wvars = wcomponents.WTemplated.getVars(self)
     regForm = self._conf.getRegistrationForm()
     wvars["body_title"] = self._getTitle()
     wvars["title_regform"] = regForm.getTitle()
     wvars["currency"] = payment_event_settings.get(self._conf, 'currency')
     wvars["postURL"] = quoteattr(
         str(urlHandlers.UHConfRegistrationFormCreation.getURL(self._conf)))
     wvars["conf"] = self._conf
     wvars['sections'] = fossilize(section
                                   for section in self.getSections()
                                   if section.isEnabled())
     return wvars
Example #24
0
 def _process(self):
     pay = request.form.get("pay") == "1"
     if pay != self.registration.is_paid:
         event = self.registration.registration_form.event
         currency = payment_event_settings.get(event, "currency") if pay else self.registration.transaction.currency
         amount = self.registration.price if pay else self.registration.transaction.amount
         action = TransactionAction.complete if pay else TransactionAction.cancel
         register_transaction(
             registration=self.registration,
             amount=amount,
             currency=currency,
             action=action,
             data={"changed_by_name": session.user.full_name, "changed_by_id": session.user.id},
         )
     return jsonify_data(html=_render_registration_details(self.registration))
Example #25
0
    def getVars(self):
        wvars = wcomponents.WTemplated.getVars(self)
        regForm = self._conf.getRegistrationForm()

        wvars["conf"] = self._conf
        wvars["confId"] = self._conf.getId()
        wvars["registrant"] = self._registrant
        wvars["authparams"] = self._authparams
        wvars["body_title"] = self._getTitle()
        wvars["in_registration_period"] = regForm.inRegistrationPeriod()
        wvars["is_full"] = regForm.isFull()
        wvars["startDate"] = regForm.getStartRegistrationDate()
        wvars["endDate"] = regForm.getEndRegistrationDate()
        wvars["nowutc"] = nowutc()
        wvars["actions"] = self._getActions()
        wvars["announcement"] = regForm.getAnnouncement()
        wvars["title"] = regForm.getTitle()
        wvars["usersLimit"] = ""
        wvars["TransactionStatus"] = TransactionStatus

        if regForm.getUsersLimit() > 0:
            wvars["usersLimit"] = regForm.getUsersLimit()
        wvars["contactInfo"] = ""
        if regForm.getContactInfo().strip() != "":
            wvars["contactInfo"] = regForm.getContactInfo()

        if self._registrant:
            wvars["payment_info"] = self._getPaymentInfo()
            wvars["payment_enabled"] = payment_event_settings.get(self._conf, 'enabled')
            wvars["payment_conditions"] = payment_event_settings.get(self._conf, 'conditions')
            wvars["payment_done"] = self._registrant.getPayed()
            wvars["registration_info"] = self._getFormSections()
            if self._registrant.getRegistrationDate() is not None:
                wvars["registration_date"] = self._registrant.getAdjustedRegistrationDate().strftime('%d %b %Y')

        return wvars
Example #26
0
 def _process(self):
     if self._registrant.getPayed():
         flash(_('You have already paid for your registration.'), 'info')
         return redirect(url_for('event.confRegistrationFormDisplay', self._conf, **get_registrant_params()))
     checkout_attempt_delta = None
     if not self._registrant.isCheckoutSessionAlive():
         self._registrant._checkout_attempt_dt = datetime.now()
     else:
         checkout_attempt_dt = self._registrant.getCheckoutAttemptDt()
         checkout_attempt_delta = int(math.ceil((datetime.now() - checkout_attempt_dt).total_seconds() / 60))
     event = self._conf
     amount = self._registrant.getTotal()
     currency = event_settings.get(event, 'currency')
     plugins = get_active_payment_plugins(event)
     force_plugin = plugins.items()[0] if len(plugins) == 1 else None  # only one plugin available
     return WPPaymentEvent.render_template('event_checkout.html', event, event=event, registrant=self._registrant,
                                           plugins=plugins.items(), force_plugin=force_plugin, amount=amount,
                                           currency=currency, checkout_attempt_delta=checkout_attempt_delta,
                                           registrant_params=get_registrant_params())
Example #27
0
    def render_payment_form(self, registration):
        """Returns the payment form shown to the user.

        :param registration: a :class:`Registration` object
        """
        from indico.modules.payment import event_settings as event_payment_settings

        event = registration.registration_form.event
        settings = self.settings.get_all()
        event_settings = self.event_settings.get_all(event)
        data = {
            "event": registration.registration_form.event,
            "registration": registration,
            "amount": registration.price,
            "currency": event_payment_settings.get(event, "currency"),
            "settings": settings,
            "event_settings": event_settings,
        }
        self.adjust_payment_form_data(data)
        return render_plugin_template("event_payment_form.html", **data)
Example #28
0
 def _process(self):
     event = self._conf
     enabled = request.form['enabled'] == '1'
     if enabled and not get_payment_plugins():
         flash(
             _('There are no payment methods available. Please contact your Indico administrator.'
               ), 'error')
         return redirect(url_for('.event_settings', event))
     if event_settings.get(event, 'enabled', None) is None:
         copy_settings = {
             'currency', 'conditions', 'register_email', 'success_email'
         }
         data = {
             k: v
             for k, v in settings.get_all().iteritems()
             if k in copy_settings
         }
         event_settings.set_multi(event, data)
     event_settings.set(event, 'enabled', enabled)
     return redirect(url_for('.event_settings', event))
Example #29
0
 def _process(self):
     form = make_registration_form(self.regform)()
     if form.validate_on_submit():
         create_registration(self.regform, form.data, management=True)
         flash(_("The registration was created."), "success")
         return redirect(url_for(".manage_reglist", self.regform))
     elif form.is_submitted():
         # not very pretty but usually this never happens thanks to client-side validation
         for error in form.error_list:
             flash(error, "error")
     user_data = {t.name: getattr(self.user, t.name, None) if self.user else "" for t in PersonalDataType}
     return WPManageRegistration.render_template(
         "display/regform_display.html",
         self.event,
         event=self.event,
         sections=get_event_section_data(self.regform),
         regform=self.regform,
         currency=payment_event_settings.get(self.event, "currency"),
         post_url=url_for(".create_registration", self.regform),
         user_data=user_data,
         management=True,
     )
Example #30
0
    def _check_currencies(self, form):
        """Checks if the currencies are valid.

        :return: `(auto_currency, invalid_currency)` - tuple containing the currency that should
                 be automatically set on the event and a flag if the currency issues cannot be resolved
                 automatically and require user interaction (i.e. saving the plugin settings is disallowed)
        """
        messages = []
        event = self._conf
        valid_currencies = self.plugin.valid_currencies
        currency = event_settings.get(event, 'currency')
        if valid_currencies is None or currency in valid_currencies:
            return None, False, messages

        if len(valid_currencies) == 1:
            auto_currency = list(valid_currencies)[0]
            for plugin in get_active_payment_plugins(event).itervalues():
                if plugin.valid_currencies is not None and auto_currency not in plugin.valid_currencies:
                    messages.append((
                        'error',
                        _("This payment method only supports {}, but the payment method "
                          "'{}' doesn't.").format(auto_currency,
                                                  plugin.title)))
                    return None, True, messages
            if not form.is_submitted():
                messages.append((
                    'warning',
                    _("This payment method only supports {0}. Enabling it will automatically "
                      "change the currency of the event to {0}!").format(
                          auto_currency)))
            return auto_currency, False, messages

        if not form.is_submitted():
            messages.append((
                'error',
                _("To enable this payment method, please use one of the following "
                  "currencies: {}").format(', '.join(valid_currencies))))
        return None, True, messages
Example #31
0
 def render_price(self):
     currency = event_payment_settings.get(self.registration.registration_form.event, 'currency', '')
     return format_currency(self.price, currency, locale=session.lang or 'en_GB')
Example #32
0
 def _process(self):
     with self.plugin.plugin_context():
         html = self.plugin.render_payment_form(
             self._conf, self._registrant, self._registrant.getTotal(),
             event_settings.get(self._conf, 'currency'))
     return jsonify(html=html)
Example #33
0
 def getVars(self):
     wvars = wcomponents.WTemplated.getVars(self)
     wvars["conditions"] = payment_event_settings.get(
         self._conf, 'conditions')
     return wvars
Example #34
0
 def _process(self):
     with self.plugin.plugin_context():
         html = self.plugin.render_payment_form(self._conf, self._registrant, self._registrant.getTotal(),
                                                event_settings.get(self._conf, 'currency'))
     return jsonify(html=html)
Example #35
0
 def _process(self):
     return WPManageRegistration.render_template('management/regform_modify.html', self.event, event=self.event_new,
                                                 sections=get_event_section_data(self.regform, management=True),
                                                 regform=self.regform,
                                                 currency=event_settings.get(self.event, 'currency'))
Example #36
0
 def _process(self):
     conditions = event_settings.get(self._conf, 'conditions')
     return WPPaymentEvent.render_template('terms_and_conditions.html', self._conf, conditions=conditions)
Example #37
0
 def getVars(self):
     wvars = wcomponents.WTemplated.getVars(self)
     wvars["conditions"] = payment_event_settings.get(self._conf, 'conditions')
     return wvars