def csv_import(cls, reader): for row in csv.DictReader(reader): teacher_id = row['teacher_id'] student_id = row['student_id'] start_time = make_local_dt(row['date'], row['start_time']) teacher = Teacher.key_for_sis_id(teacher_id) if teacher is None: logging.warn("no such teacher %s" % teacher_id) continue if student_id and Student.query(Student.sis_id == student_id).count == 0: logging.warn("no such student %s" % student_id) continue appointment = cls.query(cls.start_time == start_time, ancestor=teacher).get() if appointment is None: appointment = cls( parent=teacher, student_id=student_id, start_time=start_time, duration=int(row['duration']), location=row['location'], teacher_name=row['teacher_name'], is_active=bool_from_string(row['active']) ) appointment.put() logging.info("inserted appointment: %s" % row) else: appointment.student_id = student_id appointment.start_time = start_time appointment.duration = int(row['duration']) appointment.location = row['location'] appointment.teacher_name = row['teacher_name'] appointment.is_active = bool_from_string(row['active']) appointment.put() logging.info("updated appointment: %s" % row)
def csv_import(cls, reader): for row in csv.DictReader(reader): teacher_id = row['teacher_id'] student_id = row['student_id'] start_time = make_local_dt(row['date'], row['start_time']) teacher = Teacher.key_for_sis_id(teacher_id) if teacher is None: logging.warn("no such teacher %s" % teacher_id) continue if student_id and Student.query( Student.sis_id == student_id).count == 0: logging.warn("no such student %s" % student_id) continue appointment = cls.query(cls.start_time == start_time, ancestor=teacher).get() if appointment is None: appointment = cls(parent=teacher, student_id=student_id, start_time=start_time, duration=int(row['duration']), location=row['location'], teacher_name=row['teacher_name'], is_active=bool_from_string(row['active'])) appointment.put() logging.info("inserted appointment: %s" % row) else: appointment.student_id = student_id appointment.start_time = start_time appointment.duration = int(row['duration']) appointment.location = row['location'] appointment.teacher_name = row['teacher_name'] appointment.is_active = bool_from_string(row['active']) appointment.put() logging.info("updated appointment: %s" % row)
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)
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)
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)