예제 #1
0
 def dict(self):
     result = memcache.get(
         'gift_items_%s_%s' %
         (namespace_manager.get_namespace(), self.key.id()))
     if not result:
         item = self.item.get()
         result = item.dict()
         result['id'] = str(self.key.id())
         result.update({'points': self.points})
         for modifier in result['group_modifiers']:
             choice_dicts = modifier['choices']
             for choice_dict in choice_dicts[:]:
                 if int(choice_dict['id']
                        ) in self.additional_group_choice_restrictions:
                     choice_dict['price'] = 0
                     modifier['choices'] = [choice_dict]
                     break
         for modifier in result['single_modifiers'][:]:
             if modifier['price'] > 0:
                 result['single_modifiers'].remove(modifier)
         if self.additional_group_choice_restrictions:
             result['title'] = u'%s %s' % (item.title, u','.join([
                 GroupModifier.get_modifier_by_choice(
                     choice).get_choice_by_id(choice).title
                 for choice in self.additional_group_choice_restrictions
             ]))
         memcache.set('gift_items_%s_%s' %
                      (namespace_manager.get_namespace(), self.key.id()),
                      result,
                      time=24 * 3600)
     return result
예제 #2
0
def get_shared_gifts(client):
    if not ShareGiftModule.has_module():
        return []
    shared_gifts = SharedGift.query(
        SharedGift.recipient_id == client.key.id(),
        SharedGift.status == SharedGift.PERFORMING).fetch()
    shared_gift_dict = []
    for shared_gift in shared_gifts:
        for shared_item in shared_gift.share_items:
            shared_item = shared_item.get()
            chosen_group_modifiers = []
            for choice_id in shared_item.group_choice_ids:
                modifier = GroupModifier.get_modifier_by_choice(choice_id)
                modifier.choice = modifier.get_choice_by_id(choice_id)
                chosen_group_modifiers.append(modifier)
            shared_menu_item = shared_item.shared_item.get()
            item = shared_menu_item.item.get()
            shared_gift_dict.append({
                'item':
                item,
                'image':
                item.picture,
                'single_modifier_keys':
                sorted(shared_item.single_modifiers,
                       key=lambda modifier_key: modifier_key.id()),
                'group_modifier_keys':
                [(modifier.key, modifier.choice.choice_id)
                 for modifier in sorted(chosen_group_modifiers,
                                        key=lambda modifier: modifier.key.id())
                 ],
                'share_gift_obj':
                shared_gift
            })
    return shared_gift_dict
예제 #3
0
 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
     })
예제 #4
0
 def get_item(new_item, choice):
     for result_item in result_items:
         if result_item.title == title:
             result_item.modifier.choices.append(choice)
             return None
     new_item.modifier = GroupModifier(id='grains_%s' % new_item.key.id(), title=u'Зерна', choices=[choice])
     return new_item
예제 #5
0
 def post(self):
     group_modifier_id = self.request.get_range('group_modifier_id')
     group_modifier = GroupModifier.get_by_id(group_modifier_id)
     if not group_modifier:
         self.abort(400)
     group_modifier.title = self.request.get('name')
     group_modifier.put()
     self.redirect_to('modifiers_list')
예제 #6
0
 def get(self):
     group_modifier_id = self.request.get_range('group_modifier_id')
     group_modifier = GroupModifier.get_by_id(group_modifier_id)
     if not group_modifier:
         self.abort(400)
     self.render('/menu/add_group_modifier.html', **{
         'group_modifier': group_modifier
     })
예제 #7
0
 def get(self):
     modifier_id = self.request.get_range('modifier_id')
     modifier = GroupModifier.get_by_id(modifier_id)
     if not modifier:
         self.abort(400)
     self.render('/menu/select_default_choice.html', **{
         'modifier': modifier,
         'choices': modifier.choices
     })
예제 #8
0
 def post(self):
     modifier_id = self.request.get_range('modifier_id')
     modifier = GroupModifier.get_by_id(modifier_id)
     if not modifier:
         self.abort(400)
     choice_id = self.request.get_range('choice_id')
     for choice in modifier.choices:
         choice.default = choice.choice_id == choice_id
     modifier.put()
     self.redirect_to('modifiers_list')
