Beispiel #1
0
 def make(cls, dct: Dict) -> "CardItem":
     dct["teachers"] = [
         TeacherItem.make(x) for x in dct.pop("teacher_list")
     ]
     dct['room_id'] = dct.pop('room_code')
     dct['card_id'] = dct.pop('card_code')
     dct['weeks'] = dct.pop('week_list')
     dct['week_string'] = weeks_to_string(dct['weeks'])
     dct['room_id_encoded'] = encrypt('room', dct['room_id'])
     dct['card_id_encoded'] = encrypt('klass', dct['card_id'])
     dct['course_id'] = dct.pop('course_code')
     return cls(**ensure_slots(cls, dct))
Beispiel #2
0
 def make(cls, dct: Dict) -> "SearchResultStudentItem":
     dct['semesters'] = sorted(dct.pop("semester_list"))
     dct['student_id'] = dct.pop("student_code")  # rename
     dct['student_id_encoded'] = encrypt('student', dct['student_id'])
     dct['klass'] = dct.pop("class")
     del dct["type"]
     return cls(**ensure_slots(cls, dct))
Beispiel #3
0
 def make(cls, dct: Dict) -> "TeacherTimetableResult":
     del dct["status"]
     dct["cards"] = [CardItem.make(x) for x in dct.pop("card_list")]
     dct['semesters'] = sorted(dct.pop('semester_list'))
     dct['teacher_id'] = dct.pop('teacher_code')
     dct["teacher_id_encoded"] = encrypt("teacher", dct["teacher_id"])
     return cls(**ensure_slots(cls, dct))
Beispiel #4
0
 def make(cls, dct: Dict) -> "StudentResult":
     del dct["status"]
     dct["student_id"] = dct.pop("student_code")
     dct["student_id_encoded"] = encrypt("student", dct["student_id"])
     dct["klass"] = dct.pop("class")
     dct["semesters"] = dct.pop('semester_list')
     return cls(**ensure_slots(cls, dct))
Beispiel #5
0
 def make(cls, dct: Dict) -> "CardResult":
     del dct["status"]
     dct["teachers"] = [
         CardResultTeacherItem.make(x) for x in dct.pop("teacher_list")
     ]
     dct["students"] = [
         CardResultStudentItem.make(x) for x in dct.pop("student_list")
     ]
     dct['card_id'] = dct.pop('card_code')
     dct["card_id_encoded"] = encrypt("klass", dct["card_id"])
     dct['room_id'] = dct.pop('room_code')
     dct['room_id_encoded'] = encrypt("room", dct["room_id"])
     dct['weeks'] = dct.pop("week_list")
     dct['week_string'] = weeks_to_string(dct['weeks'])
     dct['course_id'] = dct.pop('course_code')
     dct['union_name'] = dct.pop('tea_class')
     return cls(**ensure_slots(cls, dct))
Beispiel #6
0
 def make(cls, dct: Dict) -> "StudentTimetableResult":
     del dct["status"]
     dct["cards"] = [CardItem.make(x) for x in dct.pop("card_list")]
     dct["semesters"] = dct.pop("semester_list")
     dct["student_id"] = dct.pop("student_code")
     dct["student_id_encoded"] = encrypt("student", dct["student_id"])
     dct["klass"] = dct.pop("class")
     return cls(**ensure_slots(cls, dct))
Beispiel #7
0
    def make(cls, dct: Dict) -> "ClassroomTimetableResult":
        del dct["status"]
        dct['semesters'] = sorted(dct.pop('semester_list'))
        dct['room_id'] = dct.pop("room_code")
        dct['cards'] = [CardItem.make(x) for x in dct.pop('card_list')]

        dct['room_id_encoded'] = encrypt('room', dct['room_id'])
        return cls(**ensure_slots(cls, dct))
Beispiel #8
0
 def test_encrypt(self):
     from everyclass.server.utils.resource_identifier_encrypt import encrypt
     for tp, data, encrypted in self.cases:
         result = encrypt(tp, data, encryption_key=self.key)
         print("Encrypt result:", result)
         self.assertTrue(result == encrypted)
Beispiel #9
0
 def make(cls, dct: Dict) -> "SearchResultClassroomItem":
     dct['semesters'] = sorted(dct.pop("semester_list"))
     dct['room_id'] = dct.pop("room_code")  # rename
     dct['room_id_encoded'] = encrypt('room', dct['room_id'])
     del dct["type"]
     return cls(**ensure_slots(cls, dct))
Beispiel #10
0
 def make(cls, dct: Dict) -> "SearchResultTeacherItem":
     dct['semesters'] = sorted(dct.pop("semester_list"))
     dct['teacher_id'] = dct.pop("teacher_code")  # rename
     dct['teacher_id_encoded'] = encrypt('teacher', dct['teacher_id'])
     del dct["type"]
     return cls(**ensure_slots(cls, dct))
Beispiel #11
0
 def make(cls, dct: Dict) -> "CardResultStudentItem":
     dct["klass"] = dct.pop("class")
     dct["student_id"] = dct.pop("student_code")
     dct["student_id_encoded"] = encrypt("student", dct.get("student_id"))
     return cls(**ensure_slots(cls, dct))
Beispiel #12
0
 def make(cls, dct: Dict) -> "CardResultTeacherItem":
     dct['teacher_id'] = dct.pop('teacher_code')
     dct['teacher_id_encoded'] = encrypt('teacher', dct['teacher_id'])
     return cls(**ensure_slots(cls, dct))