Ejemplo n.º 1
0
    def render_layout(self, form, context):
        """
        Returns safe html of the rendering of the layout
        """
        form.rendered_fields = set()

        # This renders the specifed Layout
        html = self.layout.render(form, self.form_style, context)

        if self.render_unmentioned_fields:
            fields = set(form.fields.keys())
            left_fields_to_render = fields - form.rendered_fields
            for field in left_fields_to_render:
                html += render_field(field, form, self.form_style, context)

        # If the user has meta fields defined, not included in the layout
        # we suppose they need to be rendered. Othewise we renderd the
        # layout fields strictly
        if getattr(form, 'Meta', None):
            current_fields = set(getattr(form, 'fields', []))
            left_fields_to_render = current_fields - form.rendered_fields

            for field in left_fields_to_render:
                html += render_field(field, form, self.form_style, context)

        return mark_safe(html)
Ejemplo n.º 2
0
    def render_layout(self, form, context, template_pack=TEMPLATE_PACK):
        """
        Returns safe html of the rendering of the layout
        """
        form.rendered_fields = set()

        # This renders the specifed Layout
        html = self.layout.render(form, self.form_style, context,
                                  template_pack=template_pack)

        if self.render_unmentioned_fields:
            fields = set(form.fields.keys())
            left_fields_to_render = fields - form.rendered_fields
            for field in left_fields_to_render:
                html += render_field(field, form, self.form_style, context, template_pack=template_pack)

        # If the user has Meta.fields defined, not included in the layout
        # we suppose they need to be rendered. Otherwise we render the
        # layout fields strictly
        if hasattr(form, 'Meta'):
            if hasattr(form.Meta, 'fields'):
                current_fields = set(getattr(form, 'fields', []))
                meta_fields = set(getattr(form.Meta, 'fields'))

                fields_to_render = current_fields & meta_fields
                left_fields_to_render = fields_to_render - form.rendered_fields

                for field in left_fields_to_render:
                    html += render_field(field, form, self.form_style, context)

        return mark_safe(html)
Ejemplo n.º 3
0
    def render(self, form, form_style, context):
        # We first render the buttons
        buttons = ''
        for field in self.fields[1:]:
            buttons += render_field(field,
                                    form,
                                    form_style,
                                    context,
                                    'bootstrap/layout/field.html',
                                    layout_object=self)

        context.update({'div': self, 'buttons': buttons})

        if isinstance(self.fields[0], Field):
            # FieldWithButtons(Field('field_name'), StrictButton("go"))
            # We render the field passing its name and attributes
            return render_field(self.fields[0][0],
                                form,
                                form_style,
                                context,
                                self.template,
                                attrs=self.fields[0].attrs)
        else:
            return render_field(self.fields[0], form, form_style, context,
                                self.template)
Ejemplo n.º 4
0
    def render_layout(self, form, context):
        """
        Returns safe html of the rendering of the layout
        """
        form.rendered_fields = set()

        # This renders the specifed Layout
        html = self.layout.render(form, self.form_style, context)

        if self.render_unmentioned_fields:
            fields = set(form.fields.keys())
            left_fields_to_render = fields - form.rendered_fields
            for field in left_fields_to_render:
                html += render_field(field, form, self.form_style, context)

        # If the user has meta fields defined, not included in the layout
        # we suppose they need to be rendered. Othewise we renderd the
        # layout fields strictly
        if getattr(form, 'Meta', None):
            current_fields = set(getattr(form, 'fields', []))
            left_fields_to_render = current_fields - form.rendered_fields

            for field in left_fields_to_render:
                html += render_field(field, form, self.form_style, context)

        return mark_safe(html)
Ejemplo n.º 5
0
    def render(self, form, form_style, context):
        # We first render the buttons
        buttons = ''
        for field in self.fields[1:]:
            buttons += render_field(field, form, form_style, context,
                'bootstrap/layout/field.html', layout_object=self)

        context.update({'div': self, 'buttons': buttons})
        return render_field(self.fields[0], form, form_style, context,
            'bootstrap/layout/field_with_buttons.html')