예제 #9
0
 def get(self):
     gifts = GiftMenuItem.query().fetch()
     for gift in gifts:
         gift.title = gift.item.get().title
         choice_titles = []
         for choice_id in gift.additional_group_choice_restrictions:
             choice = GroupModifier.get_modifier_by_choice(
                 choice_id).get_choice_by_id(choice_id)
             choice_titles.append(choice.title)
         if choice_titles:
             gift.title += u'(%s)' % u', '.join(choice_titles)
     self.render('/promos/gift_list.html', gifts=gifts)
예제 #10
0
 def post(self):
     for name in unique(self.request.params.getall('name')):
         if name:
             modifier = GroupModifier(title=name)
             modifier.sequence_number = GroupModifier.generate_sequence_number()
             modifier.put()
     self.redirect_to('modifiers_list')
예제 #11
0
 def post(self):
     modifier_id = self.request.get_range('modifier_id')
     modifier = GroupModifier.get_by_id(modifier_id)
     previous = modifier.get_previous_modifier()
     if not previous:
         self.abort(400)
     _swap_sequence_numbers(previous, modifier)
     modifier.put()
     previous.put()
     self.response.headers["Content-Type"] = "application/json"
     self.response.write(json.dumps({
         'success': True,
         'modifier_id': modifier.key.id(),
         'previous_id': previous.key.id()
     }, separators=(',', ':')))
예제 #12
0
    def post(self, group_modifier_id):
        name = self.request.get('name')
        prices = unique(self.request.params.getall('price'))

        group_modifier = GroupModifier.get_by_id(int(group_modifier_id))
        for price in prices:
            if not len(price):
                continue
            price = float(price)
            price = int(round(price * 100))
            choice = GroupModifierChoice.create(title=name, price=price)
            choice.sequence_number = group_modifier.generate_choice_sequence_number()
            group_modifier.choices.append(choice)
        group_modifier.put()
        self.redirect_to('modifiers_list')
예제 #13
0
 def post(self):
     modifier_id = self.request.get_range('modifier_id')
     modifier = GroupModifier.get_by_id(modifier_id)
     if not modifier:
         self.abort(400)
     next_ = modifier.get_next_modifier()
     if not next_:
         self.abort(400)
     _swap_sequence_numbers(modifier, next_)
     modifier.put()
     next_.put()
     self.response.headers["Content-Type"] = "application/json"
     self.response.write(json.dumps({
         'success': True,
         'modifier_id': modifier.key.id(),
         'next_id': next_.key.id()
     }, separators=(',', ':')))
예제 #14
0
 def get(self):
     venue_id = self.request.get_range('venue_id')
     if venue_id:
         venue = Venue.get_by_id(venue_id)
     else:
         venue = None
     single_modifier_ids = []
     group_modifier_ids = []
     products = MenuItem.query().fetch()
     for product in products:
         if venue and venue.key in product.restrictions:
             continue
         for modifier in product.group_modifiers:
             if modifier.id not in group_modifier_ids:
                 group_modifier_ids.append(modifier.id())
         for modifier in product.single_modifiers:
             if modifier.id not in single_modifier_ids:
                 single_modifier_ids.append(modifier.id())
     single_modifiers = SingleModifier.query().order(SingleModifier.sequence_number).fetch()
     for single_modifier in single_modifiers:
         single_modifier.products = []
         for product in products:
             if single_modifier.key in product.single_modifiers:
                 single_modifier.products.append(product)
         if single_modifier.key.id() in single_modifier_ids:
             single_modifier.enable = True
         else:
             single_modifier.enable = False
     group_modifiers = GroupModifier.query().order(GroupModifier.sequence_number).fetch()
     for group_modifier in group_modifiers:
         group_modifier.choices = sorted(group_modifier.choices, key=lambda choice: choice.sequence_number)
         group_modifier.products = []
         for product in products:
             if group_modifier.key in product.group_modifiers:
                 group_modifier.products.append(product)
         if group_modifier.key.id() in group_modifier_ids:
             group_modifier.enable = True
         else:
             group_modifier.enable = False
     self.render('/menu/modifiers.html', **{
         'single_modifiers': single_modifiers,
         'group_modifiers': group_modifiers,
         'inf': SingleModifier.INFINITY,
         'venues': Venue.query().fetch(),
         'chosen_venue': venue
     })
