def getAttenderByConference(self, request): """ Query for all registered users in a specified conference. (This query is only open to conference organizer) """ # make sure that the user is authed user = endpoints.get_current_user() if not user: raise endpoints.UnauthorizedException("Authorization required") user_id = getUserId(user, id_type="oauth") # get the conference model wsck = request.websafeConferenceKey conf = ndb.Key(urlsafe=wsck).get() # check that conference exists if not conf: raise endpoints.NotFoundException( "No conference found with key: %s" % request.websafeConferenceKey) # check if the user is the organizer of the conference if user_id != conf.organizerUserId: raise endpoints.ForbiddenException( "Only the conference organizer can query for attendees.") # apply the filter query_result = Profile.query( Profile.conferenceKeysToAttend.IN([ wsck, ])) # return the ProfileForms return ProfileForms( items=[self._copyProfileToForm(pf) for pf in query_result])
def getAttenderBySession(self, request): """Given a Session, return all attenders join this session.""" sessionKey = request.sessionKey profiles = Profile.query() attenders = [] for pro in profiles: if sessionKey in pro.sessionKeysInWishlist: attenders.append(pro) # return set of ProfileForm objects return ProfileForms(items=[self._copyProfileToForm(attender) for attender in attenders])
def getAttenderByConference(self, request): """Given a Conference, return all attenders join this conferences.""" wsck = request.websafeConferenceKey profiles = Profile.query() attenders = [] for pro in profiles: if wsck in pro.conferenceKeysToAttend: attenders.append(pro) # return set of SessionForm objects return ProfileForms(items=[self._copyProfileToForm(attender) for attender in attenders])
def GetUsersForConference(self, request): """Get list of users attending a conference. """ # get conference key wsck = request.websafeConferenceKey # Get list of user profiles that are registered to the conference profiles = Profile.query(Profile.conferenceKeysToAttend == wsck) return ProfileForms(items=[self._copyProfileToForm(profile) for profile in profiles])
def getProfilesBySessionWishList(self, request): """ Return all profiles who want to attend a particular session. """ session = ndb.Key(urlsafe=request.sessionKey).get() if not session: raise endpoints.NotFoundException('No session found with key: %s' % request.sessionKey) profiles = Profile.query().filter( Profile.session_wish_list == session.key.urlsafe()) return ProfileForms(profiles=[ self._copyProfileToForm(profile) for profile in profiles ])
def getSessionAttendees(self, request): """Return requested session's attendees (by websafeSessionKey).""" # get Session object from request; bail if not found sesh = ndb.Key(urlsafe=request.websafeSessionKey).get() if not sesh: raise endpoints.NotFoundException('No session found with key: %s' % request.websafeSessionKey) attendees = Profile.query() attendees = attendees.filter( request.websafeSessionKey == Profile.sessionKeysInWishList) # return ProfileForms return ProfileForms(items=[ self._copyProfileToForm(attendee) for attendee in attendees ])
def getConferenceAttendees(self, request): """ Return requested conference's attendees (by websafeConferenceKey). """ # get Conference object from request; bail if not found conf = ndb.Key(urlsafe=request.websafeConferenceKey).get() if not conf: raise endpoints.NotFoundException( 'No conference found with key: %s' % request.websafeConferenceKey) attendees = Profile.query() attendees = attendees.filter( request.websafeConferenceKey == Profile.conferenceKeysToAttend) # return ConferenceForm return ProfileForms(items=[ self._copyProfileToForm(attendee) for attendee in attendees ])
def getAttendeesForConference(self, request): """Get attendees for given conference""" #check if user is owner user = endpoints.get_current_user() if not user: raise endpoints.UnauthorizedException('Authorization required') user_id = getUserId(user) conf = ndb.Key(urlsafe=request.websafeConferenceKey).get() if conf.organizerUserId != user_id: raise endpoints.UnauthorizedException('Incorrect Authorization') ps = Profile.query( Profile.conferenceKeysToAttend == request.websafeConferenceKey) return ProfileForms(profiles=[self._copyProfileToForm(p) for p in ps]) return self._conferenceRegistration(request)