(self, request, reg=True)
return BooleanMessage(data=retval)
Register or unregister user for selected conference.
Register or unregister user for selected conference.
Register or unregister user for selected conference .
def _conferenceRegistration(self, request, reg=True):
        """Register or unregister user for selected conference."""
        retval = None
        prof = self._getProfileFromUser() # get user Profile

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

        # register
        if reg:
            # check if user already registered otherwise add
            if wsck in prof.conferenceKeysToAttend:
                raise ConflictException(
                    "You have already registered for this conference")

            # check if seats avail
            if conf.seatsAvailable <= 0:
                raise ConflictException(
                    "There are no seats available.")

            # register user, take away one seat
            prof.conferenceKeysToAttend.append(wsck)
            conf.seatsAvailable -= 1
            retval = True

        # unregister
        else:
            # check if user already registered
            if wsck in prof.conferenceKeysToAttend:

                # unregister user, add back one seat
                prof.conferenceKeysToAttend.remove(wsck)
                conf.seatsAvailable += 1
                retval = True
            else:
                retval = False

        # write things back to the datastore & return
        prof.put()
        conf.put()
        return BooleanMessage(data=retval)
def _conferenceRegistration ( self , request , reg = True ) : retval = None prof = self . _getProfileFromUser ( ) # get user Profile # check if conf exists given websafeConfKey # get conference; check that it exists wsck = request . websafeConferenceKey conf = ndb . Key ( urlsafe = wsck ) . get ( ) if not conf : raise endpoints . NotFoundException ( 'No conference found with key: %s' % wsck ) # register if reg : # check if user already registered otherwise add if wsck in prof . conferenceKeysToAttend : raise ConflictException ( "You have already registered for this conference" ) # check if seats avail if conf . seatsAvailable <= 0 : raise ConflictException ( "There are no seats available." ) # register user, take away one seat prof . conferenceKeysToAttend . append ( wsck ) conf . seatsAvailable -= 1 retval = True # unregister else : # check if user already registered if wsck in prof . conferenceKeysToAttend : # unregister user, add back one seat prof . conferenceKeysToAttend . remove ( wsck ) conf . seatsAvailable += 1 retval = True else : retval = False # write things back to the datastore & return prof . put ( ) conf . put ( ) return BooleanMessage ( data = retval )