Ejemplo n.º 6
0
    def render(self, form, form_style, context):
        # We first render the buttons
        buttons = ""
        for field in self.fields[1:]:
            buttons += render_field(field, form, form_style, context, "bootstrap/layout/field.html", layout_object=self)

        context.update({"div": self, "buttons": buttons})

        if isinstance(self.fields[0], Field):
            # FieldWithButtons(Field('field_name'), StrictButton("go"))
            # We render the field passing its name and attributes
            return render_field(self.fields[0][0], form, form_style, context, self.template, attrs=self.fields[0].attrs)
        else:
            return render_field(self.fields[0], form, form_style, context, self.template)
Ejemplo n.º 7
0
 def render(self, form, form_style, context):
     links, content = "", ""
     self.first_tab_with_errors(form.errors.keys()).active = True
     for tab in self.fields:
         content += render_field(tab, form, form_style, context)
         links += tab.render_link()
     return render_to_string(self.template, Context({"tabs": self, "links": links, "content": content}))
Ejemplo n.º 8
0
 def render(self, form, form_style, context):
     return render_field(self.field,
                         form,
                         form_style,
                         context,
                         template=self.template,
                         attrs=self.attrs)
Ejemplo n.º 9
0
    def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
        html = u''
        for field in self.fields:
            html += render_field(field, form, form_style,
                                 context, template_pack=template_pack)

        return render_to_string(self.template, Context({'buttonholder': self, 'fields_output': html}))
Ejemplo n.º 10
0
 def render(self, form, form_style, context):
     links, content = '', ''
     self.first_tab_with_errors(form.errors.keys()).active = True
     for tab in self.fields:
         content += render_field(tab, form, form_style, context)
         links += tab.render_link()
     return render_to_string(self.template,
         Context({'tabs': self, 'links': links, 'content': content}))
Ejemplo n.º 11
0
 def render(self, name, value, attrs=None):
     final_attrs = self.build_attrs(attrs)
     value = render_field(BoundField(self.form,
                                     self.form.fields[self.field_name],
                                     self.field_name))
     return mark_safe(u'<%s%s>%s</%s>' % (self.tag_name,
                                           flatatt(final_attrs),
                                           value,
                                           self.tag_name))
Ejemplo n.º 12
0
 def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
     html = ""
     for field in self.fields:
         html += render_field(field,
                              form,
                              form_style,
                              context,
                              template_pack=template_pack)
     return html
Ejemplo n.º 13
0
    def render(self, form, form_style, context):
        fields = ''
        for field in self.fields:
            fields += render_field(field, form, form_style, context)

        legend = ''
        if self.legend:
            legend = u'%s' % Template(unicode(self.legend)).render(context)
        return render_to_string(self.template, Context({'fieldset': self, 'legend': legend, 'fields': fields, 'form_style': form_style}))
Ejemplo n.º 14
0
    def render(self, form, form_style, context):
        fields = ''
        for field in self.fields:
            fields += render_field(field, form, form_style, context)

        legend = ''
        if self.legend:
            legend = u'%s' % Template(self.legend).render(context)
        return render_to_string(self.template, Context({'fieldset': self, 'legend': legend, 'fields': fields, 'form_style': form_style}))
Ejemplo n.º 15
0
    def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
        fields = ''
        for field in self.fields:
            fields += render_field(field, form, form_style, context,
                                   template_pack=template_pack)

        legend = ''
        if self.legend:
            legend = u'%s' % Template(unicode(self.legend)).render(context)
        return render_to_string(self.template, Context({'fieldset': self, 'legend': legend, 'fields': fields, 'form_style': form_style}))
Ejemplo n.º 16
0
 def render(self, form, form_style, context):
     html = ''
     for field in self.fields:
         html += render_field(field,
                              form,
                              form_style,
                              context,
                              template=self.template,
                              attrs=self.attrs)
     return html
Ejemplo n.º 17
0
    def render(self, form, form_style, context):
        fields = ''
        for field in self.fields:
            fields += render_field(field, form, form_style, context)

        return render_to_string(self.template,
                                Context({
                                    'div': self,
                                    'fields': fields
                                }))
Ejemplo n.º 18
0
    def render(self, form, form_style, context):
        html = u''
        for field in self.fields:
            html += render_field(field, form, form_style, context)

        return render_to_string(
            self.template, Context({
                'formactions': self,
                'fields_output': html
            }))