예제 #15
0
 def post(self):
     key = self.request.get('key')
     choice_id = int(key.split('_')[0])
     modifier_id = int(key.split('_')[1])
     modifier = GroupModifier.get_by_id(modifier_id)
     if not modifier:
         self.abort(400)
     choice = modifier.get_choice_by_id(choice_id)
     if not choice:
         self.abort(400)
     next_ = modifier.get_next_choice(choice)
     if not next_:
         self.abort(400)
     _swap_sequence_numbers(choice, next_)
     modifier.put()
     self.response.headers["Content-Type"] = "application/json"
     self.response.write(json.dumps({
         'success': True
     }, separators=(',', ':')))
예제 #16
0
 def post(self):
     choice_id = self.request.get_range('modifier_id')
     choice = GroupModifierChoice.get_by_choice_id(choice_id)
     if not choice:
         self.abort(400)
     choice.title = self.request.get('name')
     if self.request.get('price'):
         price = float(self.request.get('price'))
         choice.price = int(round(price * 100))
     else:
         choice.price = 0
     choice.put()
     modifier = GroupModifier.get_modifier_by_choice(choice_id)
     for m_choice in modifier.choices:
         if m_choice.choice_id == choice_id:
             modifier.choices.remove(m_choice)
             modifier.choices.append(choice)
     modifier.put()
     self.redirect_to('modifiers_list')
예제 #17
0
def _group_group_modifiers(modifiers):
    result = {}
    for modifier in modifiers:
        key = '%s%s' % (modifier[0].id, modifier[1])
        if key in result:
            result[key]['quantity'] += 1
        else:
            modifier_obj = GroupModifier.get(modifier[0].id())
            if not modifier_obj:
                continue
            choice = modifier_obj.get_choice_by_id(modifier[1])
            if modifier_obj and choice:
                result[key] = {
                    'id': str(modifier[0].id()),
                    'name': choice.title,
                    'choice': str(modifier[1]),
                    'quantity': 1
                }
    return result.values()
예제 #18
0
def __get_group_modifiers(resto_modifiers):
    group_modifiers = {}
    for resto_modifier in resto_modifiers:
        if not resto_modifier.get('groupId'):
            continue
        modifier = GroupModifier(id=resto_modifier['groupId'])
        modifier.title = resto_modifier['name']
        modifier.required = resto_modifier['minAmount'] != 0
        modifier.min_value = resto_modifier['minAmount']
        modifier.max_value = resto_modifier['maxAmount']

        modifier.choices = []
        for resto_choice in resto_modifier['items']:
            choice = GroupModifierChoice(choice_id_str=resto_choice['id'])
            choice.title = resto_choice['name']
            choice.price = int(resto_choice['price'] * 100)
            modifier.choices.append(choice)
        group_modifiers[modifier.key] = modifier
    return group_modifiers
예제 #19
0
 def _process_item_dict(item_dict, gift=False):
     item_obj = copy.copy(MenuItem.get_by_id(int(item_dict['id'])))
     item_obj.amount = item_dict['quantity']
     item_obj.total_float_price = item_obj.float_price * item_obj.amount
     item_obj.modifiers = []
     item_obj.is_gift = gift
     for modifier_dict in item_dict['single_modifiers']:
         modifier = SingleModifier.get_by_id(int(modifier_dict['id']))
         modifier.amount = modifier_dict['quantity']
         modifier.total_float_price = modifier.float_price * modifier.amount
         item_obj.total_float_price += modifier.total_float_price * item_obj.amount
         item_obj.modifiers.append(modifier)
     for modifier_dict in item_dict['group_modifiers']:
         modifier = GroupModifier.get_by_id(int(modifier_dict['id']))
         choice = modifier.get_choice_by_id(int(modifier_dict['choice']))
         choice.amount = modifier_dict['quantity']
         choice.total_float_price = choice.float_price * choice.amount
         item_obj.total_float_price += choice.total_float_price * item_obj.amount
         item_obj.modifiers.append(choice)
     if gift:
         item_obj.total_float_price = 0.0
     return item_obj
