本文整理汇总了Python中models.models.Student.update_apellidos方法的典型用法代码示例。如果您正苦于以下问题:Python Student.update_apellidos方法的具体用法?Python Student.update_apellidos怎么用?Python Student.update_apellidos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.models.Student
的用法示例。
在下文中一共展示了Student.update_apellidos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import update_apellidos [as 别名]
def post(self):
"""Handles POST requests."""
student = self.personalize_page_and_get_enrolled()
if not student:
return
if not self.assert_xsrf_token_or_fail(self.request,
'student-edit'):
return
if self.request.get('name'):
Student.rename_current(self.request.get('name'))
if self.request.get('apellidos'):
Student.update_apellidos(self.request.get('apellidos'))
if self.request.get('ciudad'):
Student.update_ciudad(self.request.get('ciudad'))
if self.request.get('pais'):
Student.update_pais(self.request.get('pais'))
"""
EL SIGUIENTE CÓDIGO CALCULA LA NOTA MEDIA EN LOS EXÁMENES
import datetime
ayer = datetime.datetime.now() - datetime.timedelta(days=1)
students = Student.all()
logging.info(students)
students = [s for s in Student.all()]
logging.info(students)
total_scores = {}
count_scores = {}
for s in students:
scores = json.loads(s.scores) if s.scores else {} #puntuaciones de un usuario
for asm_id, asm_score in scores.iteritems(): #para cada examen que ha realizado
total_scores[asm_id] = total_scores.get(asm_id, 0) + asm_score
count_scores[asm_id] = count_scores.get(asm_id, 0) + 1
logging.info(total_scores)
logging.info(count_scores)
for asm_id, total_score in total_scores.iteritems():
total_scores[asm_id] = total_score / count_scores[asm_id] #calcula la nota media en un examen
logging.info(total_scores)
"""
self.redirect('/student/home')