def __init__(self): super().__init__() self.cohort = self._create_model_object() self.save(self.cohort) self.teacher = UserRule().user self.save(self.teacher) teacher_role = TeacherCohortMap(self.teacher, self.cohort) self.save(teacher_role) self.student1 = UserRule().user self.student1.cohort = self.cohort self.save(self.student1) student2 = UserRule().user student2.cohort = self.cohort self.save(student2)
def get_cohorts(self): return TeacherCohortMap.get_cohorts_for(self.user)
def get_teachers(self): from zeeguu.model.teacher_cohort_map import TeacherCohortMap return TeacherCohortMap.get_teachers_for(self)
def from_user(cls, user): cohort_count_of_user = len(TeacherCohortMap.get_cohorts_for(user)) if cohort_count_of_user > 0: return cls(user) else: return None