Listing a property does not require a form, and only involves the pymongo.collection.findOne() method called from a property domain service lookup method. Things get a bit tricky, however, when dealing with room type listings. This involves parsing an embedded array of RoomType objects. What is even trickier is that within this array of objects is another property, beds, itself another array! So, here is our proposed approach:
- Define a view using the property domain service to perform a straightforward lookup on the property by key.
- Define view methods that return a JSON list of room types.
- Add two routes: one for the listing, the other for the method called by jQuery.
- Define a template that displays basic property information.
- Within the template, add a jQuery AJAX request for room type information.
The view method that returns JSON also breaks down the array of bed types embedded within each RoomType object.