def get_printable_context(self, ar, **kw): kw = super(Excerpt, self).get_printable_context(ar, **kw) kw.update(obj=self.owner) # kw.update(excerpt=self) body = "" if self.excerpt_type_id is not None: atype = self.excerpt_type if atype.backward_compat: kw.update(this=self.owner) if atype.body_template: tplname = atype.body_template tplgroup = model_group(atype.content_type.model_class()) tplname = tplgroup + "/" + tplname saved_renderer = ar.renderer ar.renderer = settings.SITE.ui.plain_renderer template = settings.SITE.jinja_env.get_template(tplname) body = template.render(**kw) ar.renderer = saved_renderer kw.update(body=body) # if self.owner is not None: # kw.update(self=self.owner) # kw.update(this=self.owner) # kw.update(doc=self) return kw
def get_template_groups(self): """Here we override the class method by an instance method. This means that we must also override all other methods of Printable who call the *class* method. This is currently only :meth:`template_choices`. """ return [model_group(self.voucher_type.model)]
def template_choices(cls,build_method,voucher_type): """ Overrides PrintableType.template_choices to not use the class method `get_templates_group`. """ if not voucher_type: return [] #~ print 20131006, voucher_type template_group = model_group(voucher_type.model) return cls.get_template_choices(build_method,template_group)
def template_choices(cls, build_method, content_type): tplgroups = [model_group(content_type.model_class()), "excerpts"] return cls.get_template_choices(build_method, tplgroups)
def get_template_groups(self): ptype = self.get_printable_type() if ptype is None: raise Exception("20140520 Must have excerpt_type.") grp = model_group(ptype.content_type.model_class()) return [grp, "excerpts"]
def body_template_choices(cls, content_type): tplgroups = [model_group(content_type.model_class()), "excerpts"] return settings.SITE.list_templates(".body.html", tplgroups)