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


Python Event.all方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
    def get(self):
        db.delete(Event.all().fetch(500))
        
        event_count = Event.all().count()
        
        self.response.out.write("Events flushed. " + str(event_count) + " teams remain. What have we done?!")

        
开发者ID:Apple101Review,项目名称:the-blue-alliance,代码行数:8,代码来源:datafeed_controller.py

示例2: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
 def get(self):
     for event in Event.all().fetch(1000):
         logging.info(event.name)
         taskqueue.add(
             url='/tasks/eventteam_update/' + event.key().name(),
             method='GET')
     
     template_values = {
         'event_count': Event.all().count(),
     }
     
     path = os.path.join(os.path.dirname(__file__), '../templates/cron/eventteam_update_enqueue.html')
     self.response.out.write(template.render(path, template_values))
开发者ID:Apple101Review,项目名称:the-blue-alliance,代码行数:15,代码来源:cron_controller.py

示例3: view_events_serialise

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
def view_events_serialise(request, country, region):
    """
    AJAX
    return list of events for given country and region
    if user is registered, than provide information about favorite and RSVP state
    """

    if request.method == "GET":
        if request.GET.has_key("format") and request.GET["format"] == "csv":

            r = None
            c = None

            if country != u"all":
                c = Country.get_by_key_name(country.strip())
                if c is None:
                    return HttpResponse("")

                if region != u"all":
                    r = Region.get_by_key_name(region.strip())
                    if r is None:
                        return HttpResponse("")

            # if r defined, then c has to be defined as well
            assert not r or (r and c)
            q = Event.all()
            if c:
                q.filter("country =", c)
            if r:
                q.filter("region =", r)

            in_iframe = request.GET.has_key("in_iframe")
            return HttpResponse(serialise_events_for_query(q, request.user, in_iframe, True, True))

    return HttpResponseNotFound()
开发者ID:fikander,项目名称:aolevents,代码行数:37,代码来源:views.py

示例4: view_event_mine

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
def view_event_mine(request):
    if request.user.is_superuser:
        q = Event.all()
    else:
        q = request.user.event_set

    return object_list(request, q, paginate_by=20, template_name="event_list_mine.html")
开发者ID:fikander,项目名称:aolevents,代码行数:9,代码来源:views.py

示例5: test_recurring_no_weekends

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
  def test_recurring_no_weekends(self):
    # Make a recurring event that happens every day.
    recurring_data = self.recurring_data.copy()
    params = self.params.copy()
    recurring_data["frequency"] = "daily"
    # We want to force there to be some weekends...
    recurring_data["repetitions"] = 6
    recurring_data["weekdaysOnly"] = True
    params["recurring-data"] = json.dumps(recurring_data)
    params["recurring"] = True

    response = self.test_app.post("/new", params)
    self.assertEqual(200, response.status_int)

    # Check the datastore.
    num_events = Event.all().count()
    self.assertEqual(6, num_events)

    query = db.GqlQuery("SELECT * FROM Event ORDER BY start_time ASC")
    last_event = None
    for event in query.run():
      if last_event:
        event_diff = event.start_time - last_event.start_time
        if last_event.start_time.weekday() < 4:
          # They should all be one day from the last one, unless the last one
          # was on Friday or a weekend. (The first one could still be on a
          # weekend.)
          self.assertEqual(1, event_diff.days)

        self.assertLess(event.start_time.weekday(), 5)

      last_event = event
开发者ID:jayjay2016,项目名称:hd-events,代码行数:34,代码来源:test_main.py

