Example #1
0
def create_school():
    jsonData = request.get_json()
    with db.auto_commit():
        school = School()
        school.school_name = jsonData['school_name']
        school.school_address = jsonData['school_address']
        db.session.add(school)
    return Success(msg='新增学校成功')
Example #2
0
 def csv_import(cls, reader):
     for row in csv.DictReader(reader):
         crypted_password = make_password(row['password'])
         
         school = School.key_for_sis_id(row['school_id'])
         student = cls.query(cls.sis_id == row['sis_id'], ancestor=school).get()
         if student is None:
             student = cls(
                 parent=school,
                 first_name=row['first_name'],
                 last_name=row['last_name'],
                 sis_id=row['sis_id'],
                 grade_level=int(row['grade_level']),
                 email=row['email'],
                 crypted_password=crypted_password
             )
             student.put()
             logging.info("inserted student: %s" % row)
         else:
             # cannot change student from one school to another?
             student.first_name = row['first_name']
             student.last_name = row['last_name']
             student.sis_id = row['sis_id']
             student.grade_level = int(row['grade_level'])
             student.email = row['email']
             student.crypted_password = crypted_password
             student.put()
             logging.info("updated student: %s" % row)
Example #3
0
    def csv_import(cls, reader):
        for row in csv.DictReader(reader):
            crypted_password = make_password(row['password'])

            school = School.key_for_sis_id(row['school_id'])
            student = cls.query(cls.sis_id == row['sis_id'],
                                ancestor=school).get()
            if student is None:
                student = cls(parent=school,
                              first_name=row['first_name'],
                              last_name=row['last_name'],
                              sis_id=row['sis_id'],
                              grade_level=int(row['grade_level']),
                              email=row['email'],
                              crypted_password=crypted_password)
                student.put()
                logging.info("inserted student: %s" % row)
            else:
                # cannot change student from one school to another?
                student.first_name = row['first_name']
                student.last_name = row['last_name']
                student.sis_id = row['sis_id']
                student.grade_level = int(row['grade_level'])
                student.email = row['email']
                student.crypted_password = crypted_password
                student.put()
                logging.info("updated student: %s" % row)
Example #4
0
 def csv_import(cls, reader):
     for row in csv.DictReader(reader):
         school = School.key_for_sis_id(row['school_id'])
         teacher = cls.query(cls.sis_id == row['sis_id'], ancestor=school).get()
         if teacher is None:
             teacher = cls(
                 parent=school,
                 first_name=row['first_name'],
                 last_name=row['last_name'],
                 sis_id=row['sis_id'],
                 location=row['location'],
                 email=row['email'],
                 is_admin=bool_from_string(row['admin'])
             )
             teacher.put()
             logging.info("inserted teacher: %s" % row)
         else:
             # cannot change teacher from one school to another?
             teacher.first_name = row['first_name']
             teacher.last_name = row['last_name']
             teacher.sis_id = row['sis_id']
             teacher.location = row['location']
             teacher.email = row['email']
             teacher.is_admin = bool(int(row['admin']))
             teacher.put()
             logging.info("updated teacher: %s" % row)
Example #5
0
 def csv_import(cls, reader):
     for row in csv.DictReader(reader):
         school = School.key_for_sis_id(row['school_id'])
         teacher = cls.query(cls.sis_id == row['sis_id'],
                             ancestor=school).get()
         if teacher is None:
             teacher = cls(parent=school,
                           first_name=row['first_name'],
                           last_name=row['last_name'],
                           sis_id=row['sis_id'],
                           location=row['location'],
                           email=row['email'],
                           is_admin=bool_from_string(row['admin']))
             teacher.put()
             logging.info("inserted teacher: %s" % row)
         else:
             # cannot change teacher from one school to another?
             teacher.first_name = row['first_name']
             teacher.last_name = row['last_name']
             teacher.sis_id = row['sis_id']
             teacher.location = row['location']
             teacher.email = row['email']
             teacher.is_admin = bool(int(row['admin']))
             teacher.put()
             logging.info("updated teacher: %s" % row)
Example #6
0
 def csv_import(cls, reader):
     for row in csv.DictReader(reader):
         school = School.key_for_sis_id(row['school_id'])
         student_id = row['student_id']
         if Student.query(Student.sis_id == student_id).count() == 0:
             logging.warn("no such student %s" % student_id)
             continue
         teacher_id = row['teacher_id']
         if Teacher.query(Teacher.sis_id == teacher_id).count() == 0:
             logging.warn("no such teacher %s" % teacher_id)
             continue
         enrollment = cls(
             parent=school,
             student_id=student_id,
             teacher_id=teacher_id,
             course_id=row['course_id'],
             section_id=row['section_id'],
             period=row['period'],
             is_homeroom=bool_from_string(row['homeroom']),
             is_active=True
         )
         enrollment.put()
         logging.info("inserted enrollment: %s" % row)