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


Python Event.get_approved_list方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_approved_list [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

示例2: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_approved_list [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

示例3: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_approved_list [as 别名]
 def get(self):
     user = users.get_current_user()
     if user:
         logout_url = users.create_logout_url('/')
     else:
         login_url = users.create_login_url('/')
     today = datetime.today()
     events = Event.get_approved_list()
     tomorrow = today + timedelta(days=1)
     self.response.out.write(template.render('templates/approved.html', locals()))
开发者ID:btubbs,项目名称:hd-events,代码行数:12,代码来源:main.py

示例4: export_json

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_approved_list [as 别名]
 def export_json(self):
     events = Event.get_approved_list()
     for k in self.request.GET:
         if self.request.GET[k] and k in ['member']:
             value = users.User(urllib.unquote(self.request.GET[k]))
         else:
             value = urllib.unquote(self.request.GET[k])
         events = events.filter('%s =' % k, value)
     events = map(lambda x: x.to_dict(summarize=True), events)
     return 'application/json', simplejson.dumps(events)
开发者ID:bluehat,项目名称:hd-events,代码行数:12,代码来源:main.py

示例5: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_approved_list [as 别名]
 def get(self, format):
     events = Event.all().filter('status IN', ['approved', 'canceled']).order('start_time')
     url_base = 'http://' + self.request.headers.get('host', 'events.hackerdojo.com')
     if 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 == 'ics':
             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)
             self.response.headers['content-type'] = 'text/calendar'
             self.response.out.write(cal.as_string())
     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:stighackvan,项目名称:hd-events,代码行数:57,代码来源:main.py


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