Ejemplo n.º 19
0
 def render(self, form, form_style, context):
     context.update({
         'crispy_prepended_text': self.text,
         'active': getattr(self, "active", False)
     })
     return render_field(self.field,
                         form,
                         form_style,
                         context,
                         template=self.template,
                         attrs=self.attrs)
Ejemplo n.º 20
0
 def render(self, form, form_style, context, template_pack="bootstrap"):
     context.update(
         {
             "crispy_appended_text": self.appended_text,
             "crispy_prepended_text": self.prepended_text,
             "active": getattr(self, "active", False),
         }
     )
     return render_field(
         self.field, form, form_style, context, template=self.template, attrs=self.attrs, template_pack=template_pack
     )
Ejemplo n.º 21
0
    def render(self, form, form_style, context):
        fields = ""
        for field in self.fields:
            fields += render_field(field, form, form_style, context)

        legend = ""
        if self.legend:
            legend = u"%s" % Template(self.legend).render(context)
        return render_to_string(
            self.template, Context({"fieldset": self, "legend": legend, "fields": fields, "form_style": form_style})
        )
Ejemplo n.º 22
0
    def render(self, form, form_style, context):
        if form.errors:
            self.css_class += " error"

        # We need to render fields using django-uni-form render_field so that MultiField can
        # hold other Layout objects inside itself
        fields_output = u''
        self.bound_fields = []
        for field in self.fields:
            fields_output += render_field(field, form, form_style, context, 'uni_form/multifield.html', self.label_class, layout_object=self)

        return render_to_string(self.template, Context({'multifield': self, 'fields_output': fields_output}))
Ejemplo n.º 23
0
 def render(self, form, form_style, context, template_pack='bootstrap'):
     context.update({
         'crispy_appended_text': self.text,
         'active': getattr(self, "active", False)
     })
     return render_field(self.field,
                         form,
                         form_style,
                         context,
                         template=self.template,
                         attrs=self.attrs,
                         template_pack=template_pack)
Ejemplo n.º 24
0
    def render(self, form, form_style, context):
        if form.errors:
            self.css_class += " error"

        # We need to render fields using django-uni-form render_field so that MultiField can
        # hold other Layout objects inside itself
        fields_output = u''
        self.bound_fields = []
        for field in self.fields:
            fields_output += render_field(field, form, form_style, context, 'uni_form/multifield.html', self.label_class, layout_object=self)

        return render_to_string(self.template, Context({'multifield': self, 'fields_output': fields_output}))
Ejemplo n.º 25
0
    def render_layout(self, form, context):
        """
        Returns safe html of the rendering of the layout
        """
        form.rendered_fields = []

        html = self.layout.render(form, self.form_style, context)

        for field in form.fields.keys():
            if not field in form.rendered_fields:
                html += render_field(field, form, self.form_style, context)

        return mark_safe(html)
Ejemplo n.º 26
0
 def render(self, form, form_style, context):
     links, content = '', ''
     self.first_tab_with_errors(form.errors.keys()).active = True
     for tab in self.fields:
         content += render_field(tab, form, form_style, context)
         links += tab.render_link()
     return render_to_string(
         self.template,
         Context({
             'tabs': self,
             'links': links,
             'content': content
         }))
Ejemplo n.º 27
0
    def render_layout(self, form, context):
        """
        Returns safe html of the rendering of the layout
        """
        form.rendered_fields = []
        
        html = self.layout.render(form, self.form_style, context)

        for field in form.fields.keys():
            if not field in form.rendered_fields:
                html += render_field(field, form, self.form_style, context)

        return mark_safe(html)
Ejemplo n.º 28
0
    def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
        fields = ''
        for field in self.fields:
            fields += render_field(field,
                                   form,
                                   form_style,
                                   context,
                                   template_pack=template_pack)

        return render_to_string(self.template,
                                Context({
                                    'div': self,
                                    'fields': fields
                                }))
Ejemplo n.º 29
0
    def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
        # If a field within MultiField contains errors
        if context['form_show_errors']:
            for field in map(lambda pointer: pointer[1], self.get_field_names()):
                if field in form.errors:
                    self.css_class += " error"

        fields_output = u''
        for field in self.fields:
            fields_output += render_field(field, form, form_style, context,
                self.field_template, self.label_class, layout_object=self,
                template_pack=template_pack)

        context.update({'multifield': self, 'fields_output': fields_output})
        return render_to_string(self.template, context)
