コード例 #1
0
ファイル: main_handler.py プロジェクト: uncamy/StartupWeekend
 def _add_food(self):
   name = self.request.get('foodName')
   calories = calc_foodcalories(name)
   image = find_image(name)
   now = datetime.datetime.now().date()
   f = Food(name = name, calories = calories, calories_left = calories, imagelink = image, time = now)
   f.put()
   self.present_food(f)
コード例 #2
0
ファイル: main.py プロジェクト: Kjordan101/fridgeIO
    def post(self):
        nameOfFood = self.request.get('food-name', allow_multiple=True)
        dateOfExpiration = self.request.get('expirationDate',
                                            allow_multiple=True)
        pickYourTitle = self.request.get('title')

        #fill list with key values
        listOfFoods = []
        for i in range(len(nameOfFood)):
            food = Food(food=nameOfFood[i],
                        expirationDate=datetime.strptime(
                            dateOfExpiration[i], '%Y-%m-%d'))
            foodKey = food.put()
            listOfFoods.append(foodKey)

        #save to grocery list to database
        groceryToSave = Grocery(title=pickYourTitle, foods=listOfFoods)
        groceryToSave.put()
        self.redirect('/loadlist')