def response_suggest(): # Retreive the form data budget, filter_words = response_suggest_get_form_data() # Format the input description HTML to echo to the user in_desc = Markup(fmt.suggest_input_description(budget, filter_words)) # Grab the 5 most recent days of menus menus = menu.get_recent_menus(5) # This function will help us quickly grab the best (or one of the best) # orders for each Menu, if it exists. def get_order(m): orders = list(suggest.orders(m, budget, filter_words)) if len(orders) == 0: return None return orders[0] # Map each menu to its best order orders = list(map(get_order, menus)) # Format the HTML that shows the orders order_glob = Markup(fmt.suggest_orders_glob(menus, orders, budget)) # Render suggest.html with the input echo and the order glob content = render_template( 'suggest.html', input_description=in_desc, orders=order_glob ) # Inject it into the page template return pagify(content)
def response(): # Retreive the 5 most recent days of menus menus = menu.get_recent_menus(5) content = '' for m in menus: # Format an HTML table for each menu with the date as a heading content += fmt.menu(m, heading=fmt.date(m.date)) # Render index.html with the tables, inject it into the page template return pagify(render_template('index.html', menus=Markup(content)))