Beispiel #1
0
 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})
Beispiel #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),
     )
Beispiel #3
0
Datei: api.py Projekt: 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))
Beispiel #4
0
 def testSerialization(self):
   restaurant = Restaurant(uid = "uid", name = 'Restaurant')
   self.assertEqual('{"logo": null, "name": "Restaurant", "uid": "uid"}',
       json_encoder.encode(restaurant))
Beispiel #5
0
 def get(self):
   restaurants = restaurant_logic.get_all()
   self.render('index.html', {
     "restaurants": json_encoder.encode(restaurants)
     })