コード例 #1
0
ファイル: product.py プロジェクト: axant/tgext.ecommerce
 def search(cls, text, fields=('name', 'description'), language=None):
     language = language or preferred_language()
     filters = []
     for field in fields:
         field = '%s.%s' % (field, language)
         filters.append({field: re.compile(text, re.I)})
     products = models.Product.query.find({'$or': filters, 'published': {'$ne': False}, 'active': {'$ne': False}})
     return products
コード例 #2
0
ファイル: models.py プロジェクト: axant/tgext.ecommerce
 def i18n_ancestor_name(cls, ancestor):
     return ancestor.name.get(preferred_language(), ancestor.name.get(tg.config.lang))
コード例 #3
0
ファイル: models.py プロジェクト: axant/tgext.ecommerce
 def i18n_name(self):
     return self.name.get(preferred_language(), self.name.get(tg.config.lang))
コード例 #4
0
ファイル: models.py プロジェクト: axant/tgext.ecommerce
 def i18n_configuration_variety(self, configuration):
     return configuration.variety.get(preferred_language(), configuration.variety.get(tg.config.lang))
コード例 #5
0
ファイル: models.py プロジェクト: axant/tgext.ecommerce
 def i18n_description(self):
     return self.description.get(preferred_language(), self.description.get(tg.config.lang))
コード例 #6
0
ファイル: helpers.py プロジェクト: axant/tgext.ecommerce
def i_entity_value(entity, key):
    return entity.get(key).get(preferred_language(), entity.get(key).get(config.lang))