Example #1
0
File: pages.py Project: niczy/hyo
 def get(self, restaurant_uid):
   "TODO: get restaurant uid from the path."
   logging.info(restaurant_uid)
   categories = category_logic.get_all_by_restaurant_uid(restaurant_uid)
   dishes = dish_logic.get_all_by_restaurant_uid(restaurant_uid)
   self.render('restaurant.html',
       {"categories": json_encoder.encode(categories),
         "dishes": json_encoder.encode(dishes),
         "restaurant_uid": restaurant_uid})
Example #2
0
 def testEncode(self):
     restaurant = Restaurant(name="test")
     restaruants = [restaurant, restaurant]
     self.assertEqual(
         '[{"logo": null, "name": "test", "uid": null}, {"logo": null, "name": "test", "uid": null}]',
         json_encoder.encode(restaruants),
     )
Example #3
0
File: api.py Project: niczy/hyo
  def send_response(self, resp):
    self.response.headers['Content-Type'] = 'application/json'
    if isinstance(resp, str):
      self.response.out.write(resp)
      return
    elif isinstance(resp, dict):
      self.response.out.write(json.dumps(resp))
      return

    self.response.out.write(json_encoder.encode(resp))
Example #4
0
 def testSerialization(self):
   restaurant = Restaurant(uid = "uid", name = 'Restaurant')
   self.assertEqual('{"logo": null, "name": "Restaurant", "uid": "uid"}',
       json_encoder.encode(restaurant))
Example #5
0
File: pages.py Project: niczy/hyo
 def get(self):
   restaurants = restaurant_logic.get_all()
   self.render('index.html', {
     "restaurants": json_encoder.encode(restaurants)
     })