示例#1
0
文件: categories.py 项目: hforge/shop
 def _get_catalog_values(self):
     # Get the languages
     site_root = self.get_site_root()
     languages = site_root.get_property('website_languages')
     # Titles
     m_title = {}
     m_breadcrumb_title = {}
     for language in languages:
         value = self.get_property('title', language=language)
         if value:
             m_title[language] = value
         value = self.get_property('breadcrumb_title', language=language)
         if value:
             m_breadcrumb_title[language] = value
     # Data
     data = self.get_property('data')
     if data is not None:
         data = xml_to_text(data)
     return merge_dicts(
         super(Category, self)._get_catalog_values(),
         data=data,
         # XXX Hack to be on sitemap
         workflow_state='public',
         m_title=m_title,
         m_breadcrumb_title=m_breadcrumb_title)
示例#2
0
 def _get_catalog_values(self):
     # Get the languages
     site_root = self.get_site_root()
     languages = site_root.get_property('website_languages')
     # Titles
     m_title = {}
     m_breadcrumb_title = {}
     for language in languages:
         value = self.get_property('title', language=language)
         if value:
             m_title[language] = value
         value = self.get_property('breadcrumb_title', language=language)
         if value:
             m_breadcrumb_title[language] = value
     # Data
     data = self.get_property('data')
     if data is not None:
         data = xml_to_text(data)
     return merge_dicts(
         super(Category, self)._get_catalog_values(),
         data=data,
         # XXX Hack to be on sitemap
         workflow_state='public',
         m_title=m_title,
         m_breadcrumb_title=m_breadcrumb_title)
示例#3
0
文件: csv_views.py 项目: hforge/crm
 def encode(cls, value):
     """Encode to a unicode or a Python value compatible with str().
     """
     # TODO in 0.70 read datatype from class_schema
     datatype = cls.datatype
     # Replace enumerate name by value
     if issubclass(datatype, Enumerate):
         value = datatype.get_value(value)
     if value is None:
         return ''
     # Default encoders
     value_type = type(value)
     if value_type is XMLParser or value_type is list:
         return xml_to_text(value)
     if is_thingy(value, MSG):
         value = value.gettext()
     return value
示例#4
0
 def get_item_value(self, resource, context, item, column, site_root):
     brain, item_resource = item
     if isinstance(item_resource, Product) is False:
         return NeutralWS_RSS.get_item_value(self, resource, context,
                                             item, column, site_root)
     if column == 'description':
         value = item_resource.get_property('data')
         if value:
             value = unicode(xml_to_text(value))
             value += u'<br/><br/>'
         else:
             value = ''
         # Add category
         category = item_resource.parent
         value += u'Catégorie %s' % category.get_title()
         return value
     return NeutralWS_RSS.get_item_value(self, resource, context,
                                         item, column, site_root)
示例#5
0
文件: csv_views.py 项目: hforge/shop
 def encode(self, resource, column, value, encoding='utf-8'):
     file_schema = self.get_file_schema(resource)
     datatype = file_schema[column]
     data = value
     # Replace enumerate name by value
     if issubclass(datatype, Enumerate):
         data = datatype.get_value(data)
     if data is None:
         return ''
     # Default encoders
     data_type = type(data)
     if data_type is XMLParser:
         return xml_to_text(data)
     elif data_type is list:
         return str(data)
     if isinstance(data, MSG):
         data = data.gettext()
     return data
示例#6
0
 def encode(self, resource, column, value, encoding='utf-8'):
     file_schema = self.get_file_schema(resource)
     datatype = file_schema[column]
     data = value
     # Replace enumerate name by value
     if issubclass(datatype, Enumerate):
         data = datatype.get_value(data)
     if data is None:
         return ''
     # Default encoders
     data_type = type(data)
     if data_type is XMLParser:
         return xml_to_text(data)
     elif data_type is list:
         return str(data)
     if isinstance(data, MSG):
         data = data.gettext()
     return data
