def get_page(self): cursor = self.request.GET.get("cursor") or None data = { "categories": Resto.CATEGORIES, "restos": Resto.find(cursor=cursor, limit=20), } data = self.update_data(data) return render_to_response(self.get_page_template(), data, RequestContext(self.request))
def get_page(self): # Find newly added restos (randomly select 4 out of 10). newly_added_restos = list(Resto.find(order_by="-update_date", limit=10)) random.shuffle(newly_added_restos) newly_added_restos = newly_added_restos[:4] # Find newly commented restos (a list of 2-tuple with resto and comment). new_comments = Comment.find_recent(ref_type=Resto.__name__, limit=4) newly_commented_restos = [] for comment in new_comments: resto = Resto.get_unique(id=int(comment.ref_pk)) if resto: newly_commented_restos.append((resto, comment)) # Render the response. data = { "categories": Resto.CATEGORIES, "newly_added_restos": newly_added_restos, "newly_commented_restos": newly_commented_restos, } data = self.update_data(data) return render_to_response(self.get_page_template(), data, RequestContext(self.request))