本文整理汇总了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')
示例2: quarter
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import query [as 别名]
def quarter():
setting = Setting.query().get()
if setting:
return setting.quarter
示例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))
示例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
示例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
示例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
示例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
示例8: year
# 需要导入模块: from models import Setting [as 别名]
# 或者: from models.Setting import query [as 别名]
def year():
setting = Setting.query().get()
if setting:
return setting.year