def handle_register(self, action):
     data, errors = self.extractData()
     if not errors:
         email = data['email']
         reg = findRegistrationObject(self.context, email)
         if reg is not None:
             widget = self.widgets['email']
             view = getMultiAdapter(
                 (schema.ValidationError(),
                  self.request, widget, widget.field,
                  self, self.context), IErrorViewSnippet)
             view.update()
             view.message = u"Duplicate Registration"
             widget.error = view
             errors += (view,)
     if errors:
         self.status = self.formErrorsMessage
         return
     # when creating a new registration, the no-show value should always
     # be False, but hiding the widget makes it come out True. This just
     # make sure it's set correctly
     data['noshow'] = False
     obj = self.createAndAdd(data)
     if obj is not None:
         # mark only as finished if we get the new object
         self._finishedAdd = True
         if data.get('new_user', False):
             msg = u'Registration submitted'
         else:
             msg = u'Registered user'
         IStatusMessage(self.request).addStatusMessage(msg, "info")
 def makePayment(self, action, data):
     reg = findRegistrationObject(self.context, self.wizard.data_manager.get("form.email"))
     if reg is None:
         raise Exception("oops, there was an error.")
     super(CheckoutReviewAndPay, self).makePayment.success_handler(self, action, data)
     reg = reg._unrestrictedGetObject()
     reg.paid_fee = True
     reg.reindexObject()
Пример #3
0
    def handle_register(self, action):
        data, errors = self.extractData()
        if not errors:
            email = data['email']
            reg = findRegistrationObject(self.context, email)
            if reg is not None:
                widget = self.widgets['email']
                view = getMultiAdapter(
                    (schema.ValidationError(),
                     self.request, widget, widget.field,
                     self, self.context), IErrorViewSnippet)
                view.update()
                view.message = u"Duplicate Registration"
                widget.error = view
                errors += (view,)
        if errors:
            self.status = self.formErrorsMessage
            return

        # avoid security checks and add a registration to the
        # registraitons folder of the event
        pt = getToolByName(self, 'portal_types')
        type_info = pt.getTypeInfo('collective.eventmanager.Registration')
        normalizer = getUtility(IIDNormalizer)
        orignewid = newid = normalizer.normalize(data['title'])
        registrations = self.context['registrations']
        count = 1
        while newid in registrations:
            newid = orignewid + '-' + str(count)
            count += 1
        obj = type_info._constructInstance(
                registrations,
                type_name='collective.eventmanager.Registration',
                id=newid,
                **data)
        if hasattr(type_info, '_finishConstruction'):
            finobj = type_info._finishConstruction(obj)
        else:
            finobj = obj

        if finobj is not None:
            # mark only as finished if we get the new object
            self._finishedAdd = True
            msg = "Registration Complete"
            IStatusMessage(self.request).addStatusMessage(msg, "info")

            self.request.response.redirect(self.context.absolute_url()
                                            + '/@@pay-for-registration')
 def validate(self, action, data):
     errors = super(CheckoutAddress, self).validate(action, data)
     reg = findRegistrationObject(self.context, data.get("email"))
     if reg is None:
         widget = self.widgets.get("email")
         error = WidgetInputError(field_name="email", widget_title=_(u"Email"), errors=_(u"Not registered email."))
         widget._error = error
         errors += (error,)
     elif reg.paid_fee:
         widget = self.widgets.get("email")
         error = WidgetInputError(
             field_name="email", widget_title=_(u"Email"), errors=_(u"This attendee has already paid.")
         )
         widget._error = error
         errors += (error,)
     return errors