本文整理汇总了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())
示例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())
示例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()))
示例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)
示例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())