예제 #20
0
    def post(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)

        for product in MenuItem.query().fetch():
            confirmed = bool(self.request.get(str(product.key.id())))
            if modifier_type == SINGLE_MODIFIER:
                found = False
                for single_modifier in product.single_modifiers:
                    if single_modifier == modifier.key:
                        if not confirmed:
                            product.single_modifiers.remove(single_modifier)
                            product.put()
                        found = True
                if not found:
                    if confirmed:
                        product.single_modifiers.append(modifier.key)
                        product.put()
            elif modifier_type == GROUP_MODIFIER:
                found = False
                for group_modifier in product.group_modifiers:
                    if group_modifier == modifier.key:
                        if not confirmed:
                            product.group_modifiers.remove(group_modifier)
                            product.put()
                        found = True
                if not found:
                    if confirmed:
                        product.group_modifiers.append(modifier.key)
                        product.put()
            self.redirect_to('modifiers_list')
예제 #21
0
def set_modifiers(items, with_gift_obj=False, with_share_gift_obj=False):
    mod_items = []
    for item in items:
        menu_item = MenuItem.get(item['item_id'])
        if not menu_item and SubscriptionModule.has_module():
            menu_item = get_subscription_menu_item(item)
        menu_item = copy.copy(menu_item)
        if with_gift_obj:
            menu_item.gift_obj = item['gift_obj']
        else:
            if menu_item:
                menu_item.gift_obj = None
        if with_share_gift_obj:
            menu_item.share_gift_obj = item['share_gift_obj']
        else:
            menu_item.share_gift_obj = None
        menu_item.chosen_single_modifiers = []
        for single_modifier in item['single_modifiers']:
            single_modifier_obj = copy.copy(
                SingleModifier.get(single_modifier['single_modifier_id']))
            for i in xrange(single_modifier['quantity']):
                menu_item.chosen_single_modifiers.append(single_modifier_obj)
        menu_item.chosen_group_modifiers = []
        for group_modifier in item['group_modifiers']:
            group_modifier_obj = copy.copy(
                GroupModifier.get(group_modifier['group_modifier_id']))
            if not group_modifier_obj:
                continue
            group_modifier_obj.choice = group_modifier_obj.get_choice_by_id(
                group_modifier['choice'])
            if group_modifier_obj.choice:
                for i in xrange(group_modifier['quantity']):
                    menu_item.chosen_group_modifiers.append(group_modifier_obj)
        for i in xrange(item['quantity']):
            mod_items.append(menu_item)
    return mod_items
예제 #22
0
def menu_parse(file_excel):
    wb = xlrd.open_workbook(file_contents=file_excel)
    sh = wb.sheet_by_index(0)
    categories = {}
    products = {}
    group_modifiers = {}
    group_choices = {}
    for row_number in range(sh.nrows):
        if row_number > 0:
            current_category = MenuCategory()
            current_item = MenuItem()
            current_modifier = GroupModifier()
            current_choice = GroupModifierChoice()
            item_add = True
            for index, cell in enumerate(sh.row_values(row_number)):
                if index == 0:
                    current_category.sequence_number = int(cell)
                    current_item.sequence_number = int(cell)
                elif index == 1:
                    if categories.get(cell):
                        current_category = categories[cell]
                    else:
                        current_category.title = cell
                        categories[cell] = current_category
                elif index == 2:
                    if products.get(cell):
                        current_item = products[cell]
                        item_add = False
                    else:
                        current_item.title = cell
                        products[cell] = current_item
                elif index == 3:
                    if item_add:
                        current_item.description = cell
                elif index == 4 and cell:
                    if item_add:
                        current_item.price = int(float(cell) * 100)
                elif index == 5:
                    if item_add and cell:
                        current_item.volume = float(cell)
                elif index == 6:
                    if item_add and cell:
                        current_item.weight = float(cell)
                elif index == 7:
                    if item_add and cell:
                        current_item.kal = int(cell)
                elif index == 8:
                    if cell:
                        if group_modifiers.get(cell):
                            current_modifier = group_modifiers[cell]
                        else:
                            current_modifier.title = cell
                            group_modifiers[cell] = current_modifier
                elif index == 9:
                    if cell:
                        current_choice.title = cell
                elif index == 10:
                    if cell or cell == 0:
                        current_choice.price = int(float(cell) * 100)
                        key = '%s_%s' % (current_choice.title,
                                         current_choice.price)
                        if group_choices.get(key):
                            current_choice = group_choices[key]
                        else:
                            current_choice.choice_id = GroupModifierChoice.generate_id(
                            )
                            group_choices[key] = current_choice
                        if current_choice not in current_modifier.choices:
                            current_modifier.choices.append(current_choice)
                            current_choice.put()
            logging.info(current_modifier)
            if current_modifier.title:
                current_modifier.put()
                if current_modifier.key not in current_item.group_modifiers:
                    current_item.group_modifiers.append(current_modifier.key)
            current_item.put()
            if item_add:
                current_item.category = current_category.key
            current_category.put()
