def get_mail_body(self, unsorted_data, request, context): """Returns the mail-body with footer. """ schema = get_schema(context) form = DummyFormView(context, request) form.schema = schema form.prefix = 'form' form._update() widgets = {name: widget.render() for name, widget in form.w.items()} data = filter_fields(self, schema, unsorted_data) bodyfield = self.body_pt # pass both the bare_fields (fgFields only) and full fields. # bare_fields for compatability with older templates, # full fields to enable access to htmlValue if isinstance(self.body_pre, basestring): body_pre = self.body_pre else: body_pre = self.body_pre.output if isinstance(self.body_post, basestring): body_post = self.body_post else: body_post = self.body_post.output if isinstance(self.body_footer, basestring): body_footer = self.body_footer else: body_footer = self.body_footer.output extra = { 'data': data, 'fields': OrderedDict([(i, j.title) for i, j in getFieldsInOrder(schema)]), 'widgets': widgets, 'mailer': self, 'body_pre': body_pre and lnbr(dollar_replacer(body_pre, data)), 'body_post': body_post and lnbr(dollar_replacer(body_post, data)), 'body_footer': body_footer and lnbr(dollar_replacer(body_footer, data)), } template = ZopePageTemplate(self.__name__) template.write(bodyfield) template = template.__of__(context) return template.pt_render(extra_context=extra)
def get_mail_body(self, unsorted_data, request, context): """Returns the mail-body with footer. """ schema = get_schema(context) form = DummyFormView(context, request) form.schema = schema form.prefix = "form" form._update() widgets = filter_widgets(self, form.w) data = filter_fields(self, schema, unsorted_data) bodyfield = self.body_pt # pass both the bare_fields (fgFields only) and full fields. # bare_fields for compatability with older templates, # full fields to enable access to htmlValue if isinstance(self.body_pre, six.string_types): body_pre = self.body_pre else: body_pre = self.body_pre.output if isinstance(self.body_post, six.string_types): body_post = self.body_post else: body_post = self.body_post.output if isinstance(self.body_footer, six.string_types): body_footer = self.body_footer else: body_footer = self.body_footer.output extra = { "data": data, "fields": OrderedDict([(i, j.title) for i, j in getFieldsInOrder(schema)]), "widgets": widgets, "mailer": self, "body_pre": body_pre and lnbr(dollar_replacer(body_pre, data)), "body_post": body_post and lnbr(dollar_replacer(body_post, data)), "body_footer": body_footer and lnbr(dollar_replacer(body_footer, data)), } template = ZopePageTemplate(self.__name__) template.write(bodyfield) template = template.__of__(context) return template.pt_render(extra_context=extra)
def get_mail_body(self, unsorted_data, request, context): """Returns the mail-body with footer. """ schema = get_schema(context) form = DummyFormView(context, request) form.schema = schema form.prefix = 'form' form._update() widgets = {name: widget.render() for name, widget in form.w.items()} data = OrderedDict( [x for x in getFieldsInOrder(schema) if x[0] in unsorted_data] ) data.update(unsorted_data) all_data = [ f for f in data # TODO # if not (f.isLabel() or f.isFileField()) and not (getattr(self, # 'showAll', True) and f.getServerSide())] if not (self._is_file_data(data[f])) and not ( getattr(self, 'showAll', True) and IFieldExtender(schema[f]).serverSide ) ] # which data should we show? if getattr(self, 'showAll', True): live_data = all_data else: showFields = getattr(self, 'showFields', []) if showFields is None: showFields = [] live_data = [ f for f in all_data if f in showFields] if not getattr(self, 'includeEmpties', True): all_data = live_data live_data = [f for f in all_data if data[f]] for f in all_data: value = data[f] if value: live_data.append(f) bare_data = OrderedDict([(f, data[f]) for f in live_data]) bodyfield = self.body_pt # pass both the bare_fields (fgFields only) and full fields. # bare_fields for compatability with older templates, # full fields to enable access to htmlValue if isinstance(self.body_pre, basestring): body_pre = self.body_pre else: body_pre = self.body_pre.output if isinstance(self.body_post, basestring): body_post = self.body_post else: body_post = self.body_post.output if isinstance(self.body_footer, basestring): body_footer = self.body_footer else: body_footer = self.body_footer.output extra = { 'data': bare_data, 'fields': OrderedDict([ (i, j.title) for i, j in getFieldsInOrder(schema) ]), 'widgets': widgets, 'mailer': self, 'body_pre': body_pre and lnbr(dollar_replacer(body_pre, data)), 'body_post': body_post and lnbr(dollar_replacer(body_post, data)), 'body_footer': body_footer and lnbr( dollar_replacer(body_footer, data)), } template = ZopePageTemplate(self.__name__) template.write(bodyfield) template = template.__of__(context) return template.pt_render(extra_context=extra)