Ejemplo n.º 1
0
Archivo: pages.py Proyecto: 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})
Ejemplo n.º 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),
     )
Ejemplo n.º 3
0
Archivo: api.py Proyecto: 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))
Ejemplo n.º 4
0
 def testSerialization(self):
   restaurant = Restaurant(uid = "uid", name = 'Restaurant')
   self.assertEqual('{"logo": null, "name": "Restaurant", "uid": "uid"}',
       json_encoder.encode(restaurant))
Ejemplo n.º 5
0
Archivo: pages.py Proyecto: niczy/hyo
 def get(self):
   restaurants = restaurant_logic.get_all()
   self.render('index.html', {
     "restaurants": json_encoder.encode(restaurants)
     })