本文整理汇总了Python中utils.local_today函数的典型用法代码示例。如果您正苦于以下问题:Python local_today函数的具体用法?Python local_today怎么用?Python local_today使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了local_today函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_pending_list
def get_pending_list(cls):
return (
cls.all()
.filter("start_time >", local_today())
.filter("status IN", ["pending", "understaffed", "onhold", "expired"])
.order("start_time")
)
开发者ID:grue,项目名称:hd-events,代码行数:7,代码来源:models.py
示例2: get_all_future_list
def get_all_future_list(cls):
return (
cls.all()
.filter("start_time >", local_today())
.filter("status IN", ["approved", "not_approved", "canceled", "pending", "onhold"])
.order("start_time")
)
开发者ID:grue,项目名称:hd-events,代码行数:7,代码来源:models.py
示例3: get_recent_not_approved_list
def get_recent_not_approved_list(cls):
return (
cls.all()
.filter("start_time >", local_today() - timedelta(days=60))
.filter("status IN", ["not_approved"])
.order("start_time")
)
开发者ID:grue,项目名称:hd-events,代码行数:7,代码来源:models.py
示例4: get_approved_list
def get_approved_list(cls):
return (
cls.all()
.filter("start_time >", local_today())
.filter("status IN", ["approved", "canceled"])
.order("start_time")
)
开发者ID:grue,项目名称:hd-events,代码行数:7,代码来源:models.py
示例5: post
def post(self):
user = users.get_current_user()
try:
start_time = datetime.strptime('%s %s:%s %s' % (
self.request.get('date'),
self.request.get('start_time_hour'),
self.request.get('start_time_minute'),
self.request.get('start_time_ampm')), '%m/%d/%Y %I:%M %p')
end_time = datetime.strptime('%s %s:%s %s' % (
self.request.get('date'),
self.request.get('end_time_hour'),
self.request.get('end_time_minute'),
self.request.get('end_time_ampm')), '%m/%d/%Y %I:%M %p')
conflicts = Event.check_conflict(start_time,end_time,self.request.get_all('rooms'))
if conflicts:
raise ValueError('Room conflict detected')
if not self.request.get('estimated_size').isdigit():
raise ValueError('Estimated number of people must be a number')
if not int(self.request.get('estimated_size')) > 0:
raise ValueError('Estimated number of people must be greater then zero')
if (end_time-start_time).days < 0:
raise ValueError('End time must be after start time')
if ( self.request.get( 'contact_phone' ) and not is_phone_valid( self.request.get( 'contact_phone' ) ) ):
raise ValueError( 'Phone number does not appear to be valid' )
else:
event = Event(
name = cgi.escape(self.request.get('name')),
start_time = start_time,
end_time = end_time,
type = cgi.escape(self.request.get('type')),
estimated_size = cgi.escape(self.request.get('estimated_size')),
contact_name = cgi.escape(self.request.get('contact_name')),
contact_phone = cgi.escape(self.request.get('contact_phone')),
details = cgi.escape(self.request.get('details')),
url = cgi.escape(self.request.get('url')),
fee = cgi.escape(self.request.get('fee')),
notes = cgi.escape(self.request.get('notes')),
rooms = self.request.get_all('rooms'),
expired = local_today() + timedelta(days=PENDING_LIFETIME), # Set expected expiration date
)
event.put()
log = HDLog(event=event,description="Created new event")
log.put()
notify_owner_confirmation(event)
notify_new_event(event)
set_cookie(self.response.headers, 'formvalues', None)
self.redirect('/event/%s-%s' % (event.key().id(), slugify(event.name)))
except Exception, e:
message = str(e)
if 'match format' in message:
message = 'Date is required.'
if message.startswith('Property'):
message = message[9:].replace('_', ' ').capitalize()
# This is NOT a reliable way to handle erorrs
#set_cookie(self.response.headers, 'formerror', message)
#set_cookie(self.response.headers, 'formvalues', dict(self.request.POST))
#self.redirect('/new')
error = message
self.response.out.write(template.render('templates/error.html', locals()))
开发者ID:stighackvan,项目名称:hd-events,代码行数:59,代码来源:main.py
示例6: get_recent_past_and_future
def get_recent_past_and_future(cls):
return (
cls.all()
.filter("start_time >", local_today() - timedelta(days=1))
.filter("status IN", ["approved", "canceled"])
.order("start_time")
.fetch(200)
)
开发者ID:grue,项目名称:hd-events,代码行数:8,代码来源:models.py
示例7: get
def get(self):
user = users.get_current_user()
if user:
logout_url = users.create_logout_url('/')
else:
login_url = users.create_login_url('/')
today = local_today()
events = Event.all().filter('start_time < ', today).order('-start_time')
self.response.out.write(template.render('templates/past.html', locals()))
开发者ID:jonhull,项目名称:hd-events,代码行数:9,代码来源:main.py
示例8: post
def post(self):
# Find events expiring in 10 days to warn owner
ten_days = local_today() + timedelta(days=10)
events = Event.all() \
.filter('status IN', ['pending', 'understaffed']) \
.filter('expired >=', ten_days) \
.filter('expired <', ten_days + timedelta(days=1))
for event in events:
notify_owner_expiring(event)
开发者ID:jernst,项目名称:hd-events,代码行数:9,代码来源:main.py
示例9: get_approved_list_with_multiday
def get_approved_list_with_multiday(cls):
events = list(cls.all().filter("end_time >", local_today()).filter("status IN", ["approved", "canceled"]))
# create dupe event objects for each day of multiday events
for event in list(events):
if event.start_time < local_today():
# remove original if it started before today
events.remove(event)
for day in range(1, event.num_days):
if event.start_time + timedelta(days=day) >= local_today():
clone = copy(event)
clone.start_time = datetime.combine(event.start_date(), time()) + timedelta(days=day)
clone.is_continued = True
events.append(clone)
events.sort(key=lambda event: event.start_time)
return events
开发者ID:grue,项目名称:hd-events,代码行数:18,代码来源:models.py
示例10: get
def get(self):
user = users.get_current_user()
if user:
logout_url = users.create_logout_url('/')
else:
login_url = users.create_login_url('/')
today = local_today()
show_all_nav = user
events = Event.get_recent_not_approved_list()
self.response.out.write(template.render('templates/not_approved.html', locals()))
开发者ID:jernst,项目名称:hd-events,代码行数:10,代码来源:main.py
示例11: get
def get(self):
user = users.get_current_user()
if user:
logout_url = users.create_logout_url("/")
else:
login_url = users.create_login_url("/")
today = local_today()
show_all_nav = user
events = Event.all().filter("start_time < ", today).order("-start_time")
self.response.out.write(template.render("templates/past.html", locals()))
开发者ID:kiwinoy,项目名称:hd-events,代码行数:10,代码来源:main.py
示例12: post
def post(self):
# Find events expiring in 10 days to warn owner
ten_days = local_today() + timedelta(days=10)
events = (
Event.all()
.filter("status IN", ["pending", "understaffed"])
.filter("expired >=", ten_days)
.filter("expired <", ten_days + timedelta(days=1))
)
for event in events:
notify_owner_expiring(event)
开发者ID:billsaysthis,项目名称:hd-events,代码行数:11,代码来源:main.py
示例13: get
def get(self):
user = users.get_current_user()
if user:
logout_url = users.create_logout_url("/")
else:
login_url = users.create_login_url("/")
today = local_today()
show_all_nav = user
events = Event.get_recent_not_approved_list()
# this is not the permanent answer but just for now
cdn = "http://cdn.hackerdojo.com"
self.response.out.write(template.render("templates/not_approved.html", locals()))
开发者ID:billsaysthis,项目名称:hd-events,代码行数:12,代码来源:main.py
示例14: get_approved_list_with_multiday
def get_approved_list_with_multiday(cls):
# TODO(eascott): PEP8: the backslash is redundant between brackets
events = list(cls.all() \
.filter('end_time >', local_today()) \
.filter('status IN', ['approved', 'canceled']))
# create dupe event objects for each day of multiday events
for event in list(events):
if event.start_time < local_today():
# remove original if it started before today
events.remove(event)
for day in range(1, event.num_days):
if event.start_time + timedelta(days=day) >= local_today():
clone = copy(event)
clone.start_time = datetime.combine(event.start_date(), time()) + timedelta(days=day)
clone.is_continued = True
events.append(clone)
# TODO(eascott): shadows name 'event' from outer scope
events.sort(key=lambda event: event.start_time)
return events
开发者ID:eascott,项目名称:hd-events-api,代码行数:22,代码来源:hdeventsapi.py
示例15: post
def post(self):
user = users.get_current_user()
try:
start_time = datetime.strptime("%s %s:%s %s" % (
self.request.get('date'),
self.request.get('start_time_hour'),
self.request.get('start_time_minute'),
self.request.get('start_time_ampm')), "%m/%d/%Y %I:%M %p")
end_time = datetime.strptime("%s %s:%s %s" % (
self.request.get('date'),
self.request.get('end_time_hour'),
self.request.get('end_time_minute'),
self.request.get('end_time_ampm')), "%m/%d/%Y %I:%M %p")
if (end_time-start_time).days < 0:
raise ValueError("End time must be after start time")
else:
event = Event(
name = self.request.get('name'),
start_time = start_time,
end_time = end_time,
type = self.request.get('type'),
estimated_size = self.request.get('estimated_size'),
contact_name = self.request.get('contact_name'),
contact_phone = self.request.get('contact_phone'),
details = self.request.get('details'),
url = self.request.get('url'),
fee = self.request.get('fee'),
notes = self.request.get('notes'),
rooms = self.request.get_all('rooms'),
expired = local_today() + timedelta(days=PENDING_LIFETIME), # Set expected expiration date
)
event.put()
notify_owner_confirmation(event)
if not event.is_staffed():
notify_staff_needed(event)
notify_new_event(event)
set_cookie(self.response.headers, 'formvalues', None)
self.redirect('/event/%s-%s' % (event.key().id(), slugify(event.name)))
except Exception, e:
message = str(e)
if 'match format' in message:
message = "Date is required."
if message.startswith('Property'):
message = message[9:].replace('_', ' ').capitalize()
set_cookie(self.response.headers, 'formerror', message)
set_cookie(self.response.headers, 'formvalues', dict(self.request.POST))
self.redirect('/new')
开发者ID:mdhancher,项目名称:hd-events,代码行数:47,代码来源:main.py
示例16: is_past
def is_past(self):
return self.end_time < local_today()
开发者ID:mdhancher,项目名称:hd-events,代码行数:2,代码来源:models.py
示例17: get_pending_list
def get_pending_list(cls):
return cls.all() \
.filter('start_time >', local_today()) \
.filter('status IN', ['pending', 'understaffed', 'onhold', 'expired']) \
.order('start_time')
开发者ID:mdhancher,项目名称:hd-events,代码行数:5,代码来源:models.py
示例18: get_approved_list
def get_approved_list(cls):
return cls.all() \
.filter('start_time >', local_today()) \
.filter('status IN', ['approved', 'canceled']) \
.order('start_time')
开发者ID:mdhancher,项目名称:hd-events,代码行数:5,代码来源:models.py
注:本文中的utils.local_today函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论