예제 #23
0
 def get(self):
     promos = Promo.query().order(-Promo.priority).fetch()
     for promo in promos:
         if promo.start:
             promo.start_str = promo.start.strftime(STR_DATETIME_FORMAT)
         else:
             promo.start_str = u'Не задано'
         if promo.end:
             promo.end_str = promo.end.strftime(STR_DATETIME_FORMAT)
         else:
             promo.end_str = u'Не задано'
         conditions = []
         for condition in promo.conditions[:]:
             if condition.item_details and condition.item_details.item:
                 choice_titles = []
                 for choice_id in condition.item_details.group_choice_ids:
                     choice = GroupModifier.get_modifier_by_choice(
                         choice_id).get_choice_by_id(choice_id)
                     choice_titles.append(choice.title)
                 condition.item_details.title = condition.item_details.item.get(
                 ).title
                 if choice_titles:
                     condition.item_details.title += u'(%s)' % u', '.join(
                         choice_titles)
             condition.value_string = str(
                 condition.value) if condition.value else ""
             if condition.method == PromoCondition.CHECK_TYPE_DELIVERY:
                 condition.value_string = DELIVERY_MAP[condition.value]
                 conditions.append(condition)
             elif condition.method in [
                     PromoCondition.CHECK_HAPPY_HOURS,
                     PromoCondition.CHECK_HAPPY_HOURS_CREATED_TIME
             ]:
                 for day in (condition.schedule.days
                             if condition.schedule else []):
                     new_condition = PromoCondition(method=condition.method)
                     new_condition.value_string = day.str()
                     conditions.append(new_condition)
             else:
                 conditions.append(condition)
         for outcome in promo.outcomes[:]:
             if outcome.item_details and outcome.item_details.item:
                 choice_titles = []
                 for choice_id in outcome.item_details.group_choice_ids:
                     choice = GroupModifier.get_modifier_by_choice(
                         choice_id).get_choice_by_id(choice_id)
                     choice_titles.append(choice.title)
                 outcome.item_details.title = outcome.item_details.item.get(
                 ).title
                 if choice_titles:
                     outcome.item_details.title += u'(%s)' % u', '.join(
                         choice_titles)
         promo.conditions = conditions
     self.render(
         '/promos/list.html', **{
             'promo_api_key':
             config.PROMOS_API_KEY if config.PROMOS_API_KEY else '',
             'wallet_api_key':
             config.WALLET_API_KEY if config.WALLET_API_KEY else '',
             'promos':
             promos,
             'condition_map':
             CONDITION_MAP,
             'outcome_map':
             OUTCOME_MAP
         })
예제 #24
0
 def post(self):
     for group_modifier in GroupModifier.query().fetch():
         confirmed = bool(self.request.get('required_%s' % group_modifier.key.id()))
         group_modifier.required = confirmed
         group_modifier.put()
     self.redirect('/company/menu/main')
