def update(self): context = aq_inner(self.context) self.errors = {} if 'form.button.Submit' in self.request: authenticator = getMultiAdapter((context, self.request), name=u"authenticator") if not authenticator.verify(): raise Unauthorized fullname = self.request.get('form.name.fullname', None) email = self.request.get('form.name.email', None) project = self.request.get('form.name.project', None) tasks = self.request.get('form.name.tasks', None) # timeframe = self.request.get('form.name.timeframe', None) if not email or email is None: self.errors['email'] = _(u"A valid E-mail address is required") elif not project or project is None: self.errors['project'] = _(u"Please describe your project") else: data = { 'email': email, 'fullname': fullname, 'project': project, 'tasks': tasks } self._send_request(data)
def _send_request(self, data): context = aq_inner(self.context) mto = '*****@*****.**' envelope_from = '*****@*****.**' subject = _(u"Rent my Expert: Callback Request") options = dict(phone=data['phone'], name=data['fullname'], time=data['timeframe']) body = ViewPageTemplateFile('callbackserviceemail.pt')(self, **options) mailhost = getToolByName(context, 'MailHost') mailhost.send(body, mto=mto, mfrom=envelope_from, subject=subject, charset='utf-8') IStatusMessage(self.request).addStatusMessage( _(u"Your request has been forwarded"), type="info") target_url = context.absolute_url() + '/@@callback-request-dispatched' return self.request.response.redirect(target_url)
def _send_request(self, data): context = aq_inner(self.context) mto = '*****@*****.**' envelope_from = '*****@*****.**' subject = _(u"Rent my Expert: Enquiry") options = dict(email=data['email'], name=data['fullname'], project=data['project']) body = ViewPageTemplateFile('enquiryemail.pt')(self, **options) mailhost = getToolByName(context, 'MailHost') mailhost.send(body, mto=mto, mfrom=envelope_from, subject=subject, charset='utf-8') IStatusMessage(self.request).addStatusMessage( _(u"Your request has been forwarded"), type="info") target_url = context.absolute_url() return self.request.response.redirect(target_url)
def update(self): context = aq_inner(self.context) self.errors = {} if 'form.button.Submit' in self.request: authenticator = getMultiAdapter((context, self.request), name=u"authenticator") if not authenticator.verify(): raise Unauthorized fullname = self.request.get('form.name.fullname', None) phone = self.request.get('form.name.phone', None) timeframe = self.request.get('form.name.timeframe', None) if not phone or phone is None: self.errors['phone'] = _(u"Phone number is required") else: data = { 'phone': phone, 'fullname': fullname, 'timeframe': timeframe } self._send_request(data)