def get_sessions(self, request): """ Given a conference, return all sessions. :param request: Conference GET Request [Void, query string with conference key] :return: SessionForms with matching SessionForm's """ wsck = request.websafeConferenceKey conf_key = ndb.Key(urlsafe=wsck) if not conf_key.get(): raise endpoints.NotFoundException( 'No conference found with key: %s' % wsck) sessions = Session.query(ancestor=conf_key) return SessionForms(items=SessionApi.populate_forms(sessions))
def get_wishlist(self, request): """ Gets the list of sessions wishlisted by a User given a Conference. :param request: Conference GET Request [VoidMessage, conference key in query string] :return: SessionForms """ prof = ProfileApi.profile_from_user() # get user Profile conf_key = ndb.Key(urlsafe=request.websafeConferenceKey) wishlist = ConferenceWishlist().query(ancestor=prof.key) \ .filter(ConferenceWishlist.conferenceKey == conf_key) \ .get() if not wishlist: error = 'No wishlist for conference with key %s' % \ request.websafeConferenceKey raise endpoints.NotFoundException(error) sessions = ndb.get_multi(wishlist.sessionKeys) return SessionForms(items=SessionApi.populate_forms(sessions))