def retrieve_product(self, product): product_slug = helper.slug(product.strip()) temp_product = g.db.products.find_one({'db_name': product_slug}) if temp_product: return Product(temp_product) return str(product)
def validate_title(self, field): found = g.db.limit_maps.find_one({ 'product': self.product.data, 'slug': slug(self.title.data) }) if found: if str(found.get('_id')) != str(self.id.data): raise validators.ValidationError('Duplicate limit')
def validate_title(self, field): found = g.db.limit_maps.find_one( { 'product': self.product.data, 'slug': slug(self.title.data) } ) if found: if str(found.get('_id')) != str(self.id.data): raise validators.ValidationError('Duplicate limit')
def __init__(self, data): self.product = data.get('product') self.title = normalize(data.get('title')) self.uri = data.get('uri') self.absolute_path = data.get('absolute_path') self.absolute_type = data.get('absolute_type') self.limit_key = data.get('limit_key') self.value_key = data.get('value_key') self.active = bool(data.get('active')) self.id = data.get('_id') self.slug = slug(data.get('title'))