Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
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)