当前位置: 首页>>代码示例>>Python>>正文


Python Conference.query方法代码示例

本文整理汇总了Python中models.Conference.query方法的典型用法代码示例。如果您正苦于以下问题:Python Conference.query方法的具体用法?Python Conference.query怎么用?Python Conference.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Conference的用法示例。


在下文中一共展示了Conference.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getMarketableConferences

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
    def getMarketableConferences(self, request):
        """Find the conferences that is in progress and not yet fully booked"""
        mtoday = datetime.now().date()
        # Get conferences with seats available
        conf_inprogress_seatsavail = set(
            Conference.query().filter(
                Conference.seatsAvailable > 0).fetch(keys_only=True))
        # Get conferences where open end date is more or equal than today
        conf_inprogress_enddate = set(
            Conference.query().filter(Conference.endDate >= mtoday).fetch(
                keys_only=True))
        # Get conferences where open start date is less than or equal to today
        conf_inprogress_startdate = set(
            Conference.query().filter(Conference.startDate <= mtoday).fetch(
                keys_only=True))

        # return a set with conferences common in all queries
        conf_inprogress_keys = conf_inprogress_seatsavail\
                               & conf_inprogress_startdate\
                               & conf_inprogress_enddate
        conf_inprogress = ndb.get_multi(conf_inprogress_keys)

        return MarketableConferenceForms(items=[
            MarketableConferenceForm(name=getattr(data, "name"),
                                     topics=getattr(data, "topics"),
                                     city=getattr(data, "city"),
                                     seatsAvailable=getattr(data,
                                                            "seatsAvailable"),
                                     endDate=str(getattr(data, "endDate")))
            for data in conf_inprogress])
开发者ID:acivux,项目名称:ConferenceCentral,代码行数:32,代码来源:conference.py

示例2: getConferencesNotSoldOutInAmsterdam

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
    def getConferencesNotSoldOutInAmsterdam(self, request):
        """ Only show conferences in Amsterdam that are not sold out
        """
        in_amsterdam = Conference.query(
            Conference.city == 'Amsterdam')
        not_sold_out = Conference.query(
            Conference.seatsAvailable > 0)

        confs = self._intersectQueries(in_amsterdam, not_sold_out)
        names = self._getConferenceOrganisers(confs)

        return ConferenceForms(
            items=[self._copyConferenceToForm(
                conf, names[conf.organizerUserId]) for conf in confs])
开发者ID:adarsh0806,项目名称:udacity-nd004-p4-conference-organization-app,代码行数:16,代码来源:conference.py

示例3: filterPlayground

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
    def filterPlayground(self, request):
        q = Conference.query()
        # simple filter usage:
        q = q.filter(Conference.city == "Paris")
        q = q.filter(Conference.seatsAvailable > 0)

        # advanced filter building and usage
        field = "city"
        operator = "="
        value = "London"
        f = ndb.query.FilterNode(field, operator, value)
        q = q.filter(f)

        # Adding second filter
        q = q.filter(Conference.topics == "Medical Innovations")

        # Filter for big conferences
        q = q.filter(Conference.maxAttendees > 50)

        # Sorting by name
        q = q.order(Conference.name)

        return ConferenceForms(
            items=[self._copyConferenceToForm(conf, "") for conf in q]
        )
开发者ID:aristoteles-nunez,项目名称:Conference-Organization-App,代码行数:27,代码来源:conference.py

示例4: queryConferences

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
    def queryConferences(self, request):
        """Queries conferences for results."""
        conferences = Conference.query()

        return ConferenceForms(
            items = [self._copyConferenceToForm(conf, "")\
            for conf in conferences])
开发者ID:iamparas,项目名称:Conference-Centre,代码行数:9,代码来源:conference.py

示例5: getConferencesByPopularity

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
    def getConferencesByPopularity(self, request):
        """Return conferences by popularity"""
        # fetch conference from key
        conf = Conference.query().fetch()

        # Check that conference exists
        if not conf:
            raise endpoints.NotFoundException("No conference found with this key: %s" % request.websafeConferenceKey)
        conf_list = []

        for c in conf:
            count = Profile.query().filter(Profile.conferenceKeysToAttend == c.key.urlsafe()).count()
            conf_list.append({"conf": c, "count": count})
        conf_list = sorted(conf_list, key=lambda conf: conf["count"], reverse=True)

        # need to fetch organiser displayName from profiles
        # get all keys and use get_multi for speed
        organisers = [(ndb.Key(Profile, c.organizerUserId)) for c in conf]
        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 individual ConferenceForm object per Conference
        return ConferenceForms(
            items=[self._copyConferenceToForm(c["conf"], names[c["conf"].organizerUserId]) for c in conf_list]
        )
