Exemplo n.º 1
0
 def getSessionsInWishlist(self, request):
     """query for all the sessions in a conference
     that the user is interested in"""
     profile = profileUtils.getProfileForLoggedInUser()
     sessionKeys = [ndb.Key(urlsafe=sessionKey) for sessionKey in profile.interestedInSessions]
     sessions = ndb.get_multi(sessionKeys)
     return SessionForms(
         items = [sessionUtils.copySessionToForm(session) for session in sessions]
     )
Exemplo n.º 2
0
    def deleteSessionInWithlist(self, request):
        """removes the session from the user's list of
        sessions they are interested in attending"""
        profile = profileUtils.getProfileForLoggedInUser()
        if request.websafeSessionKey not in profile.interestedInSessions:
            raise ConflictException("You haven't registered for this conference")

        profile.interestedInSessions.remove(request.websafeSessionKey)
        profile.put()
        return BooleanMessage(data=True)
Exemplo n.º 3
0
    def addSessionToWishlist(self, request):
        """adds the session to the user's list of
        sessions they are interested in attending"""
        profile = profileUtils.getProfileForLoggedInUser()
        if request.websafeSessionKey in profile.interestedInSessions:
            raise ConflictException("You already have this session in your wishlist")

        profile.interestedInSessions.append(request.websafeSessionKey)
        profile.put()
        return BooleanMessage(data=True)
Exemplo n.º 4
0
    def _doProfile(self, save_request=None):
        """Get user Profile and return to user, possibly updating it first."""
        # get user Profile
        prof = profileUtils.getProfileForLoggedInUser()

        # if saveProfile(), process user-modifyable fields
        if save_request:
            for field in ('displayName', 'teeShirtSize'):
                if hasattr(save_request, field):
                    val = getattr(save_request, field)
                    if val:
                        setattr(prof, field, str(val))
                        #if field == 'teeShirtSize':
                        #    setattr(prof, field, str(val).upper())
                        #else:
                        #    setattr(prof, field, val)
                        prof.put()

        # return ProfileForm
        return profileUtils.copyProfileToForm(prof)
Exemplo n.º 5
0
    def getConferencesToAttend(self, request):
        """Get list of conferences that user has registered for."""
        prof = profileUtils.getProfileForLoggedInUser() # get user Profile
        conf_keys = [ndb.Key(urlsafe=wsck) for wsck in prof.conferenceKeysToAttend]
        conferences = ndb.get_multi(conf_keys)

        # get organizers
        organisers = [ndb.Key(Profile, conf.organizerUserId) for conf in conferences]
        profiles = ndb.get_multi(organisers)

        # put display names in a dict for easier fetching
        names = {}
        for profile in profiles:
            names[profile.key.id()] = profile.displayName

        # return set of ConferenceForm objects per Conference
        return ConferenceForms(items=[self._copyConferenceToForm(conf, names[conf.organizerUserId])\
         for conf in conferences]
        )
Exemplo n.º 6
0
    def _conferenceRegistration(self, request, reg=True):
        """Register or unregister user for selected conference."""
        userProfile = profileUtils.getProfileForLoggedInUser() # get user Profile

        # check if conf exists given websafeConfKey
        # get conference; check that it exists
        conferenceKey = request.websafeConferenceKey
        conference = ndb.Key(urlsafe=conferenceKey).get()
        if not conference:
            raise endpoints.NotFoundException(
                'No conference found with key: %s' % wsck)

        # register
        if reg:
            conferenceUtils.registerUserForConference(userProfile, conference)

        # unregister
        else:
            conferenceUtils.unregisterUserForConference(userProfile, conference)