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


Python Employee.query方法代码示例

本文整理汇总了Python中models.Employee.query方法的典型用法代码示例。如果您正苦于以下问题:Python Employee.query方法的具体用法?Python Employee.query怎么用?Python Employee.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Employee的用法示例。


在下文中一共展示了Employee.query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import query [as 别名]
    def post(self):
        if (self.request.get('username')):
            user = self.request.get('username')
        else:
            user = self.session['username']
        employee_query = Employee.query(Employee.login_name == user)
        employee = employee_query.fetch()[0]

        timesheet_query = Timesheet.query(Timesheet.time_period == self.request.get('time_period'), Timesheet.worked_by == employee.key)
        timesheet = timesheet_query.fetch()

        currentPositions = []
        for sheet in timesheet:
            currentPositions.append(sheet.position)

        for position in employee.positions:
            if position not in currentPositions:
                new_timesheet = Timesheet(worked_by=employee.key, position=position, time_period=self.request.get('time_period'))
                new_timesheet.put()
                timesheet.append(new_timesheet)

        jsonSheet = {'sheets': []}
        for t in timesheet:
            obj = {
                'worked_by': Employee.query(Employee.key == t.worked_by).fetch()[0].login_name,
                'position': Position.query(Position.key == t.position).fetch()[0].title,
                'hours_worked': t.hours_worked,
                'time_period': t.time_period,
                'is_submitted': t.is_submitted,
                'is_approved': t.is_approved
            }
            jsonSheet['sheets'].append(obj)

        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(json.dumps(jsonSheet))
开发者ID:kulczajr,项目名称:custom-timesheet,代码行数:37,代码来源:main.py

示例2: get

# 需要导入模块: from models import Employee [as 别名]
# 或者: from models.Employee import query [as 别名]
    def get(self):
        employee_query = Employee.query(Employee.login_name != self.session.get('username'))
        employee_list = employee_query.fetch()

        position_query = Position.query()
        position_list = position_query.fetch()

        admin_values = {
            'username': self.session.get('username'),
            'first_name': self.session.get('first_name'),
            'last_name': self.session.get('last_name'),
            'is_admin': self.session.get('is_admin'),
            'positions': self.session.get('positions'),
            'employee_list': employee_list,
            'position_list': position_list
        }
        template = jinja_env.get_template("templates/admin_edit.html")
        self.response.write(template.render(admin_values))
开发者ID:kulczajr,项目名称:custom-timesheet,代码行数:20,代码来源:main.py


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