Example #1
0
 def post(self):
     category_id = self.request.get_range('category_id')
     category = MenuCategory.get_by_id(category_id)
     if not category:
         self.abort(400)
     category.key.delete()
     self.redirect_to('mt_category_list')
Example #2
0
 def get(self):
     category_id = self.request.get_range('category_id')
     category = MenuCategory.get_by_id(category_id)
     if not category:
         self.abort(400)
     product_id = self.request.get_range('item_id')
     product = MenuItem.get_by_id(product_id)
     if not product:
         self.abort(400)
     self.render('/menu/add_item.html', product=product, category=category)
Example #3
0
 def post(self):
     logging.info(self.request.POST)
     category_id = self.request.get_range('category_id')
     category = MenuCategory.get_by_id(category_id)
     if not category:
         self.abort(400)
     for item in category.get_items():
         item.status = bool(self.request.get(str(item.key.id())))
         item.put()
     self.redirect('/company/menu/item/list?category_id=%s' % category_id)
Example #4
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
     category_id = self.request.get_range('category_id')
     category = MenuCategory.get_by_id(category_id)
     if not category:
         self.abort(400)
     items = category.get_items_in_order(venue)
     self.render('/menu/items.html', items=items, category=category,
                 venues=Venue.query().fetch(), chosen_venue=venue)
Example #5
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
     category_id = self.request.get_range('category_id')
     if category_id:
         category = MenuCategory.get_by_id(category_id)
     else:
         category = MenuCategory.get_initial_category()
     categories = sorted(category.get_categories(venue), key=lambda category: category.sequence_number)
     self.render('/menu/categories.html', categories=categories, main_category=category,
                 venues=Venue.query().fetch(), chosen_venue=venue)
Example #6
0
    def post(self):
        logging.info(self.request.POST)
        category_id = self.request.get_range('category_id')
        if category_id:
            category = MenuCategory.get_by_id(category_id)
        else:
            category = MenuCategory.get_initial_category()

        if not category:
            self.abort(400)
            
        for subcategory in category.get_categories():
            subcategory.status = bool(self.request.get(str(subcategory.key.id())))
            subcategory.put()

        self.redirect('/company/menu/category/list?%s' % self.request.query_string)
Example #7
0
 def post(self):
     category_id = self.request.get_range('category_id')
     category = MenuCategory.get_by_id(category_id)
     if not category:
         self.abort(400)
     previous = category.get_previous_category()
     if not previous:
         self.abort(400)
     _swap_sequence_numbers(previous, category)
     category.put()
     previous.put()
     self.response.headers["Content-Type"] = "application/json"
     self.response.write(json.dumps({
         'success': True,
         'category_id': category.key.id(),
         'previous_id': previous.key.id()
     }, separators=(',', ':')))
Example #8
0
 def post(self):
     category_id = self.request.get_range('category_id')
     category = MenuCategory.get_by_id(category_id)
     if not category:
         self.abort(400)
     next_ = category.get_next_category()
     if not next_:
         self.abort(400)
     _swap_sequence_numbers(category, next_)
     category.put()
     next_.put()
     self.response.headers["Content-Type"] = "application/json"
     self.response.write(json.dumps({
         'success': True,
         'category_id': category.key.id(),
         'next_id': next_.key.id()
     }, separators=(',', ':')))
Example #9
0
 def post(self):
     category_id = self.request.get_range('category_id')
     category = MenuCategory.get_by_id(category_id)
     if not category:
         self.abort(400)
     category.title = self.request.get('title')
     if self.request.get('image_file'):
         new_url = get_new_image_url('MenuCategory', category.key.id(), image_data=str(self.request.get('image_file')))
     elif self.request.get('picture'):
         new_url = get_new_image_url('MenuCategory', category.key.id(), url=self.request.get('picture'))
     else:
         new_url = None
     category.picture = new_url
     if category.picture:
         category.icon = get_new_image_url('MenuCategoryIcon', category.key.id(), url=category.picture, size=ICON_SIZE)
     else:
         category.icon = None
     category.put()
     self.redirect_to('mt_category_list')
