def _data(self, comp, user, **kwds): """Create the data dictionary for the renderer.""" users = [] photos = [] status = comp.status for uc in comp.users(): user1 = uc.user.get() users.append((user1, "Yes" if uc.submitted_scores else "No")) if status == OPEN: photo = Photo.competition_user(comp, user1) photos.append(photo.key.id()) data = { "page_title": "Modify Competition", "title": comp.title, "description": comp.description, "year": comp.year, "month": MONTHS[comp.month], "status": comp.get_status(), "user": user, "users": users, "photos": photos, "comp_id": comp.key.id(), "status_values": ((0, "Open"), (1, "Scoring"), (2, "Completed")), } data.update(kwds) # logging.info('kwds %s' % kwds) return data
def get(self): """Show the competitions page.""" user_id, user = self.get_user() comps = [] for c in Competition.all(): month = c.month month_word = MONTHS[month] user_photo = False if user: user_photo = Photo.competition_user(c, user) is not None comps.append( ( # month, c.key.id(), month_word, c.year, c.title, c.description, c.get_status(), user_photo, ) ) data = {"page_title": "Competitions", "user": user, "comps": comps, "months": MONTHS} self.render("competitions.html", **data)