开发者ID:jdvalera,项目名称:Udacity-Full-Stack,代码行数:31,代码来源:conference.py

示例6: getSessionsBySpeaker

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
    def getSessionsBySpeaker(self, request):
        """Given a speaker, return all sessions given by this particular speaker, across all conferences"""

        # make sure user is logged in
        user = endpoints.get_current_user()
        if not user:
            raise endpoints.UnauthorizedException("Authorization required")
        user_id = getUserId(user)

        # get speaker value from form request
        sessionSpeakerOfInterest = request.speaker

        # store all session objects across all conferences where this speaker is presenting
        all_sessions = []
        # query for conferences
        conferences = Conference.query()
        for conf in conferences:
            ck = getattr(conf, "key")
            wsck = ck.urlsafe()

            # For each conference, get Sessions for the Conference filtered by Speaker
            sessions = Session.query(Session.websafeConferenceKey == wsck)
            sessions = sessions.filter(Session.speaker == sessionSpeakerOfInterest)

            for session in sessions:
                all_sessions.append(session)

        # return sessions in all conferences
        return SessionForms(items=[self._copySessionToForm(session) for session in all_sessions])
开发者ID:twhetzel,项目名称:ud858-scalable-apps,代码行数:31,代码来源:conference.py

示例7: filterPlayground

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
    def filterPlayground(self, request):
        q = Conference.query()

        # advanced filter building and usage
        field = "city"
        operator = "="
        value = "London"
        f = ndb.query.FilterNode(field, operator, value)
        q = q.filter(f)

        # TODO
        # add 2 filters:
        # 1: city equals to London
        # 2: topic equals "Medical Innovations"

        field = "topics"
        operation = "="
        value = "Medical Innovations"
        f = ndb.query.FilterNode(field, operator, value)
        q = q.filter(f)

        q = q.order(Conference.maxAttendees)

        return ConferenceForms(
            items=[self._copyConferenceToForm(conf, "") for conf in q]
        )
开发者ID:silveruby,项目名称:udacity-full-stack-p4,代码行数:28,代码来源:conference.py

示例8: getConferencesWithSpace

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
 def getConferencesWithSpace(self, request):
     ''' Get a list of conferences with seats available. '''
     q = Conference.query()
     q = q.filter(Conference.seatsAvailable > 0)
     q = q.order(Conference.seatsAvailable)
     return ConferenceForms(
         items=[self._copyConferenceToForm(conf, "") for conf in q])
开发者ID:kirklink,项目名称:udacity-fullstack-p4,代码行数:9,代码来源:conference.py

示例9: testUnregisterFromConference

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
    def testUnregisterFromConference(self):
        """ TEST: Unregister user for selected conference."""
        self.initDatabase()

        # verify database fixture
        self.login()
        prof = ndb.Key(Profile, self.getUserId()).get()
        conf = Conference.query(Conference.name == 'room #2').get()
        assert conf and conf.seatsAvailable == 1 and len(prof.conferenceKeysToAttend) == 0, \
            "This shouldn't fail. Maybe someone messed with database fixture"

        prof.conferenceKeysToAttend.append(conf.key)
        prof.put()

        container = CONF_GET_REQUEST.combined_message_class(
            websafeConferenceKey=conf.key.urlsafe(),
        )

        # unregister conference
        r = self.api.unregisterFromConference(container)

        # re-fetch profile and conference, then check if user was properly unregistered
        prof = prof.key.get()
        conf = conf.key.get()
        assert r.data, 'Returned an invalid response'
        assert len(prof.conferenceKeysToAttend) == 0, "Failed to remove conference from user's conferenceKeysToAttend"
        assert conf.seatsAvailable == 2, 'Failed to increment available seats'
开发者ID:LuizGsa21,项目名称:p4-conference-central,代码行数:29,代码来源:test_conference.py

示例10: _getQuery

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
    def _getQuery(self, request, kind="Conference"):
        """Return formatted query from the submitted filters.
           The request (ConferenceQueryForms) from queryConferences is passed here.
           The request.filters is passed to _formatFilters(request.filters)
           The filters are a list of ConferenceQueryForms
        """

        q = Conference.query()

        inequality_filter, filters = self._formatFilters(request.filters)

        # If exists, sort on inequality filter first
        if not inequality_filter:
            q = q.order(Conference.name)
        else:
            q = q.order(ndb.GenericProperty(inequality_filter))
            q = q.order(Conference.name)

        for filtr in filters:
            if filtr["field"] in ["month", "maxAttendees"]:
                filtr["value"] = int(filtr["value"])
            formatted_query = ndb.query.FilterNode(filtr["field"], filtr["operator"], filtr["value"])
            q = q.filter(formatted_query)
            # print '_getQuery returns: %s' % q

        return q