示例6: event_export

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
def event_export(request):
    user = users.get_current_user()
    query = Event.all().filter('owner =',user).order('start')
    results = []
    for e in query.fetch(1000): # TODO:
        d = {'summary':e.summary,
              'start':e.start,
              'finish':e.finish, 
              'cooperation_dep':e.cooperation_dep,
              'content':e.content,
              'aim':e.aim,
              'resolved_problem':e.resolved_problem,
              'leave_problem':e.leave_problem,
              'total_work_time':e.total_work_time,
              'last_modified':e.last_modified,
              'created':e.created,}
        period_set = []
        for period in e.period_set:
            period_set.append({
                   'start':period.start,
                   'finish':period.finish,
                   'content':period.content,
                   'last_modified':period.last_modified,
                   'created':period.created,
                   'current':str(period.key())==e.last_period})
        d['period_set'] = period_set
        results.append(d)
    from django.core.serializers.json import DjangoJSONEncoder
    response = HttpResponse(simplejson.dumps(results,cls=DjangoJSONEncoder,sort_keys=True,indent=4),mimetype="text/plain")
    response['Content-Disposition'] = 'attachment; filename=%s_export.json'%user.email()
    return response
开发者ID:lijiangt,项目名称:oa-gae,代码行数:33,代码来源:views.py

示例7: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
    def get(self, format):
        events = Event.all().filter('status IN', ['approved', 'canceled']).order('start_time')
        if format == 'ics':
            cal = Calendar()
            for event in events:
                cal.add_component(event.to_ical())
            self.response.headers['content-type'] = 'text/calendar'
            self.response.out.write(cal.as_string())
        elif format == 'json':
            self.response.headers['content-type'] = 'application/json'
            events = map(lambda x: x.to_dict(summarize=True), Event.get_approved_list())
            self.response.out.write(simplejson.dumps(events))
        elif format =='rss':
            url_base = 'http://' + self.request.headers.get('host', 'events.hackerdojo.com')
            rss = PyRSS2Gen.RSS2(
                title = "Hacker Dojo Events Feed",
                link = url_base,
                description = "Upcoming events at the Hacker Dojo in Mountain View, CA",
                lastBuildDate = datetime.now(),
                items = [PyRSS2Gen.RSSItem(
                            title = event.name,
                            link = url_base + event_path(event),
                            description = event.details,
                            guid = url_base + event_path(event),
                            pubDate = event.updated,
                         ) for event in events]
            )

            self.response.headers['content-type'] = 'application/xml'
            self.response.out.write(rss.to_xml())
开发者ID:jonhull,项目名称:hd-events,代码行数:32,代码来源:main.py

示例8: export_ics

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
 def export_ics(self):
     events = Event.all().filter('status IN', ['approved', 'canceled']).order('start_time')
     url_base = 'http://' + self.request.headers.get('host', 'events.hackerdojo.com')
     cal = Calendar()
     for event in events:
         iev = CalendarEvent()
         iev.add('summary', event.name if event.status == 'approved' else event.name + ' (%s)' % event.status.upper())
         # make verbose description with empty fields where information is missing
         ev_desc = '__Status: %s\n__Member: %s\n__Type: %s\n__Estimated size: %s\n__Info URL: %s\n__Fee: %s\n__Contact: %s, %s\n__Rooms: %s\n\n__Details: %s\n\n__Notes: %s' % (
             event.status, 
             event.owner(), 
             event.type, 
             event.estimated_size, 
             event.url, 
             event.fee, 
             event.contact_name, 
             event.contact_phone, 
             event.roomlist(), 
             event.details, 
             event.notes)
         # then delete the empty fields with a regex
         ev_desc = re.sub(re.compile(r'^__.*?:[ ,]*$\n*',re.M),'',ev_desc)
         ev_desc = re.sub(re.compile(r'^__',re.M),'',ev_desc)
         ev_url = url_base + event_path(event)
         iev.add('description', ev_desc + '\n--\n' + ev_url)
         iev.add('url', ev_url)
         if event.start_time:
           iev.add('dtstart', event.start_time.replace(tzinfo=pytz.timezone('US/Pacific')))
         if event.end_time:
           iev.add('dtend', event.end_time.replace(tzinfo=pytz.timezone('US/Pacific')))
         cal.add_component(iev)
     return 'text/calendar', cal.as_string()
开发者ID:bluehat,项目名称:hd-events,代码行数:34,代码来源:main.py

