本文整理汇总了Python中utils.db.db函数的典型用法代码示例。如果您正苦于以下问题:Python db函数的具体用法?Python db怎么用?Python db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: saveattendance
def saveattendance():
clsn = request.form["classname"].strip()
term = request.form['term'].strip()
nameParts = clsn.split("-")
if request.form['absent'] != '':
abss = request.form['absent'].strip().split('_')
else:
abss = []
if request.form['late'] != '':
lats = request.form['late'].strip().split('_')
else:
lats = []
if request.form['excused'] != '':
excs = request.form['excused'].strip().split('_')
else:
excs = []
if request.form['exlates'] != '':
exlates = request.form['exlates'].strip().split('_')
else:
exlates = []
date = request.form['date'].strip()
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
mydb.setMassAttendance( (nameParts[0], nameParts[1], nameParts[2] ),
term, abss, lats, excs, exlates, date )
return "done"
示例2: getassignments
def getassignments():
clsn = request.form["classname"].strip()
term = request.form['term'].strip()
nameParts = clsn.split("-")
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
assignments = mydb.getAssignments((nameParts[0],nameParts[1],nameParts[2]), term)
return json.dumps( assignments )
示例3: getinfo
def getinfo():
clsn = request.form["classname"].strip()
term = request.form['term'].strip()
nameParts = clsn.split("-")
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
student = mydb.getStudent((nameParts[0], nameParts[1], nameParts[2] ), term, request.form['sid'])
return json.dumps(student['students'])
示例4: changegrade
def changegrade():
clsn = request.form["classname"].strip()
term = request.form['term'].strip()
nameParts = clsn.split("-")
grades = json.loads(request.form['grades'].strip())
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
student = mydb.changeGrade((nameParts[0], nameParts[1], nameParts[2] ), term, request.form['sid'].strip(), request.form['atype'].strip(), grades)
return json.dumps(student['students'])
示例5: removestudent
def removestudent():
clsn = request.form["classname"].strip()
term = request.form['term'].strip()
nameParts = clsn.split("-")
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
mydb.removeStudent((nameParts[0], nameParts[1], nameParts[2]),term,
request.form['sid'].strip())
return "done"
示例6: getbackupcsv
def getbackupcsv():
clsn = request.args.get('classname')
term = request.args.get('term')
nameParts = clsn.split("-")
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
backup = mydb.getBackupCSV((nameParts[0], nameParts[1], nameParts[2]), term)
response = make_response( backup )
response.headers['Content-Disposition'] = 'attachment; filename=' + clsn + '-' + term + '-' + str(datetime.date.today()) + '.csv'
return response
示例7: seated
def seated():
clsn = request.form["classname"].strip()
term = request.form['term'].strip()
nameParts = clsn.split("-")
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
mydb.setSeated( (nameParts[0], nameParts[1], nameParts[2]), term,
request.form["seated"].strip(),
request.form['rows'].strip(), request.form['cols'].strip())
return "seated set"
示例8: createassignmenttypr
def createassignmenttypr():
clsn = request.form["classname"].strip()
term = request.form['term'].strip()
nameParts = clsn.split("-")
atname = request.form['atname'].strip()
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
mydb.addAssignmentType((nameParts[0], nameParts[1], nameParts[2]),term,
atname)
return 'done'
示例9: getallbackupcsv
def getallbackupcsv():
teacher = session['teacher']
term = request.args.get('term')
mydb = db.db();
classes = mydb.getClasses(teacher, term)
backup = ''
for c in classes:
backup+= mydb.getBackupCSV(c, term) + '\n\n'
response = make_response( backup )
response.headers['Content-Disposition'] = 'attachment; filename=' + teacher + '-' + term + '-' + str(datetime.date.today()) + '.csv'
return response
示例10: backupreset
def backupreset():
backup = request.files['backupfile']
backup = backup.read()
backup = json.loads(backup)
clsn = backup['code'] + "-" + backup['section'] + '-' + backup['period']
nameParts = clsn.split("-")
term = backup['term']
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
mydb.resetFromBackup(backup)
return render_template("classview.html", clsname = clsn,trm = term )
示例11: savegradeoptions
def savegradeoptions():
clsn = request.form["classname"].strip()
term = request.form['term'].strip()
nameParts = clsn.split("-")
option = request.form['option'].strip()
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
mydb.saveGradeOptions((nameParts[0], nameParts[1], nameParts[2]),term, option)
return "done";
示例12: changeweights
def changeweights():
clsn = request.form["classname"].strip()
term = request.form['term'].strip()
nameParts = clsn.split("-")
weights = json.loads(request.form['weights'].strip())
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
mydb.changeWeights((nameParts[0], nameParts[1], nameParts[2]),term,
weights)
return "done"
示例13: getassignment
def getassignment():
clsn = request.form["classname"].strip()
term = request.form['term'].strip()
nameParts = clsn.split("-")
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
try:
assignment = mydb.getAssignment((nameParts[0],nameParts[1],nameParts[2]), term,
request.form['aname'].strip())
return json.dumps( assignment )
except:
return '{"grades":[]}'
示例14: deletegrades
def deletegrades():
clsn = request.form["classname"].strip()
term = request.form['term'].strip()
nameParts = clsn.split("-")
ids = json.loads(request.form['ids'])
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
print ids
mydb.deleteAssignment( (nameParts[0], nameParts[1], nameParts[2] ),
term, ids,
request.form['aname'].strip(), request.form['atype'].strip());
return "done"
示例15: gettoday
def gettoday():
clsn = request.form["classname"].strip()
term = request.form['term'].strip()
nameParts = clsn.split("-")
mydb = db.db()
if session['teacher'] != mydb.getTeacher( (nameParts[0], nameParts[1], nameParts[2] ), term ):
return 'false'
a = mydb.getTodaysAttendance((nameParts[0], nameParts[1], nameParts[2]), term, request.form['date'].strip(), 'absent')
l = mydb.getTodaysAttendance((nameParts[0], nameParts[1], nameParts[2]), term, request.form['date'].strip(), 'late')
e = mydb.getTodaysAttendance((nameParts[0], nameParts[1], nameParts[2]), term, request.form['date'].strip(), 'excused')
el = mydb.getTodaysAttendance((nameParts[0], nameParts[1], nameParts[2]), term, request.form['date'].strip(), 'exlate')
d = {'absent':a, 'late':l, 'excused':e, 'exlate':el}
return json.dumps(d)