示例#7
0
 def get_item_value(self, resource, context, item, column, site_root):
     brain, item_resource = item
     if isinstance(item_resource, Product) is False:
         return NeutralWS_RSS.get_item_value(self, resource, context, item,
                                             column, site_root)
     if column == 'description':
         value = item_resource.get_property('data')
         if value:
             value = unicode(xml_to_text(value))
             value += u'<br/><br/>'
         else:
             value = ''
         # Add category
         category = item_resource.parent
         value += u'Catégorie %s' % category.get_title()
         return value
     return NeutralWS_RSS.get_item_value(self, resource, context, item,
                                         column, site_root)
示例#8
0
 def _get_catalog_values(self):
     values = merge_dicts(DynamicFolder._get_catalog_values(self),
                          TagsAware._get_catalog_values(self),
                          self._get_dynamic_catalog_values())
     # Data
     data = self.get_property('data')
     if data is not None:
         data = xml_to_text(data)
     values['data'] = data
     # Reference
     values['reference'] = self.get_property('reference')
     # Manufacturer
     values['manufacturer'] = str(self.get_property('manufacturer'))
     # Supplier
     values['supplier'] = str(self.get_property('supplier'))
     # Stock quantity
     values['stock_quantity'] = self.get_property('stock-quantity')
     # Product models
     values['product_model'] = str(self.get_property('product_model'))
     # Images
     order = self.get_resource('order-photos', soft=True)
     if order:
         ordered_names = list(order.get_ordered_names())
         values['has_images'] = (len(ordered_names) != 0)
     else:
         values['has_images'] = False
     # Price # XXX We can't sort decimal, so transform to int
     values['stored_price'] = int(self.get_price_with_tax() * 100)
     values['stored_weight'] = int(self.get_weight() * 100)
     # Price
     values['ht_price'] = self.get_price_without_tax()
     values['ttc_price'] = self.get_price_with_tax()
     # Creation time
     values['ctime'] = self.get_property('ctime')
     # Publication date
     values['pub_datetime'] = self.get_property('pub_datetime')
     # Promotion
     values['has_reduction'] = self.get_property('has_reduction')
     # not_buyable_by_groups
     values['not_buyable_by_groups'] = self.get_property(
         'not_buyable_by_groups')
     return values
示例#9
0
文件: product.py 项目: hforge/shop
 def _get_catalog_values(self):
     values = merge_dicts(DynamicFolder._get_catalog_values(self),
                          TagsAware._get_catalog_values(self),
                          self._get_dynamic_catalog_values())
     # Data
     data = self.get_property('data')
     if data is not None:
         data = xml_to_text(data)
     values['data'] = data
     # Reference
     values['reference'] = self.get_property('reference')
     # Manufacturer
     values['manufacturer'] = str(self.get_property('manufacturer'))
     # Supplier
     values['supplier'] = str(self.get_property('supplier'))
     # Stock quantity
     values['stock_quantity'] = self.get_property('stock-quantity')
     # Product models
     values['product_model'] = str(self.get_property('product_model'))
     # Images
     order = self.get_resource('order-photos', soft=True)
     if order:
         ordered_names = list(order.get_ordered_names())
         values['has_images'] = (len(ordered_names) != 0)
     else:
         values['has_images'] = False
     # Price # XXX We can't sort decimal, so transform to int
     values['stored_price'] = int(self.get_price_with_tax() * 100)
     values['stored_weight'] = int(self.get_weight() * 100)
     # Price
     values['ht_price'] = self.get_price_without_tax()
     values['ttc_price'] = self.get_price_with_tax()
     # Creation time
     values['ctime'] = self.get_property('ctime')
     # Publication date
     values['pub_datetime'] = self.get_property('pub_datetime')
     # Promotion
     values['has_reduction'] = self.get_property('has_reduction')
     # not_buyable_by_groups
     values['not_buyable_by_groups'] = self.get_property('not_buyable_by_groups')
     return values
示例#10
0
 def to_text(self):
     """Removes the markup and returns a plain text string.
     """
     return xml_to_text(self.events)
示例#11
0
文件: odf.py 项目: kennym/itools
 def to_text(self):
     content = self.get_file('content.xml')
     return xml_to_text(content)
示例#12
0
文件: odf.py 项目: mmather02/itools
 def to_text(self):
     content = self.get_file('content.xml')
     return xml_to_text(content)
示例#13
0
文件: xmlfile.py 项目: hforge/itools
 def to_text(self):
     """Removes the markup and returns a plain text string.
     """
     return xml_to_text(self.events)