Esempio n. 1
0
    def cart_details (self):
        totqty, grandtot = self.cart_totals()
        session          = self.session
        cart             = session.get ('cart', None)

        if not cart: return None

        table = tags.table (
                tags.thead (tags.tr (tags.th ('Line', 'Sku', 'Summary','Notes','Qty','New qty', 'Price', 'Ext'))) +
                #tags.thead (tags.tr (tags.th ('Line', 'Sku', 'Summary','Qty','New qty', 'Price', 'Ext'))) +
                tags.treo (
                    [tags.td (num + 1,
                            line['sku'],
                            line.get ('summary',''),
                            line.get ('notes',''),
                            line['qty'],
                            tags.input (name="updqty", size=3, width=3),
                            # + tags.input (name="ordlin", type='hidden', value=num),
                            '$%.2f' % line['totprice'],
                            '$%.2f' % (line['qty']*line['totprice']))
                        for num, line in enumerate (cart)]
                ) +
                #tags.tfoot (tags.tr (tags.th ('Total for %s items:' % totqty, colspan=7) + tags.th ('$%.2f' % grandtot))),
                tags.tfoot (tags.tr (tags.th ('Total for %s items:' % totqty, colspan=6) + tags.th ('$%.2f' % grandtot))),
            d='cart', width='100%')
        return table
Esempio n. 2
0
    def cart_details (self):
        totqty, grandtot = self.cart_totals()
        session          = self.session
        cart             = session.get ('cart', None)

        if not cart: return None

        table = tags.table (
                tags.thead (tags.tr (tags.th ('Line', 'Sku', 'Summary','Notes','Qty','New qty', 'Price', 'Ext'))) +
                #tags.thead (tags.tr (tags.th ('Line', 'Sku', 'Summary','Qty','New qty', 'Price', 'Ext'))) +
                tags.treo (
                    [tags.td (num + 1,
                            line['sku'],
                            line.get ('summary',''),
                            line.get ('notes',''),
                            line['qty'],
                            tags.input (name="updqty", size=3, width=3),
                            # + tags.input (name="ordlin", type='hidden', value=num),
                            '$%.2f' % line['totprice'],
                            '$%.2f' % (line['qty']*line['totprice']))
                        for num, line in enumerate (cart)]
                ) +
                #tags.tfoot (tags.tr (tags.th ('Total for %s items:' % totqty, colspan=7) + tags.th ('$%.2f' % grandtot))),
                tags.tfoot (tags.tr (tags.th ('Total for %s items:' % totqty, colspan=6) + tags.th ('$%.2f' % grandtot))),
            d='cart', width='100%')
        return table
Esempio n. 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'))
        )
Esempio n. 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'))
        )
Esempio n. 5
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))
Esempio n. 6
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))