def addSessionToWishlist(self, request):
        """Add the session to the user's list of sessions they are interested in attending."""
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')
        user_id = getUserId(user)

        s_key = ndb.Key(urlsafe=request.websafeSessionKey)
        if not s_key:
            raise endpoints.BadRequestException('Session key not found')

        w_key = ndb.Key(WishlistSession, request.websafeSessionKey)

        wishlist_session = w_key.get()
        if wishlist_session:
            raise endpoints.BadRequestException(
                'Session is already in wish list.')

        wishlist_session = WishlistSession(
            key=w_key,
            sessionConferenceKey=s_key.parent().urlsafe(),
            sessionKey=s_key.urlsafe(),
            userId=user_id)
        wishlist_session.put()

        return self._copyWishlistSessionToForm(wishlist_session)
    def addSessionToWishlist(self, request):
        """adds the session to the user's list of sessions they are interested in attending"""
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')
        user_id = getUserId(user)

        s_key = ndb.Key(urlsafe=request.websafeSessionKey)
        if not s_key:
            raise endpoints.BadRequestException('Session key not found')

        w_key = ndb.Key(WishlistSession, request.websafeSessionKey)
        wishlist_session = w_key.get()
        if wishlist_session:
            raise endpoints.BadRequestException('Session already added')

        wishlist_session = WishlistSession(key=w_key,
                                           sessionConferenceKey=s_key.parent().urlsafe(),
                                           sessionKey=s_key.urlsafe(),
                                           userId=user_id)
        wishlist_session.put()

        return self._copyWishlistSessionToForm(wishlist_session)
    def getSessionsInWishlist(self, request):
        """query for all the sessions in a conference that the user is interested in"""
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')
        user_id = getUserId(user)

        wl_sessions = WishlistSession.query(WishlistSession.userId == user_id)
        if hasattr(request, 'websafeConferenceKey'):
            if request.websafeConferenceKey:
                wl_sessions = wl_sessions.filter(WishlistSession.sessionConferenceKey == request.websafeConferenceKey)

        sessions = ndb.get_multi([ndb.Key(urlsafe=w.sessionKey) for wl in wl_sessions])

        return SessionForms(items=[self._copySessionToForm(session) for session in sessions])
    def getSessionsInWishlist(self, request):
        """Query session a user wishes to attend in a conference"""
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')
        user_id = getUserId(user)

        wls = WishlistSession.query(WishlistSession.userId == user_id)
        if hasattr(request, 'websafeConferenceKey'):
            if request.websafeConferenceKey:
                wls = wls.filter(WishlistSession.sessionConferenceKey ==
                                 request.websafeConferenceKey)
        sessions = ndb.get_multi(
            [ndb.Key(urlsafe=wishList.sessionKey) for wishList in wls])

        return SessionForms(
            items=[self._copySessionToForm(session) for session in sessions])