def get_namespace(self, resource, context): namespace = {} cart = ProductCart(context) widget = SelectWidget('delivery_address', has_empty_option=False) namespace['delivery_address'] = widget.to_html( Addresses_Enumerate, cart.addresses['delivery_address']) widget = SelectWidget('bill_address', has_empty_option=False) namespace['bill_address'] = widget.to_html( Addresses_Enumerate, cart.addresses['bill_address']) return namespace
def get_namespace(self, resource, context): namespace = {} cart = ProductCart(context) widget = SelectWidget('delivery_address', has_empty_option=False) namespace['delivery_address'] = widget.to_html(Addresses_Enumerate, cart.addresses['delivery_address']) widget = SelectWidget('bill_address', has_empty_option=False) namespace['bill_address'] = widget.to_html(Addresses_Enumerate, cart.addresses['bill_address']) return namespace
def get_namespace(self, datatype, value): # XXX Hack to get tax value (and keep it when submit form) context = get_context() submit = (context.method == 'POST') prefix = self.prefix if submit: tax_value = context.get_form_value('%stax' % prefix, type=TaxesEnumerate) has_reduction = context.get_form_value('%shas_reduction' % prefix, type=Boolean) reduce_pre_tax_price = context.get_form_value( '%sreduce-pre-tax-price' % prefix) else: tax_value = context.resource.get_property('%stax' % prefix) has_reduction = context.resource.get_property('%shas_reduction' % prefix) reduce_pre_tax_price = context.resource.get_property( '%sreduce-pre-tax-price' % prefix) taxes = SelectWidget('%stax' % prefix, css='tax-widget', has_empty_option=False) # Devise shop = get_shop(context.resource) devise = shop.get_property('devise') symbol = Devises.get_symbol(devise) # Return namespace return { 'widget_name': self.name, 'pre-tax-price': value, 'prefix': prefix, 'devise': symbol, 'reduce-pre-tax-price': reduce_pre_tax_price, 'has_reduction': has_reduction, 'taxes': taxes.to_html(TaxesEnumerate, tax_value) }
def get_namespace(self, datatype, value): # XXX Hack to get tax value (and keep it when submit form) context = get_context() submit = (context.method == 'POST') prefix = self.prefix if submit: tax_value = context.get_form_value('%stax' % prefix, type=TaxesEnumerate) has_reduction = context.get_form_value('%shas_reduction' % prefix, type=Boolean) reduce_pre_tax_price = context.get_form_value('%sreduce-pre-tax-price' % prefix) else: tax_value = context.resource.get_property('%stax' % prefix) has_reduction = context.resource.get_property('%shas_reduction' % prefix) reduce_pre_tax_price = context.resource.get_property('%sreduce-pre-tax-price' % prefix) taxes = SelectWidget('%stax' % prefix, css='tax-widget', has_empty_option=False) # Devise shop = get_shop(context.resource) devise = shop.get_property('devise') symbol = Devises.get_symbol(devise) # Return namespace return {'widget_name': self.name, 'pre-tax-price': value, 'prefix': prefix, 'devise': symbol, 'reduce-pre-tax-price': reduce_pre_tax_price, 'has_reduction': has_reduction, 'taxes': taxes.to_html(TaxesEnumerate, tax_value)}
def get_item_value(self, resource, context, item, column): handler = resource.handler if column == 'checkbox': return item.id, False elif column == 'title': id = item.id title = handler.get_record_value(item, 'title') link = context.get_link(resource) return title, '%s/;edit_record?id=%s' % (link, id) elif column == 'countries': from countries import CountriesEnumerate datatype = CountriesEnumerate(zone=item.id) widget = SelectWidget('l_%s' % item.id, has_empty_option=False) h_widget = widget.to_html(datatype, None) link = '/shop/countries?zone=%i&search=' % item.id link = self.link_template % link h_link = XMLParser(link) return list(h_widget) + list(h_link) elif column == 'has_tax': has_tax = handler.get_record_value(item, 'has_tax') return bool_to_img(has_tax)
def get_namespace(self, resource, context): datatype = CategoriesSortEnumerate value = str(context.uri) widget = SelectWidget('sort_by', has_empty_option=False) return {'widget': widget.to_html(datatype, value)}