def save(self): course = Course.lookup_id(self.course_id) user = Course.lookup_id(self.user_id) course.users.append(user) user.courses.append(course) Base.save(self)
def save(self, warned): credentials = User.lookup_id(self.user_id) prerequisites = Course.lookup_id(self.course_id).prerequisites conflict = None if not warned: for prerequisite in prerequisites: matched = [ c for c in credentials if c.id == prerequisite.credential_id ] if matched.length == 0: conflict = prerequisite.id break if conflict: return "Missing prerequisite: " + Credential.lookup_id( conflict).name else: Base.save(self)