def restaurants_patch(self, request):
     check_admin(endpoints)
     rest_list = []
     for rest in request.restaurants:
         rest_dict = {}
         rest_dict["name"] = rest.name
         rest_dict["entries"] = rest.entries
         rest_list.append(rest_dict)
     re = RestaurantsEntity(id=request.location, location=request.location, restaurants=json.dumps(rest_list))
     re.put()
     return request
    def restaurants_get(self, request):
        re = RestaurantsEntity.get_by_id(request.location)
        rest_dict = json.loads(re.restaurants)
        # logging.info(rest_dict)
        rm_list = []
        for rest in rest_dict:
            # logging.info(rest)
            # logging.info(rest['name'])
            rm = RestaurantMessage(name=rest["name"], entries=rest["entries"])
            rm_list.append(rm)

        return RestaurantsMessage(location=re.location, restaurants=rm_list)
    def restaurants_add(self, request):
        check_admin(endpoints)
        re = RestaurantsEntity.get_by_id(request.location)
        rest_dict = json.loads(re.restaurants)
        rest_dict.append({"name": request.name, "entries": request.entries})
        re.restaurants = json.dumps(rest_dict)
        re.put()
        rm_list = []
        for rest in rest_dict:
            # logging.info(rest)
            # logging.info(rest['name'])
            rm = RestaurantMessage(name=rest["name"], entries=rest["entries"])
            rm_list.append(rm)

        return RestaurantsMessage(location=re.location, restaurants=rm_list)