Esempio n. 1
0
 def getSpeakersByConference(self, request):
     """Given a conference, return all speakers."""
     # Ensure that user is authed
     user = endpoints.get_current_user()
     if not user:
         raise endpoints.UnauthorizedException('Authorization Required')
     # Retrieve the Conference key
     try:
         c_key = ndb.Key(urlsafe=request.websafeConferenceKey)
     except Exception:
         raise endpoints.BadRequestException(
             'The websafeConferenceKey given is invalid.')
     # Verify that the conference exists
     conf = c_key.get()
     if not conf:
         raise endpoints.NotFoundException(
             'No conference found for the key provided: %s' %
             request.websafeConferenceKey)
     # Store the Sessions that are ancestors of the Conference
     sessions = Session.query(ancestor=c_key)
     # Retrieve Speaker Keys from each Session in a Conference
     speakerKeys = set([])
     for sesh in sessions:
         for wssk in sesh.speakerKey:
             speaker_key = ndb.Key(urlsafe=wssk)
             # Utilize add to set to eliminate duplicate results
             speakerKeys.add(speaker_key)
     # Get each speaker using its key and appended it to the final list
     speakers = []
     for spkr in speakerKeys:
         speaker = spkr.get()
         speakers.append(speaker)
     # Return a SpeakerForm for each Speaker
     return SpeakerForms(
         items=[self._copySpeakerToForm(spkr) for spkr in speakers])
Esempio n. 2
0
    def getSpeakers(self, request):
        """Returns list of speakers"""
        speakers = Speaker.query()

        # Return set of SpeakerForm objects
        return SpeakerForms(
            speakers=[self._copySpeakerToForm(s) for s in speakers])
Esempio n. 3
0
 def querySpeakers(self, request):
     """Query for Speakers."""
     speakers = Speaker.query().fetch()
     # return Speakers
     return SpeakerForms(
         items=[self._copySpeakerToForm(speaker) for speaker in speakers]
     )
Esempio n. 4
0
    def showSpeakerInfo(self, request):
        """Return Speakers by session"""
        #grab session instance using websafeSessionkey
        sess = ndb.Key(urlsafe=request.websafeSessionKey).get()
        #populate list with speakers from the session
        spkr_keys = [s for s in sess.speakerKeys]

        return SpeakerForms(
            items=[self._copySpeakerToForm(s.get()) for s in spkr_keys])
Esempio n. 5
0
    def getSpeakers(self, request):
        """Create Speaker object, returning SpeakerForm/request."""

        speakers = Speaker.query()

        # return set of SpeakerForm objects per Speaker
        return SpeakerForms(
            items=[self._copySpeakerToForm(speaker) for speaker in speakers]
        )
    def getSpeakers(self, request):
        """Return all the speakers."""

        # create ancestor query for all key matches for this conference
        speakers = Speaker.query()

        # return set of ConferenceForm objects per Conference
        return SpeakerForms(
            items=[self._copySpeakerToForm(speaker) for speaker in speakers]
        )
    def _getSpeakers(self, request, nameFilter=None):
        """ Return speakers, with the option to filter on name
        """
        speakers = Speaker.query()

        if nameFilter:
            speakers.filter(Speaker.name == nameFilter)

        return SpeakerForms(
            items=[self._copySpeakerToForm(speaker) for speaker in speakers])
Esempio n. 8
0
    def querySpeaker(self, request):
        """Queries all speakers with the name and or organization provided."""

        q = Speaker.query()
        q = q.filter(Speaker.speaker == request.speaker)

        # if an organization query is provided, query speaker by organization
        if request.organization:
            q = q.filter(Speaker.organization == request.organization)

        return SpeakerForms(items=[self._copySpeakerToForm(s) for s in q])
    def querySpeakers(self, request):
        """
        Queries Speakers, takes generic filters
        Input: Field, Operator, Value
        """
        speakers = self._getSpeakers(request)

        # return individual SpeakerForm object
        return SpeakerForms(speakers=[
            self._copySpeakerToForm(speaker) for speaker in speakers
        ])
    def getSpeakersByConference(self, request):
        """Given a websafeConferenceKey, return all speakers."""
        
        # Getting and Verifying current user
        user = getUser()

        # Retrieve the Conference key
        try:
            
            c_key = ndb.Key(urlsafe=request.websafeConferenceKey)
        
        except Exception:
        
            raise endpoints.BadRequestException(
                'The websafeConferenceKey is invalid.')
        
        # Verify that the conference exists
        conference = c_key.get()

        checkObj(conference, 'Conference')

        # Save the ancestors the Conference obj
        sessions = Session.query(ancestor=c_key)
        
        # Retrieve Speaker Keys from each Session in a Conference
        speakerKeys = set()

        for sess in sessions:
            
            for webSafeKey in sess.speakerKey:
                
                speaker_key = ndb.Key(urlsafe=webSafeKey)
                
                # add to set
                speakerKeys.add(speaker_key)

        # Container to keep speaker objects
        speakers = []
        
        # Get each speaker and add to the set
        for spk in speakerKeys:
            
            speaker = spk.get()

            speakers.append(speaker)

        # Return one or many SpeakerForms for Speakers
        return SpeakerForms(
            items = [self._copySpeakerToForm(
                spkr) for spkr in speakers])
Esempio n. 11
0
    def getSpeakersCreated(self, request):
        """Return speakers created by user."""
        # make sure user is authed
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException('Authorization required')
        user_id = getUserId(user)

        # create ancestor query for all key matches for this user
        speakers = Speaker.query(ancestor=ndb.Key(Profile, user_id))

        # return set of Speaker objects
        return SpeakerForms(
            items=[self._copySpeakerToForm(speaker) for speaker in speakers]
        )
 def getSpeakerByName(self, request):
     """Get Speaker Object given the speaker's full name"""
     speakers = Speaker.query().filter(Speaker.displayName == request.name)
     return SpeakerForms(
         items=[self._copySpeakerToForm(speaker) for speaker in speakers]
     )
Esempio n. 13
0
 def getSpeakers(self, request):
     """Get list of all speakers in the system."""
     speakers = Speaker.query().order(Speaker.name).fetch()
     # Return individual SpeakerForm object per Speaker
     return SpeakerForms(
         items=[self._copySpeakerToForm(speaker) for speaker in speakers])
Esempio n. 14
0
    def getAllSpeakers(self, request):
        """Return all speakers."""
        speakers = Speaker.query()

        return SpeakerForms(
            items=[self._copySpeakerToForm(speaker) for speaker in speakers])
Esempio n. 15
0
    def getSpeakers(self, request):
        """Return speakers"""

        spkrs = Speaker.query().order(Speaker.name)

        return SpeakerForms(items=[self._copySpeakerToForm(s) for s in spkrs])
Esempio n. 16
0
 def getSpeakersByName(self, request):
     """Get a list of speakers with the given name"""
     query = Speaker.query().filter(Speaker.name == request.data)
     return SpeakerForms(
         items=[self._copySpeakerToForm(speaker) for speaker in query])
 def getSpeakersCreated(self, request):
     """Get all Speaker Objects within Datastore"""
     speakers = Speaker.query()
     return SpeakerForms(
         items=[self._copySpeakerToForm(speaker) for speaker in speakers]
     )
Esempio n. 18
0
 def _copySpeakersToForms(self, speakers):
     """Return SpeakerForms from a given Speaker array"""
     return SpeakerForms(
         items=[self._copySpeakerToForm(speaker) for speaker in speakers])