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


Python Setting.query方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import query [as 别名]
    def post(self):
        if bool(self.request.get('choice')):
            ndb.delete_multi(Student.query().fetch(keys_only=True))
            ndb.delete_multi(Assignment.query().fetch(keys_only=True))
            ndb.delete_multi(Setting.query().fetch(keys_only=True))

        self.redirect('/admin')
开发者ID:austinsherron,项目名称:partner_app,代码行数:9,代码来源:admin_misc.py

示例2: quarter

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import query [as 别名]
    def quarter():
        setting = Setting.query().get()

        if setting:
            return setting.quarter
开发者ID:austinsherron,项目名称:partner_app,代码行数:7,代码来源:settings.py

示例3: post

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import query [as 别名]
    def post(self):
        try:
            file = self.request.get('the_file')                               
            file = file.strip().split('\n')                                    

            quarter  = int(self.request.get('quarter'))                       
            year     = int(self.request.get('year'))
            num_labs = 0
            
            # students to be uploaded 
            students = []
            # to check for duplicates in roster
            student_cache = set()

            # grab students in DB (active and not active) 
            existing_students  = StudentModel.get_students_by_active_status(quarter, year).fetch()    
            existing_students += StudentModel.get_students_by_active_status(quarter, year, active=False).fetch()
            existing_students  = dict(map(lambda x: (int(x.studentid), x), existing_students))

            for row in file:
                row = row.split(',')

                # save highest lab number found
                if int(row[5]) > num_labs:
                    num_labs = int(row[5])

                # grab student ID from current row of CSV roster
                studentid = int(row[0].strip())

                # if student w/ same studentid has already been found in roster, skip...
                if studentid in student_cache:
                    continue

                # ...else, add them to 'seen' cache
                student_cache.add(studentid)

                # if student in DB, skip to next student...
                if studentid in existing_students:
                    existing_student = existing_students[studentid]

                    # ...unless they're inactive; if so, activate them...
                    if not existing_student.active:
                        existing_student.active = True
                        students.append(existing_student)

                    # ...or if they've switched labs; if so, update lab num...
                    if existing_student.lab != int(row[5]):
                        existing_student.lab = int(row[5])
                        students.append(existing_student)

                    # ...to see which students have dropped the class, remove active students from existing_students
                    del existing_students[studentid]
                    # ...and continue to next student
                    continue

                # create student object
                student = Student()

                student.studentid  = studentid
                student.last_name  = row[1].strip().title()
                student.last_name  = row[1].strip('"').title()
                student.first_name = row[2].strip().title()
                student.first_name = row[2].strip('"').title()
                student.ucinetid   = row[3].lower().strip()
                student.email      = row[4].lower().strip()
                student.lab        = int(row[5])
                student.quarter    = quarter
                student.year       = year
                student.active     = True
                students.append(student)

            # deactivate students who have dropped (students left in existing_students)
            for dropped in existing_students.values():
                dropped.active = False
                students.append(dropped)

            # save student objects...
            ndb.put_multi(students)
            # ...save num_labs...
            setting = Setting.query().get()
            setting = setting if setting else Setting()
            setting.num_labs = num_labs
            setting.put()
            # ...and render the response
            return self.redirect('/admin/roster/view?message=' + 'Successfully uploaded new roster')            

        except Exception, e:
            return self.redirect('/admin?message=' + 'There was a problem uploading the roster: ' + str(e))            
开发者ID:austinsherron,项目名称:partner_app,代码行数:90,代码来源:admin_roster.py

示例4: group_max

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import query [as 别名]
    def group_max():
        setting = Setting.query().get()

        if setting:
            return setting.group_max
开发者ID:austinsherron,项目名称:partner_app,代码行数:7,代码来源:settings.py

示例5: cross_section_partners

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import query [as 别名]
    def cross_section_partners():
        setting = Setting.query().get()

        if setting:
            return setting.cross_section_partners
开发者ID:austinsherron,项目名称:partner_app,代码行数:7,代码来源:settings.py

示例6: repeat_partners

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import query [as 别名]
    def repeat_partners():
        setting = Setting.query().get()

        if setting:
            return setting.repeat_partners
开发者ID:austinsherron,项目名称:partner_app,代码行数:7,代码来源:settings.py

示例7: num_labs

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import query [as 别名]
    def num_labs():
        setting = Setting.query().get()

        if setting:
            return setting.num_labs
开发者ID:austinsherron,项目名称:partner_app,代码行数:7,代码来源:settings.py

示例8: year

# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import query [as 别名]
    def year():
        setting = Setting.query().get()

        if setting:
            return setting.year
开发者ID:austinsherron,项目名称:partner_app,代码行数:7,代码来源:settings.py


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