本文整理汇总了Python中models.Event.get_recent_past_and_future方法的典型用法代码示例。如果您正苦于以下问题:Python Event.get_recent_past_and_future方法的具体用法?Python Event.get_recent_past_and_future怎么用?Python Event.get_recent_past_and_future使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Event
的用法示例。
在下文中一共展示了Event.get_recent_past_and_future方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export_ics
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_recent_past_and_future [as 别名]
def export_ics(self):
events = Event.get_recent_past_and_future()
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()
示例2: export_rss
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_recent_past_and_future [as 别名]
def export_rss(self):
url_base = "http://" + self.request.headers.get("host", "events.hackerdojo.com")
events = Event.get_recent_past_and_future()
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="%s @ %s: %s"
% (
event.start_time.strftime("%A, %B %d"),
event.start_time.strftime("%I:%M%p").lstrip("0"),
event.name,
),
link=url_base + event_path(event),
description=event.details,
guid=url_base + event_path(event),
pubDate=event.updated,
)
for event in events
],
)
return "application/xml", rss.to_xml()
示例3: export_json
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_recent_past_and_future [as 别名]
def export_json(self):
events = Event.get_recent_past_and_future()
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', json.dumps(events)
示例4: export_rss
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_recent_past_and_future [as 别名]
def export_rss(self):
url_base = 'http://' + self.request.headers.get('host', 'events.hackerdojo.com')
events = Event.get_recent_past_and_future()
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]
)
return 'application/xml', rss.to_xml()
示例5: export_ics
# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_recent_past_and_future [as 别名]
def export_ics(self):
events = Event.get_recent_past_and_future()
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()