예제 #25
0
    def post(self):
        venue = self.venue_or_error
        if not venue:
            return self.send_error(u'Нет связки с точкой')
        stop_list = json.loads(self.request.get('stop_list'))
        for item_id in stop_list.get('stopped'):
            item = MenuItem.get_by_id(int(item_id))
            if not item:
                return self.send_error(u'Продукт не найден')
            if item.status != STATUS_AVAILABLE:
                return self.send_error(
                    u'Продукт %s не имеет статуса доступен' % item.title)
            if venue.key in item.restrictions:
                return self.send_error(
                    u'Продукт %s недоступен в данном заведении' % item.title)
            if item.key in venue.stop_lists:
                return self.send_error(u'Продукт %s уже в стоп-листе' %
                                       item.title)
            venue.stop_lists.append(item.key)
        for item_id in stop_list.get('recovered'):
            item = MenuItem.get_by_id(int(item_id))
            if not item:
                return self.send_error(u'Продукт не найден')
            if item.status != STATUS_AVAILABLE:
                return self.send_error(
                    u'Продукт %s не имеет статуса доступен' % item.title)
            if venue.key in item.restrictions:
                return self.send_error(
                    u'Продукт %s недоступен в данном заведении' % item.title)
            if item.key not in venue.stop_lists:
                return self.send_error(
                    u'Продукт %s не находится в стоп-листе' % item.title)
            venue.stop_lists.remove(item.key)
        for single_modifier_id in stop_list.get('stopped_single_modifiers'):
            item = SingleModifier.get_by_id(int(single_modifier_id))
            if not item:
                return self.send_error(u'Одиночный модификатор не найден')
            if item.key in venue.single_modifiers_stop_list:
                return self.send_error(
                    u'Одиночный модификатор %s уже в стоп-листе' % item.title)
            venue.single_modifiers_stop_list.append(item.key)
        for single_modifier_id in stop_list.get('recovered_single_modifiers'):
            item = SingleModifier.get_by_id(int(single_modifier_id))
            if not item:
                return self.send_error(u'Одиночный модификатор не найден')
            if item.key not in venue.single_modifiers_stop_list:
                return self.send_error(
                    u'Одиночный модификатор %s не находится в стоп-листе' %
                    item.title)
            venue.single_modifiers_stop_list.remove(item.key)
        for group_choice_id in stop_list.get('stopped_group_choices'):
            item = GroupModifierChoice.query(
                GroupModifierChoice.choice_id == int(group_choice_id)).get()
            if not item:
                return self.send_error(
                    u'Выбор группового модификатора не найден')
            if item.key in venue.group_choice_modifier_stop_list:
                return self.send_error(
                    u'Выбор группового модификатора %s уже в стоп-листе' %
                    item.title)
            venue.group_choice_modifier_stop_list.append(item.key)
        for group_choice_id in stop_list.get('recovered_group_choices'):
            item = GroupModifierChoice.query(
                GroupModifierChoice.choice_id == int(group_choice_id)).get()
            if not item:
                return self.send_error(
                    u'Выбор группового модификатора не найден')
            if item.key not in venue.group_choice_modifier_stop_list:
                return self.send_error(
                    u'Выбор группового модификатора %s не находится в стоп-листе'
                    % item.title)
            venue.group_choice_modifier_stop_list.remove(item.key)

        for group_choice_id_with_item_id in stop_list.get(
                'stopped_group_choices_with_item_id'):
            group_choice_id = int(
                group_choice_id_with_item_id.get('choice_id'))
            item_id = group_choice_id_with_item_id.get('item_id')
            modifier = GroupModifier.get_modifier_by_choice(group_choice_id)
            item = MenuItem.get_by_id(int(item_id))
            if not modifier:
                return self.send_error(
                    u'Выбор группового модификатора не найден')
            if not item:
                return self.send_error(u"Продукт не найден")
            if modifier.key not in item.group_modifiers:
                return self.send_error(
                    u"Продукт не связан с этим групповым модификатором")
            if group_choice_id in item.stop_list_group_choices:
                return self.send_error(
                    u'Выбор группового модификатора %s уже в стоп-листе' %
                    item.title)
            item.stop_list_group_choices.append(group_choice_id)
            item.put()
        for group_choice_id_with_item_id in stop_list.get(
                'recovered_group_choices_with_item_id'):
            group_choice_id = int(
                group_choice_id_with_item_id.get('choice_id'))
            item_id = group_choice_id_with_item_id.get('item_id')
            modifier = GroupModifier.get_modifier_by_choice(group_choice_id)
            item = MenuItem.get_by_id(int(item_id))
            if not modifier:
                return self.send_error(
                    u'Выбор группового модификатора не найден')
            if not item:
                return self.send_error(u"Продукт не найден")
            if modifier.key not in item.group_modifiers:
                return self.send_error(
                    u"Продукт не связан с этим групповым модификатором")
            if group_choice_id not in item.stop_list_group_choices:
                return self.send_error(
                    u'Выбор группового модификатора %s не в стоп-листе' %
                    item.title)
            item.stop_list_group_choices.remove(group_choice_id)
            item.put()
        venue.put()
        self.render_json({'success': True})