开发者ID:haopei,项目名称:Conference-Central-FSND-P4,代码行数:28,代码来源:conference.py

示例11: _getQuery

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
    def _getQuery(self, request):
        """Return formatted query from the submitted filters."""
        q = Conference.query()
        filters = self._formatFilters(request.filters, kind='conference')

        qf = []
        sets = None
        for filtr in filters:
            if filtr["field"] in ["month", "maxAttendees"]:
                filtr["value"] = int(filtr["value"])
            formatted_query = ndb.query.FilterNode(
                filtr["field"], filtr["operator"], filtr["value"])
            qs = q.filter(formatted_query).fetch(keys_only=True)
            qf.append(qs)

        for idx, val in enumerate(qf):
            if (idx == 0):
                sets = set(val)
            else:
                sets = sets.intersection(val)

        if sets:
            q = ndb.get_multi(sets)

        return q
开发者ID:chriswilley,项目名称:conference-central,代码行数:27,代码来源:conference.py

示例12: _cacheAnnouncement

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
    def _cacheAnnouncement():
        """Create Announcement & assign to memcache; used by
        memcache cron job & putAnnouncement().
        """

        logging.info('_cacheAnnouncement entered')

        confs = Conference.query(ndb.AND(
            Conference.seatsAvailable <= 5,
            Conference.seatsAvailable > 0)
        ).fetch(projection=[Conference.name])

        if confs:
            # If there are almost sold out conferences,
            # format announcement and set it in memcache
            announcement = ANNOUNCEMENT_TPL % (
                ', '.join(conf.name for conf in confs))
            memcache.set(MEMCACHE_ANNOUNCEMENTS_KEY, announcement)
        else:
            # If there are no sold out conferences,
            # delete the memcache announcements entry
            announcement = ""
            memcache.delete(MEMCACHE_ANNOUNCEMENTS_KEY)

        return announcement
开发者ID:Kakadu123,项目名称:ConferenceApp,代码行数:27,代码来源:conference.py

示例13: getSessionsByCityAndDate

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
    def getSessionsByCityAndDate(self, request):
        """Query for conference sessions that are held in a specific city
        and within a specific date interval.
        """
        confs = Conference.query(Conference.city == request.city)
        # raise exception if no conference found
        if not confs:
            raise endpoints.NotFoundException(
                'No conference found to be held in %s' % request.city)
        # convert dates from strings to Date objects;
        startDate = datetime.strptime(request.startDate, "%Y-%m-%d").date()
        endDate = datetime.strptime(request.endDate, "%Y-%m-%d").date()

        # query all sessions that are held between the requested dates
        # and sort it in order
        sessions = []
        for conf in confs:
            sessions += Session.query(ancestor=conf.key).filter(
                            ndb.AND(Session.date >= startDate,
                                    Session.date <= endDate)).order(
                                Session.date).fetch()

        # return individual SessionForm object per session
        return SessionForms(
                items=[self._copySessionToForm(
                    ses, getattr(ses.key.parent().get(), 'name'))
                        for ses in sessions])
开发者ID:DuCalixte,项目名称:ConferenceCentral,代码行数:29,代码来源:conference.py

示例14: list_conferences

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
def list_conferences():
    """List all conferences"""
    conferences = Conference.query()

    return render_template(
        'list_conferences.html', conferences=conferences
    )
开发者ID:gdgbogota,项目名称:flask-appengine-template,代码行数:9,代码来源:views.py

示例15: _cacheAnnouncement

# 需要导入模块: from models import Conference [as 别名]
# 或者: from models.Conference import query [as 别名]
    def _cacheAnnouncement():
        """Create Announcement & assign to memcache;
        used by memcache cron job & putAnnouncement(). """
        nearSoldOutConferences = Conference.query(ndb.AND(
            Conference.seatsAvailable <= 5,
            Conference.seatsAvailable > 0
        )).fetch(
            projection = [Conference.name]
        )

        if nearSoldOutConferences:
            # format announcement and set it in memcache.
            announcement = """Last chance to attend! The following conferences
                are nearly sold out:
                {nearSoldOutConferences}""".format(
                    nearSoldOutConferences = ", ".join(
                        c.name for c in nearSoldOutConferences
                    )
                )
            memcache.set(MEMCACHE_ANNOUNCEMENTS_KEY, announcement)
        else:
            # delete the memcache annoucements entry.
            announcement = ""
            memcache.delete(MEMCACHE_ANNOUNCEMENTS_KEY)

        return announcement
开发者ID:TsubasaK111,项目名称:MeetingMaster,代码行数:28,代码来源:conference.py


注:本文中的models.Conference.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。