示例9: expand_recurring_events

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
def expand_recurring_events(request):
    try:
        cursor=request.POST.get('cursor')
        recurring_events_q=Event.all().filter('repeats_frequency >=', 'MONTHLY').filter('status =', 'approved')
        if cursor:
            recurring_events_q=recurring_events_q.with_cursor(cursor)
        
        events=recurring_events_q.fetch(1)
        if events:
            taskqueue.add(url='/events/expand_recurring_events/', params={'cursor':recurring_events_q.cursor()})
        
        for event in events:
            logging.warning("expanding %s" % event.title)
            if event.repeats_frequency == 'WEEKLY':
                rule=rrule(WEEKLY, dtstart=event.site.today,
                byweekday=event.local_start.weekday(),
                count=5)
                copies=event.copy(rule)
                db.put(copies)
            elif event.repeats_frequency == 'MONTHLY':
                ordinal=event.repeats_setpos
                weekday=(MO,TU,WE,TH,FR,SU)[event.local_start.weekday()](ordinal)
                logging.warning(ordinal)
                rule=rrule(MONTHLY, dtstart=event.site.today, 
                byweekday=weekday(ordinal), 
                count=5,
                wkst=MO)
                copies=event.copy(rule)
                db.put(copies)
        
    except Exception,e:
            logging.error("%s in \n%s"% (traceback.format_exc(),str(request.POST)))        
开发者ID:Hubble1,项目名称:eventgrinder,代码行数:34,代码来源:tasks.py

示例10: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
 def get(self, year=None):
     if year:
         year = int(year)
         explicit_year = True
     else:
         year = datetime.datetime.now().year
         explicit_year = False
     
     memcache_key = "event_list_%s" % year
     html = memcache.get(memcache_key)
     
     if html is None:
         events = Event.all().filter("year =", int(year)).order('start_date').fetch(1000)
     
         template_values = {
             "explicit_year": explicit_year,
             "year": year,
             "events": events,
         }
     
         path = os.path.join(os.path.dirname(__file__), '../templates/events/list.html')
         html = template.render(path, template_values)
         memcache.set(memcache_key, html, 3600)
     
     self.response.out.write(html)
开发者ID:Apple101Review,项目名称:the-blue-alliance,代码行数:27,代码来源:event_controller.py

示例11: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
    def get(self, format):
        events = Event.all().filter("status IN", ["approved", "canceled"]).order("start_time")
        if format == "ics":
            cal = Calendar()
            for event in events:
                cal.add_component(event.to_ical())
            self.response.headers["content-type"] = "text/calendar"
            self.response.out.write(cal.as_string())
        elif format == "json":
            self.response.headers["content-type"] = "application/json"
            events = map(lambda x: x.to_dict(summarize=True), Event.get_approved_list())
            self.response.out.write(simplejson.dumps(events))
        elif format == "rss":
            url_base = "http://" + self.request.headers.get("host", "events.hackerdojo.com")
            rss = PyRSS2Gen.RSS2(
                title="Hacker Dojo Events Feed",
                link=url_base,
                description="Upcoming events at the Hacker Dojo in Mountain View, CA",
                lastBuildDate=datetime.now(),
                items=[
                    PyRSS2Gen.RSSItem(
                        title=event.name,
                        link=url_base + event_path(event),
                        description=event.details,
                        guid=url_base + event_path(event),
                        pubDate=event.updated,
                    )
                    for event in events
                ],
            )

            self.response.headers["content-type"] = "application/xml"
            self.response.out.write(rss.to_xml())
开发者ID:deanmao,项目名称:hd-events,代码行数:35,代码来源:main.py

示例12: test_weekly_recurring_events

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
  def test_weekly_recurring_events(self):
    # Make a recurring event that happens every week.
    recurring_data = self.recurring_data.copy()
    params = self.params.copy()
    recurring_data["frequency"] = "weekly"
    params["recurring-data"] = json.dumps(recurring_data)
    params["recurring"] = True

    response = self.test_app.post("/new", params)
    self.assertEqual(200, response.status_int)

    # Check the datastore.
    num_events = Event.all().count()
    self.assertEqual(5, num_events)

    query = db.GqlQuery("SELECT * FROM Event ORDER BY start_time ASC")
    last_event = None
    for event in query.run():
      if last_event:
        # They should all be on the same day of the week.
        self.assertEqual(last_event.start_time.weekday(),
                         event.start_time.weekday())
        # They should all be one week from the last one.
        event_diff = event.start_time - last_event.start_time
        self.assertEqual(7, event_diff.days)

      last_event = event