Example #10
0
 def post(self):
     category_id = self.request.get_range('category_id')
     category = MenuCategory.get_by_id(category_id)
     if not category:
         self.abort(400)
     product_id = self.request.get_range('product_id')
     item = MenuItem.get_by_id(product_id)
     if not item:
         self.abort(400)
     item.title = self.request.get('title')
     item.description = self.request.get('description')
     if self.request.get('price'):
         price = float(self.request.get('price'))
         item.price = int(round(price * 100))
     else:
         item.price = 0
     item.kal = self.request.get_range('kal')
     if self.request.get('volume') and self.request.get('volume') != 'None':
         item.volume = float(self.request.get('volume'))
     else:
         item.volume = 0
     if self.request.get('weight') and self.request.get('weight') != 'None':
         item.weight = float(self.request.get('weight'))
     else:
         item.weight = 0
     item.picture = None
     item.cut_picture = None
     item.icon = None
     if self.request.get('image_file') or self.request.get('picture'):
         if self.request.get('image_file'):
             new_url = get_new_image_url('MenuItem', item.key.id(), image_data=str(self.request.get('image_file')))
             if new_url:
                 item.picture = new_url
         elif self.request.get('picture'):
             new_url = get_new_image_url('MenuItem', item.key.id(), url=self.request.get('picture'))
             if new_url:
                 item.picture = new_url
     if item.picture:
         item.icon = get_new_image_url('MenuItemIcon', item.key.id(), url=item.picture, size=ICON_SIZE)
     item.put()
     self.redirect('/company/menu/item/list?category_id=%s' % category_id)
Example #11
0
 def post(self):
     main_category_id = self.request.get_range('main_category_id')
     main_category = MenuCategory.get_by_id(main_category_id)
     if not main_category:
         self.abort(400)
     category = MenuCategory(sequence_number=MenuCategory.generate_category_sequence_number(),
                             category=main_category.key)
     category.title = self.request.get('title')
     category.put()
     if self.request.get('image_file') or self.request.get('picture'):
         if self.request.get('image_file'):
             new_url = get_new_image_url('MenuCategory', category.key.id(), image_data=str(self.request.get('image_file')))
         elif self.request.get('picture'):
             new_url = get_new_image_url('MenuCategory', category.key.id(), url=self.request.get('picture'))
         else:
             new_url = None
         if new_url:
             category.picture = new_url
     if category.picture:
         category.icon = get_new_image_url('MenuCategoryIcon', category.key.id(), url=category.picture, size=ICON_SIZE)
     category.put()
     self.redirect_to('mt_category_list')
Example #12
0
    def post(self):
        category_id = self.request.get_range('category_id')
        category = MenuCategory.get_by_id(category_id)
        if not category:
            self.abort(400)

        item = MenuItem(title=self.request.get('title'))
        item.description = self.request.get('description')

        if self.request.get('price'):
            price = float(self.request.get('price'))
            item.price = int(round(price * 100))

        item.kal = self.request.get_range('kal')
        if self.request.get('volume'):
            item.volume = float(self.request.get('volume'))
        if self.request.get('weight'):
            item.weight = float(self.request.get('weight'))
        item.sequence_number = category.generate_sequence_number()
        item.put()  # it is need to get id in saving image
        if self.request.get('image_file') or self.request.get('picture'):
            if self.request.get('image_file'):
                new_url = get_new_image_url('MenuItem', item.key.id(), image_data=str(self.request.get('image_file')))
                if new_url:
                    item.picture = new_url
            elif self.request.get('picture'):
                new_url = get_new_image_url('MenuItem', item.key.id(), url=self.request.get('picture'))
                if new_url:
                    item.picture = new_url
        if item.picture:
            item.icon = get_new_image_url('MenuItemIcon', item.key.id(), url=item.picture, size=ICON_SIZE)
        item.category = category.key
        if not self.request.get('restriction_on'):
            for venue in Venue.query().fetch():
                item.restrictions.append(venue.key)
        item.put()
        self.redirect('/company/menu/item/list?category_id=%s' % category_id)
Example #13
0
 def get(self):
     category_id = self.request.get_range('category_id')
     category = MenuCategory.get_by_id(category_id)
     if not category:
         self.abort(400)
     self.render('/menu/add_item.html', category=category)
Example #14
0
 def get(self):
     main_category_id = self.request.get_range('main_category_id')
     main_category = MenuCategory.get_by_id(main_category_id)
     if not main_category:
         self.abort(400)
     self.render('/menu/add_category.html', main_category=main_category)