Exemplo n.º 1
0
 def send_email(self, data):
     """ Construct and send an enquiry email. """
     context_url = self.context.absolute_url()
     contactinfo = self.context.contact.to_object
     mailto = contactinfo.email
     bcc = contactinfo.additional_email
     if bcc:
         mto = (u"%s, %s") % (mailto, bcc)
     else:
         mto = mailto
     envelope_from = data['email']
     subject = _(u'Request from %s %s') % (
         data['firstname'], data['lastname'])
     options = data
     options['recipientname'] = contactinfo.Title()
     options['url'] = context_url
     body = ViewPageTemplateFile("enquiry_email.pt")(self, **options)
     # send email
     mailhost = getToolByName(self.context, 'MailHost')
     mailhost.send(body, mto=mto, mfrom=envelope_from, subject=subject,
                   charset='utf-8')
     IStatusMessage(self.request).addStatusMessage(
         _(u"Your email has been forwarded."),
         type="info")
     return self.request.response.redirect(context_url + '/@@thank-you')
Exemplo n.º 2
0
 def __call__(self, context):
     TYPES = {_(u"Data Sheet"): 'Data Sheet',
              _(u"Instruction Manual"): 'Instruction Manual',
              _(u"Price/Delivery Information"):
                 'Price/Delivery Information',
             }
     return SimpleVocabulary([SimpleTerm(value, title=title)
                             for title, value in TYPES.iteritems()])