开发者ID:jayjay2016,项目名称:hd-events,代码行数:29,代码来源:test_main.py

示例13: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
 def get(self):                        
     page = memcache.get("homepage")
     if page is None:
         events = Event.all().order("-sent").fetch(1000)
         path = os.path.join(os.path.dirname(__file__), 'templates', 'index.html')
         page = template.render(path, {"events": events,})
         memcache.add("homepage", page)
     self.response.out.write(page)
开发者ID:benburry,项目名称:towel,代码行数:10,代码来源:main.py

示例14: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
 def get(self, format):
     if format == 'ics':
         events = Event.all().filter('status IN', ['approved', 'canceled']).order('start_time')
         cal = Calendar()
         for event in events:
             cal.add_component(event.to_ical())
         self.response.headers['content-type'] = 'text/calendar'
         self.response.out.write(cal.as_string())
开发者ID:btubbs,项目名称:hd-events,代码行数:10,代码来源:main.py

示例15: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import all [as 别名]
    def get(self):
        self.response.headers['Content-Type'] = "application/rss+xml; charset=utf-8"

        host = self.request.headers.get('host', 'nohost')
        base_url = self.request.scheme + "://" + host

        events = []
        query = Event.all().order("-start")

        # Filter query by requested services, if specified in the 'service' URL parameter.
        service_list = []
        for service_arg in self.request.get_all('services'):
            service_list.extend(service_arg.split(','))
        service_list = map(lambda serv_slug: Service.get_by_slug(serv_slug), service_list)
        # filter out any non-existent services
        service_list = filter(lambda service: not service is None, service_list)

        service_string = 'all services'
        if len(service_list) > 0:
            query.filter('service IN', service_list)
            if len(service_list) == 1:
                service_string = 'the %s service' % service_list[0].name
            elif len(service_list) == 2:
                service_string = 'the %s and %s services' % (service_list[0].name, service_list[1].name)
            else:
                service_string = 'the %s, and %s services' % (', '.join([service.name for service in service_list[:-1]]), service_list[-1].name)

        # Create the root 'rss' element
        rss_xml = et.Element('rss')
        rss_xml.set('version', '2.0')

        # Create the channel element and its metadata elements
        channel = et.SubElement(rss_xml, 'channel')
        title = et.SubElement(channel, 'title')
        title.text = '%s Service Events' % settings.SITE_NAME
        description = et.SubElement(channel, 'description')
        description.text = 'This feed shows the last %d events on %s on %s.' % (settings.RSS_NUM_EVENTS_TO_FETCH, service_string, settings.SITE_NAME)
        link = et.SubElement(channel, 'link')
        link.text = base_url

        # Create each of the feed events.
        item_subelements = {
            'title': lambda(event): '[%s - %s] %s' % (event.service.name, event.status.name, unicode(event.message)),
            'description': lambda(event): '%s' % unicode(event.message),
            'link': lambda(event): '%s/services/%s' % (base_url, event.service.slug),
            'category': lambda(event): event.service.name,
            'pubDate': lambda(event): format_date_time(mktime(event.start.timetuple())),
            'guid': lambda(event): '%s/api/v1/services/%s/events/%s' % (base_url, event.service.slug, unicode(event.key()))
        }

        for event in query.fetch(settings.RSS_NUM_EVENTS_TO_FETCH):
            item = et.SubElement(channel, 'item')
            for tag, text_func in item_subelements.iteritems():
                subelement = et.SubElement(item, tag)
                subelement.text = text_func(event)

        self.response.out.write('<?xml version="1.0" encoding="UTF-8"?>\n')
        self.response.out.write(et.tostring(rss_xml))
开发者ID:Open-Source-GIS,项目名称:stashboard,代码行数:60,代码来源:site.py


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