def render(self, context, template=None): """ A ``template`` kwarg can be passed to use an explictly defined template instead of the default template list. """ with update_context(context, {'self': self}): return render_to_string( template or self.get_render_templates(context), context)
def get_form_template(self, request, template=None, context=None): """ :Returns: Rendered form template with the given context, if any. """ if not context: context = RequestContext(request) with update_context(context, {'form': self.get_form(request, prefix=self.get_form_prefix())}): return render_to_string(template or self.edit_templates, context)
def render(self, context, template=None): """ A ``template`` kwarg can be passed to use an explictly defined template instead of the default template list. """ with update_context(context, {'self': self}): return render_to_string( template or self.get_render_templates(context), context )
def render_root(context, owner, field_name): """ Renders `root_node` _unless_ `root_node_override` is in the context, in which case the override is rendered instead. `root_node_override` is used for stuff like preview, when a view wants to specify exactly what root node to use. """ root_node = context.get('root_node_override') field = owner._meta.get_field_by_name(field_name)[0] with update_context(context, {'root_node_override': None}): return field.render(owner, context=context, node=root_node)
def render_root(context, owner, field_name): """ Renders `root_node` _unless_ `root_node_override` is in the context, in which case the override is rendered instead. `root_node_override` is used for stuff like preview, when a view wants to specify exactly what root node to use. """ root_node = context.get('root_node_override') field = owner._meta.get_field(field_name) with update_context(context, {'root_node_override': None}): return field.render(owner, context=context, node=root_node)
def render(self, model_instance, context=None, node=None): root_node = node or self.get_render_node(model_instance, context) if not root_node: return 'no content' root_node.prefetch_tree() env = { 'widgy': { 'site': self.site, 'owner': model_instance, 'root_node': root_node, 'parent': context and context.get('widgy'), }, } with update_context(context, env) as context: return root_node.render(context)
def render(self, context): if self.context_var in context: # when the form fails validation, the submission view passes # the existing instance back to us in the context form = context[self.context_var] else: form = self.build_form_class()() request = context.get('request') action_url = build_url( self.action_url(context['widgy']), **{'from': request and (request.GET.get('from') or request.path)}) ctx = { 'form': form, 'action_url': action_url, 'success': request and request.GET.get('success') == self.success_key, } with update_context(context, ctx): return super(Form, self).render(context)
def render(self, context): if self.context_var in context: # when the form fails validation, the submission view passes # the existing instance back to us in the context form = context[self.context_var] else: form = self.build_form_class()() request = context.get('request') action_url = build_url( self.action_url(context['widgy']), **{'from': request and (request.GET.get('from') or request.path)} ) ctx = { 'form': form, 'action_url': action_url, 'success': request and request.GET.get('success') == self.success_key, } with update_context(context, ctx): return super(Form, self).render(context)
def render(self, context): form = context['form'] field = form[self.get_formfield_name()] with update_context(context, {'field': field}): return super(BaseFormField, self).render(context)