当前位置: 首页>>代码示例>>Python>>正文


Python Employee.all方法代码示例

本文整理汇总了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)
开发者ID:hartleybrody,项目名称:random-lunch,代码行数:31,代码来源:main.py

示例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()
开发者ID:gipsy86147,项目名称:SMSSchedulingGAE,代码行数:31,代码来源:main.py

示例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))  
开发者ID:gipsy86147,项目名称:SMSSchedulingGAE,代码行数:19,代码来源:main.py


注:本文中的models.Employee.all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。