Exemplo n.º 1
0
    def handleApply(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        if 'captcha' in data:
            captcha = CaptchaValidator(self.context, self.request, None,
                                       IRequestForm['captcha'], None)
            try:
                captcha.validate(data['captcha'])
            except WrongCaptchaCode:
                # import ipdb; ipdb.set_trace()
                message = _(u'Wrong captcha code')
                api.portal.show_message(message=message,
                                        request=self.request,
                                        type='error')
                return

            # else;

        # Do something with valid data here
        # data['site_title'] = api.portal.get_registry_record('plone.site_title')
        # Set status on this form page
        # (this status message is not bind to the session and does not go thru redirects)
        self.send_message(data)
        message = _(u'Your request has been send to the owner')
        self.status = message
        api.portal.show_message(message=message,
                                request=self.request,
                                type='info')
        self.request.response.redirect(self.context.absolute_url())
Exemplo n.º 2
0
    def handleApply(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        msg = u"""Registration process completed. You will receive an email
message with details on how to proceed further."""

        if data.has_key('captcha'):
            # Verify the user input against the captcha
            captcha = CaptchaValidator(self.context, self.request, None,
                                       IRegisterCityForm['captcha'], None)

            try:
                valid = captcha.validate(data['captcha'])
            except WrongCaptchaCode:
                show_message(message=u"Invalid Captcha.",
                             request=self.request,
                             type='error')
                return

            if valid:
                name = data.get('name')
                email = data.get('email')

                obj = CityProfileRegister(name=name, email=email)
                obj = obj.__of__(self.context)
                notify(CityProfileRegisterEvent(obj))
                show_message(message=msg, request=self.request, type='info')
            else:
                show_message(message=u"Please complete the Captcha.",
                             request=self.request,
                             type='error')
Exemplo n.º 3
0
def validateCaptca(value):
    site = getSite()
    request = getRequest()
    if request.getURL().endswith('kss_z3cform_inline_validation'):
        return

    captcha = CaptchaValidator(site, request, None,
            IRegistrationForm['captcha'], None)
    captcha.validate(value)
Exemplo n.º 4
0
 def handleApply(self, action):
     data, errors = self.extractData()
     if data.has_key('captcha'):
         # Verify the user input against the captcha
         captcha = CaptchaValidator(self.context, self.request, None, ICaptchaForm['captcha'], None)
         if data.has_key('subject') and captcha.validate(data['captcha']):
             # if captcha validation passes, print the subject
             print data['subject']
     return
Exemplo n.º 5
0
    def handleApply(self, action):
        data, errors = self.extractData()

        if errors:
            self.status = self.formErrorsMessage

            return

        if 'captcha' in data:
            # Verify the user input against the captcha
            captcha = CaptchaValidator(self.context, self.request, None,
                                       IContactFooterForm['captcha'], None)

            try:
                valid = captcha.validate(data['captcha'])
            except WrongCaptchaCode:
                show_message(message=u"Invalid Captcha.",
                             request=self.request,
                             type='error')
                return

            if valid:
                mail_host = api.portal.get_tool(name='MailHost')

                info = {
                    'name': data.get('name'),
                    'mail': data.get('email'),
                    'url': self.context.absolute_url()
                }
                text = """

Climate Adapt Website

You are receiving this mail because %(name)s
%(mail)s
is sending feedback about the site you administer at %(url)s.
""" % info

            mime_msg = MIMEText(data.get('message') + text)
            mime_msg['Subject'] = data.get('subject')
            mime_msg['From'] = data.get('email')
            mime_msg['To'] = str(api.portal.getSite().email_from_address)

            self.description = u"Email Sent."

            IStatusMessage(self.request).addStatusMessage("Email SENT", 'info')

            return mail_host.send(mime_msg.as_string())
        else:
            self.description = u"Please complete the Captcha."
Exemplo n.º 6
0
 def handle_send(self, action):
     """Send button for sending the email."""
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     if 'captcha' in data:
         # Verify the user input against the captcha
         captcha = CaptchaValidator(
             self.context, self.request, None, IEmailForm['captcha'], None,
         )
         if not self.already_sent and captcha.validate(data['captcha']):
             self.send_email(data)
             self._email_sent = True
     return
Exemplo n.º 7
0
    def handleApply(self, action):
        data, errors = self.extractData()

        if errors:
            self.status = self.formErrorsMessage

            return

        if 'captcha' in data:
            # Verify the user input against the captcha
            captcha = CaptchaValidator(self.context, self.request, None,
                                       IContactForm['captcha'], None)

            try:
                valid = captcha.validate(data['captcha'])
            except WrongCaptchaCode:
                show_message(message=u"Invalid Captcha.",
                             request=self.request,
                             type='error')
                return

            if valid:
                mail_host = api.portal.get_tool(name='MailHost')
                # emailto = str(api.portal.getSite().email_from_address)

                mime_msg = MIMEText(data.get('message'))
                mime_msg['Subject'] = data.get('feedback')
                mime_msg['From'] = data.get('email')
                # mime_msg['To'] = ','.join(b for b in CONTACT_MAIL_LIST)
                # mime_msg['To'] = CONTACT_MAIL_LIST

                for m in CONTACT_MAIL_LIST:
                    mime_msg['To'] = m

                self.description = u"Email Sent."
                IStatusMessage(self.request).addStatusMessage(
                    "Email SENT", 'info')
                return mail_host.send(mime_msg.as_string())
            else:
                self.description = u"Please complete the Captcha."
Exemplo n.º 8
0
    def handle_send(self, action):
        """Send button for sending the email."""
        can_send = True
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        if 'captcha' in data:
            can_send = False
            # Verify the user input against the captcha
            captcha = CaptchaValidator(
                self.context,
                self.request,
                None,
                IContactForm['captcha'],
                None,
            )
            try:
                can_send = captcha.validate(data['captcha'])
            except WrongCaptchaCode, e:
                self.status = e.doc()
                return