Пример #1
0
    def old_as_table_for_dual_form (self):
        """
        Returns this form rendered as HTML <tr>s -- excluding the <table></table>.

        - Bolds the labels of the required fields

        - Includes a display version of the data (aka preview) if an existing instance is supplied

        Copied and modified from django.forms.forms.Form
        JJW 7/11/12
        """
        self.handle_required_fields()

        thead = tags.thead (tags.tr (tags.th (self.header + '&nbsp;' + tags.button ('Toggle Edit', d='edit%s' % self.myname, cls='nice small green radius button'), colspan=self.columns))) if self.header else ''

        if self.initial:  # filled with data
            #preview_rows = [('<td>%s:</td><td>%s</td><td>%s</td>' % (field.label, field.value, field.help_text)) for name, field in self.fields.items()]
            preview_rows = [('<th>%s:</th><td>%s</td><td>%s</td>' % (field.label, getattr (self.instance, name, ''), field.help_text)) for name, field in self.fields.items()]
            preview = '<tr>%s</tr>' % '</tr><tr>'.join (preview_rows) if preview_rows else ''
            normal_row = u'<tr%(html_class_attr)s class="hidden"><th>%(label)s</th><td>%(errors)s%(field)s</td><td title="%(help_text)s">%(help_text).50s</td></tr>'
        else:
            preview = ''
            normal_row = u'<tr%(html_class_attr)s><th>%(label)s</th><td>%(errors)s%(field)s</td><td title="%(help_text)s">%(help_text).50s</td></tr>'

        rows = preview + self._html_output (
            normal_row = normal_row,  # u'<tr%(html_class_attr)s><th>%(label)s</th><td>%(errors)s%(field)s</td><td>%(help_text)s</td></tr>',
            error_row = u'<tr><td colspan="2">%s</td></tr>',
            row_ender = u'</td></tr>',
            #help_text_html = u'<br /><span class="helptext">%s</span>',
            #help_text_html = u'<span class="helptext">%s</span>',
            help_text_html = u'My Help Text: %s',
            errors_on_separate_row = False
        )

        return mark_safe (thead + tags.tbody (rows, d=self.myname))
Пример #2
0
    def old_as_table_for_dual_form (self):
        """
        Returns this form rendered as HTML <tr>s -- excluding the <table></table>.

        - Bolds the labels of the required fields

        - Includes a display version of the data (aka preview) if an existing instance is supplied

        Copied and modified from django.forms.forms.Form
        JJW 7/11/12
        """
        self.handle_required_fields()

        thead = tags.thead (tags.tr (tags.th (self.header + '&nbsp;' + tags.button ('Toggle Edit', d='edit%s' % self.myname, cls='nice small green radius button'), colspan=self.columns))) if self.header else ''

        if self.initial:  # filled with data
            #preview_rows = [('<td>%s:</td><td>%s</td><td>%s</td>' % (field.label, field.value, field.help_text)) for name, field in self.fields.items()]
            preview_rows = [('<th>%s:</th><td>%s</td><td>%s</td>' % (field.label, getattr (self.instance, name, ''), field.help_text)) for name, field in self.fields.items()]
            preview = '<tr>%s</tr>' % '</tr><tr>'.join (preview_rows) if preview_rows else ''
            normal_row = u'<tr%(html_class_attr)s class="hidden"><th>%(label)s</th><td>%(errors)s%(field)s</td><td title="%(help_text)s">%(help_text).50s</td></tr>'
        else:
            preview = ''
            normal_row = u'<tr%(html_class_attr)s><th>%(label)s</th><td>%(errors)s%(field)s</td><td title="%(help_text)s">%(help_text).50s</td></tr>'

        rows = preview + self._html_output (
            normal_row = normal_row,  # u'<tr%(html_class_attr)s><th>%(label)s</th><td>%(errors)s%(field)s</td><td>%(help_text)s</td></tr>',
            error_row = u'<tr><td colspan="2">%s</td></tr>',
            row_ender = u'</td></tr>',
            #help_text_html = u'<br /><span class="helptext">%s</span>',
            #help_text_html = u'<span class="helptext">%s</span>',
            help_text_html = u'My Help Text: %s',
            errors_on_separate_row = False
        )

        return mark_safe (thead + tags.tbody (rows, d=self.myname))
Пример #3
0
    def cart_summary_table (self):  # Returns table innards
        smry      = self.cart_summary()
        totqty    = smry ['totqty']
        grandtot  = smry ['grandtot']
        totweight = smry ['totweight']

        return tags.tbody (
          tags.tr (tags.th ('Items') + tags.td (totqty)) +
          tags.tr (tags.th ('Total') + tags.td ('$%.2f' % grandtot)) +
          tags.tr (tags.th ('Shipping Weight') + tags.td ('%s lbs' % totweight)) +
          tags.tr (tags.th ('Subtotal (pre-tax)') + tags.td ('$%.2f' % (grandtot+totweight))) +
          tags.tr (tags.th ('Tax') + tags.td ('TBD'))
        )
Пример #4
0
    def cart_summary_table (self):  # Returns table innards
        smry      = self.cart_summary()
        totqty    = smry ['totqty']
        grandtot  = smry ['grandtot']
        totweight = smry ['totweight']

        return tags.tbody (
          tags.tr (tags.th ('Items') + tags.td (totqty)) +
          tags.tr (tags.th ('Total') + tags.td ('$%.2f' % grandtot)) +
          tags.tr (tags.th ('Shipping Weight') + tags.td ('%s lbs' % totweight)) +
          tags.tr (tags.th ('Subtotal (pre-tax)') + tags.td ('$%.2f' % (grandtot+totweight))) +
          tags.tr (tags.th ('Tax') + tags.td ('TBD'))
        )