本文整理汇总了Python中models.Status.all方法的典型用法代码示例。如果您正苦于以下问题:Python Status.all方法的具体用法?Python Status.all怎么用?Python Status.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Status
的用法示例。
在下文中一共展示了Status.all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def get(self):
user = users.get_current_user()
total = TotalAmount.all().filter('user = ', user).get()
if user and total:
page = int(self.request.get('page', 1))
if page > 0:
offset = limit * (page - 1)
else:
self.redirect('/')
return
chart_labels, chart_values = mk_chart_data(total)
total_status = Status.all().filter('user = ', user).count(1000)
statuses = Status.all().filter('user = ', user).order('-updated_at').fetch(limit, offset)
if len(statuses):
self.render_response('index.html', {
'statuses': statuses,
'total_amount': total.amount,
'chart_labels': chart_labels,
'chart_values': chart_values,
'is_paginated': limit < total_status,
'has_previous': page > 1,
'has_next': (offset + limit) < total_status,
'previous_page': page - 1,
'next_page': page + 1,
})
else:
self.render_response('index.html', {
'statuses': [],
})
else:
self.render_response('index.html', {})
示例2: update
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def update(self, somekey=""):
"""
statusから抜き出してついーと
"""
"""適当"""
stasu = Status.all().order("status_id").fetch(1)
self.post(status)
示例3: data
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def data(self):
services = []
default_status = Status.get_default()
lists = []
for list in self.lists:
l = List.get_by_slug(list)
if l is not None:
lists.append(l)
for service in Service.all().filter("list IN", lists).order("name").fetch(100):
event = service.current_event()
if event is not None:
status = event.status
else:
status = default_status
if len(self.statuses) and not status.slug in self.statuses:
continue
today = date.today() + timedelta(days=1)
current, = service.history(1, default_status, start=today)
has_issues = current["information"] and status.key() == default_status.key()
service_dict = {
"slug": service.slug,
"name": service.name,
"url": service.url(),
"status": status,
"has_issues": has_issues,
"history": service.history(5, default_status),
}
services.append(service_dict)
return {"days": get_past_days(5), "statuses": Status.all().fetch(100), "services": services}
示例4: data
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def data(self):
services = []
dstatus = Status.default()
for s in Service.all().order("name").fetch(100):
event = s.current_event()
if event is not None:
status = event.status
else:
status = dstatus
service = {
"slug": s.slug,
"name": s.name,
"url": s.url(),
"status": status,
"history": s.history(5, dstatus)
}
services.append(service)
return {
"days": get_past_days(5),
"statuses": Status.all().fetch(100),
"services": services,
}
示例5: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def get(self):
statuses = Status.all()
amounts = {}
users = {}
for status in statuses:
nickname = status.user.nickname()
amount = amounts.get(nickname, {
'nama_cup': 0,
'nama_small': 0,
'nama_middle': 0,
'nama_big': 0,
'kan_350': 0,
'kan_500': 0,
})
amount[status.beer] += status.amount
amounts[nickname] = amount
if not users.has_key(nickname):
users[nickname] = status.user
for nickname, amount in amounts.items():
total = TotalAmount.all().filter('user = ', users[nickname]).get()
if total:
for beer, value in amount.items():
setattr(total, beer, value)
self.response.out.write("%s: %s(%s)<br>\n" % (nickname, beer, value))
total.put()
self.response.out.write("done.")
示例6: data
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def data(self):
services = []
default_status = Status.get_default()
query = Service.all().filter("list =", self.list).order("name")
for service in query.fetch(100):
event = service.current_event()
if event is not None:
status = event.status
else:
status = default_status
today = date.today() + timedelta(days=1)
current, = service.history(1, default_status, start=today)
has_issues = (current["information"] and
status.key() == default_status.key())
service_dict = {
"slug": service.slug,
"name": service.name,
"url": service.url(),
"status": status,
"has_issues": has_issues,
"history": service.history(5, default_status),
}
services.append(service_dict)
return {
"days": get_past_days(5),
"statuses": Status.all().fetch(100),
"services": services,
}
示例7: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def get(self, version):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
query = Status.all().order('name')
data = [s.rest(self.base_url(version)) for s in query]
self.json({"statuses": data})
示例8: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def get(self, slug):
service = Service.get_by_slug(slug)
if not service:
self.not_found()
return
td = {
"services_selected": True,
"service": service,
"statuses": Status.all().fetch(100),
}
td.update(site.default_template_data())
self.render(td, 'admin/events_create.html')
示例9: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def get(self):
# get all the statuses
query = Status.all()
# pass all the statuses and the sitetitle to the template
template_values = {
'sitetitle': SITE_TITLE,
'statuses': query,
}
# find the template
path = os.path.join(os.path.dirname(__file__), 'index.html')
# render the template
self.response.out.write(template.render(path, template_values))
示例10: post
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def post(self, version, status_slug):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
status = Status.get_by_slug(status_slug)
if not status:
self.error(404, "No status with the slug %s found" % status_slug)
return
name = self.request.get('name', default_value=None)
image_slug = self.request.get('image', default_value=None)
image = None
default = self.request.get('default', default_value=None)
description = self.request.get('description', default_value=None)
if image_slug is not None:
image = Image.get_by_slug(image_slug)
if image is None:
self.error(400, "An Image with the "
"slug %s doesn't exist" % image_slug)
return
status.image = image.path
if description is not None:
status.description = description
if default is not None and default in ["false", "true"]:
# Reset default status
if default == "true":
for stat in Status.all().filter("default", True):
stat.default = False
stat.put()
status.default = default == "true"
if name is not None:
status.name = name
if description or name or image or default:
status.put()
invalidate_cache()
self.json(status.rest(self.base_url(version)))
示例11: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def get(self):
# get all the statuses
query = Status.all()
if query.count() != 0:
for result in query:
# if there are already some, then update them
update(result)
else:
# create an example status and put it in the datastore
test = Status(description='google',
comment='the acclaimed search engine',
link_url='http://www.google.com',
link_text='www.google.com',
update_type='status',
update_url='http://www.google.com')
test.put()
示例12: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def get(self, version):
logging.debug("StatusesListHandler#get")
if (self.valid_version(version)):
query = Status.all().order('severity')
if (query):
data = []
for s in query:
data.append(s.rest(self.base_url(version)))
self.json({"statuses": data})
else:
self.error(404, "No statuses")
else:
self.error(404, "API Version %s not supported" % version)
示例13: data
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def data(self):
lists = {}
default_status = Status.get_default()
for service in Service.all().order("list").fetch(100):
event = service.current_event()
if event is not None:
status = event.status
else:
status = default_status
if service.list and not lists.has_key(service.list.slug) or \
lists[service.list.slug]["status"].name < status.name:
lists[service.list.slug] = {"list": service.list, "status": status}
return {
"lists": lists.items(),
"statuses": Status.all().fetch(100),
}
示例14: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def get(self):
user = users.get_current_user()
logging.debug("BasicRootHandler#get")
q = Service.all()
q.order("name")
services = q.fetch(100)
p = Status.all()
p.order("severity")
past = get_past_days(5)
td = default_template_data()
td["services"] = q.fetch(100)
td["statuses"] = p.fetch(100)
td["past"] = past
td["default"] = Status.default()
self.render(td, 'basic','index.html')
示例15: get
# 需要导入模块: from models import Status [as 别名]
# 或者: from models.Status import all [as 别名]
def get(self):
user = users.get_current_user()
logging.debug("BasicRootHandler#get")
today = datetime.datetime.today()
end = today
start = end - timedelta(days=+5)
start_date = dateparser.parse(self.request.get('start', default_value=str(start)))
end_date = dateparser.parse(self.request.get('end', default_value=str(end)))
history_size = config.SITE['history_size']
if end_date > today or start_date > end_date or \
today.toordinal() - history_size > start_date.toordinal():
end_date = today
start_date = end_date - timedelta(days=5)
q = Service.all()
q.order("name")
services = []
for service in q.fetch(100):
events = service.events_for_days(start_date, end_date)
services.append((service, events))
p = Status.all()
p.order("severity")
past = get_past_days(5, end_date)
td = default_template_data()
td["start_date"] = start_date
td["end_date"] = end_date
td["services"] = services
td["statuses"] = p.fetch(100)
td["past"] = past
td["default"] = Status.default()
self.render(td, 'basic','index.html')