當前位置: 首頁>>代碼示例>>Python>>正文


Python Event.all方法代碼示例

本文整理匯總了Python中core.models.Event.all方法的典型用法代碼示例。如果您正苦於以下問題:Python Event.all方法的具體用法?Python Event.all怎麽用?Python Event.all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在core.models.Event的用法示例。


在下文中一共展示了Event.all方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setUp

# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import all [as 別名]
    def setUp(self):
        app = get_application()
        self.client = Client(app, BaseResponse)

        self.test_values = {
            'date': datetime.datetime(2016, 5, 20, 15, 0),
            'title': 'THIS IS TITLE',
            'description': 'THIS IS TITLE',
        }

        eve = Event(
            event_date=self.test_values['date'],
            title=self.test_values['title'],
            description=self.test_values['description'],
        )
        eve.put()
        events = Event.all().fetch(100)
        self.assertEquals(len(events), 1)
        self.assertEquals(events[0].title, 'THIS IS TITLE')
        self.event_key = str(events[0].key())
開發者ID:yosukesuzuki,項目名稱:calendar-app,代碼行數:22,代碼來源:test_views.py

示例2: event_feed

# 需要導入模塊: from core.models import Event [as 別名]
# 或者: from core.models.Event import all [as 別名]
def event_feed(request):
    try:
        theyear_themonth = request.args['month'].split('-')
        theyear = int(theyear_themonth[0])
        themonth = int(theyear_themonth[1])
        feed_title = 'Events of: %s %d' % (calendar.month_name[themonth], theyear)
        if themonth < 1 or themonth > 12:
            raise ValueError
    except:
        now = datetime.now()
        theyear = now.year
        themonth = now.month
        feed_title = _('Upcoming Event')
    first_day_of_themonth = datetime(theyear, themonth, 1) + timedelta(days=-1)
    three_month_after = add_months(first_day_of_themonth, 2)
    results = Event.all().filter(u'event_date >=', first_day_of_themonth).filter(
        u'event_date <', three_month_after).order('event_date').fetch(1000)
    events = [
        {'date': r.event_date.strftime('%Y-%m-%d %H:%M'),
         'title': r.title, 'description': r.description, 'key': str(r.key())} for r in results]
    return render_json_response({'events': events, 'title': feed_title}, mimetype='application/json')
開發者ID:yosukesuzuki,項目名稱:calendar-app,代碼行數:23,代碼來源:views.py


注:本文中的core.models.Event.all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。