Ejemplo n.º 30
0
    def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
        html = u''
        for field in self.fields:
            html += render_field(field,
                                 form,
                                 form_style,
                                 context,
                                 template_pack=template_pack)

        return render_to_string(
            self.template,
            Context({
                'buttonholder': self,
                'fields_output': html
            }))
Ejemplo n.º 31
0
    def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
        # If a field within MultiField contains errors
        if context['form_show_errors']:
            for field in map(lambda pointer: pointer[1],
                             self.get_field_names()):
                if field in form.errors:
                    self.css_class += " error"

        fields_output = u''
        for field in self.fields:
            fields_output += render_field(field,
                                          form,
                                          form_style,
                                          context,
                                          self.field_template,
                                          self.label_class,
                                          layout_object=self,
                                          template_pack=template_pack)

        context.update({'multifield': self, 'fields_output': fields_output})
        return render_to_string(self.template, context)
Ejemplo n.º 32
0
 def render(self, form, form_style, context, template_pack='bootstrap'):
     context.update({'crispy_prepended_text': self.text, 'active': getattr(self, "active", False)})
     return render_field(self.field, form, form_style, context, template=self.template, attrs=self.attrs, template_pack=template_pack)
Ejemplo n.º 33
0
 def render(self, form, form_style, context):
     html = ""
     for field in self.fields:
         html += render_field(field, form, form_style, context)
     return html
Ejemplo n.º 34
0
 def render(self, form, form_style, context):
     return render_field(self.field, form, form_style, context, template=self.template, attrs=self.attrs)
Ejemplo n.º 35
0
    def render(self, form, form_style, context):
        fields = ''
        for field in self.fields:
            fields += render_field(field, form, form_style, context)

        return render_to_string(self.template, Context({'div': self, 'fields': fields}))
Ejemplo n.º 36
0
    def render(self, form, form_style, context):
        fields = ""
        for field in self.fields:
            fields += render_field(field, form, form_style, context)

        return render_to_string(self.template, Context({"div": self, "fields": fields}))
Ejemplo n.º 37
0
 def render(self, form, form_style, context):
     html = ""
     for field in self.fields:
         html += render_field(field, form, form_style, context)
     return html
Ejemplo n.º 38
0
    def render(self, form, form_style, context):
        html = u""
        for field in self.fields:
            html += render_field(field, form, form_style, context)

        return render_to_string(self.template, Context({"buttonholder": self, "fields_output": html}))
Ejemplo n.º 39
0
 def render(self, form, form_style, context):
     html = ''
     for field in self.fields:
         html += render_field(field, form, form_style, context, template=self.template, attrs=self.attrs)
     return html
Ejemplo n.º 40
0
    def render(self, form, form_style, context):
        html = u''
        for field in self.fields:
            html += render_field(field, form, form_style, context)

        return render_to_string(self.template, Context({'formactions': self, 'fields_output': html}))
Ejemplo n.º 41
0
 def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
     html = ''
     for field in self.fields:
         html += render_field(field, form, form_style, context, template=self.template, attrs=self.attrs, template_pack=template_pack)
     return html
Ejemplo n.º 42
0
    def render(self, form, form_style, context, template_pack=TEMPLATE_PACK):
        fields = ''
        for field in self.fields:
            fields += render_field(field, form, form_style, context, template_pack=template_pack)

        return render_to_string(self.template, Context({'div': self, 'fields': fields}))
Ejemplo n.º 43
0
    def render(self, form, form_style, context, template_pack="bootstrap"):
        html = u""
        for field in self.fields:
            html += render_field(field, form, form_style, context, template_pack=template_pack)

        return render_to_string(self.template, Context({"formactions": self, "fields_output": html}))
Ejemplo n.º 44
0
 def render(self, form, form_style, context):
     context.update({'crispy_appended_text': self.appended_text,
                     'crispy_prepended_text': self.prepended_text,
                     'active': getattr(self, "active", False)})
     return render_field(self.field, form, form_style, context, template=self.template, attrs=self.attrs)