def get(self): categories = MenuCategory.query().fetch() for category in categories: category.items = [] for item in category.get_items(): category.items.append(item) self.render('/promos/gift_add.html', categories=categories)
def get(self): modifier_type = self.request.get_range('modifier_type') modifier = None if modifier_type == SINGLE_MODIFIER: modifier = SingleModifier.get_by_id(self.request.get_range('modifier_id')) elif modifier_type == GROUP_MODIFIER: modifier = GroupModifier.get_by_id(self.request.get_range('modifier_id')) else: self.abort(400) categories = MenuCategory.query().fetch() for category in categories: category.products = [] for product in category.get_items(only_available=True): category.products.append(product) if modifier_type == SINGLE_MODIFIER: if modifier.key in product.single_modifiers: product.has_modifier = True else: product.has_modifier = False elif modifier_type == GROUP_MODIFIER: if modifier.key in product.group_modifiers: product.has_modifier = True else: product.has_modifier = False self.render('/menu/select_products_modifier.html', **{ 'categories': categories, 'modifier': modifier, 'modifier_type': modifier_type })
def _get_category_ids(current_id): q = Queue() q.put(current_id) cats = [] while not q.empty(): current_id = q.get() cats.append(current_id) for category in MenuCategory.query( MenuCategory.category == ndb.Key(MenuCategory, current_id)): q.put(category.key.id()) return cats
def get(self): promo_id = self.request.get_range('promo_id') promo = Promo.get_by_id(promo_id) if not promo: self.abort(400) feature_type = self.request.get_range('feature_type') if feature_type not in FEATURES_TYPES: self.abort(400) number = self.request.get_range('number') if feature_type == OUTCOME: if len(promo.outcomes) <= number: self.abort(400) feature = promo.outcomes[number] feature_name = OUTCOME_MAP[feature.method] elif feature_type == CONDITION: if len(promo.conditions) <= number: self.abort(400) feature = promo.conditions[number] feature_name = CONDITION_MAP[feature.method] else: feature_name = u'Не найдено' feature = None categories = MenuCategory.query().fetch() for category in categories: items = [] for item in category.get_items(): if item.key == feature.item_details.item: item.has = True else: item.has = False items.append(item) category.items = items self.render( '/promos/choose_product.html', **{ 'categories': categories, 'promo': promo, 'feature': feature, 'feature_name': feature_name, 'feature_number': number, })
def get(self): venue_id = self.request.get_range('venue_id') venue_key = ndb.Key('Venue', venue_id) venue = Venue.get_by_id(venue_id) if not venue: self.abort(400) categories = [] for category in MenuCategory.query().fetch(): products = [] for product in category.get_items(only_available=True): if venue_key in product.restrictions: product.avail = False else: product.avail = True products.append(product) category.products = products if products: categories.append(category) self.render('/menu/select_products_restriction.html', **{ 'categories': categories, 'venue': venue })