本文整理汇总了Python中models.Employee.all方法的典型用法代码示例。如果您正苦于以下问题:Python Employee.all方法的具体用法?Python Employee.all怎么用?Python Employee.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Employee
的用法示例。
在下文中一共展示了Employee.all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import all [as 别名]
def get(self):
key = self.request.get("key", False)
if not key or key != "hartley-rulez":
self.error(401)
return self.response.out.write("What's the magic password??")
# commence shufflin' http://youtu.be/KQ6zr6kCPj8
all_employees = [e for e in Employee.all()] # lists are easier to work w than Query objects
already_matched_employees = []
created_lunches = []
for employee in all_employees:
if employee not in already_matched_employees:
already_matched_employees.append(employee)
employees_left = [e for e in all_employees if e not in already_matched_employees]
partner = choose_partner(employees_left, employee)
if partner:
logging.info("creating lunch between %s and %s" % (employee, partner))
already_matched_employees.append(partner)
l = Lunch(employees=[employee.key(), partner.key()])
l.put()
created_lunches.append(l)
else:
logging.info("couldn't find lunch mate for %s" % employee)
already_matched_employees.remove(employee)
logging.info("created lunches:")
logging.info(created_lunches)
示例2: post
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import all [as 别名]
def post(self):
q_id = int(self.request.get('q_id'))
q = QueueEntry.get_by_id(q_id)
twilio_settings = TwilioSettings.all().get()
schedule = SMSSchedule.all().get()
tclient = TwilioRestClient(twilio_settings.account_sid, twilio_settings.auth_token)
if q and q.status == 'P':
employees = Employee.all()
for employee in employees:
entry = ReportingEntry.all().filter('reporting_date = ', q.report_date).filter('mobile_number =', employee.mobile_number).get()
if not entry:
entry = ReportingEntry(name = employee.name,
mobile_number = employee.mobile_number,
email = employee.email,
reporting_date = q.report_date,
reporting_location = "NOT REPORTED",
reporting_time = None,
employee = employee)
entry.put()
if schedule.status=='Active':
tclient.sms.messages.create(to = employee.mobile_number, from_ = twilio_settings.twilio_number, body = schedule.message[:160])
smslog = SMSLog(message = schedule.message[:160],
from_number = twilio_settings.twilio_number,
to_number = employee.mobile_number,
direction = 'outgoing-scheduled',
employee_name = employee.name)
smslog.put()
q.status = 'S'
q.save()
示例3: get
# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import all [as 别名]
def get(self):
try:
page = int(self.request.get('page',0))
next_page = page + 1
employees = Employee.all().order('-created').fetch(PAGE_SIZE, page*PAGE_SIZE)
next_count = Employee.all().order('-created').fetch(PAGE_SIZE, next_page*PAGE_SIZE)
has_next = len(next_count) > 0
has_previous = page > 0
emp_array = []
for employee in employees:
emp_array.append(employee.to_dict())
result_dict = {'success':True, 'employees':emp_array,'has_next':has_next,'has_previous':has_previous,'next_count':len(next_count)}
except:
result_dict = {'success':False}
self.response.headers['Content-Type'] = 'application/json'
self.response.out.write(json.dumps(result_dict))