コード例 #1
0
    def delete_success(self):
        oid = subjectBLL.insert("Asignatura Muy Nueva", "AMN", 6, 3,
                                "Obligatoria", 1)
        subject = subjectBLL.get_by_name("Asignatura Muy Nueva")

        if subject is None:
            raise BLLException("The subject was not created")

        subjectBLL.delete(oid)

        subject = subjectBLL.get_by_name("Asignatura Muy Nueva")
        if subject is not None:
            raise BLLException("The subject hasn't been deleted")
コード例 #2
0
    def update_success(self):
        subject_list = subjectBLL.get_all()
        old_subject = subject_list[0]
        oid = old_subject["subjectId"]

        subjectBLL.update(oid, "Asignatura Muy Nueva", "AMN", 12, 1,
                          "Obligatoria", 1)

        subject = subjectBLL.get_by_name(old_subject["name"])
        if subject is not None:
            raise BLLException(
                "The subject has the same name as before the change")

        subject = subjectBLL.get_by_name("Asignatura Muy Nueva")
        if subject is None:
            raise BLLException("The subject has not got the new name")
コード例 #3
0
 def check_RN005_date_hour_correct(self, dateAppointment, hourAppointment,
                                   tutorialId):
     dayWeek = calendar.day_name[dateAppointment.weekday()]
     tutorial = tutorial_bll.get_by_OID(tutorialId)
     if dayWeek != tutorial["dayWeek"] or hourAppointment < tutorial[
             "startTime"] or hourAppointment >= tutorial["endTime"]:
         raise BLLException("Appointment no valid.")
コード例 #4
0
ファイル: TeacherBLL.py プロジェクト: marsamber/proyectoIISSI
 def check_category(self, cat):
     lista = [
         "Catedrático", "Titular de Universidad",
         "Profesor Contratado Doctor", "Profesor Ayudante Doctor"
     ]
     if cat not in lista:
         raise BLLException(
             f"Cannot add or update teacher with category = {cat}")
コード例 #5
0
ファイル: TeacherBLL.py プロジェクト: marsamber/proyectoIISSI
    def delete(self, oid):
        self.check_teacherId_exists(oid)

        try:
            deleted_id = super().delete(oid)
        except DALException as exc:
            raise BLLException(exc) from exc

        return deleted_id
コード例 #6
0
    def delete(self, oid):
        # Check that the OID exists
        self.check_oid_exists(oid)

        try:
            res = super().delete(oid)
        except DALException as exc:
            raise BLLException(exc) from exc

        return res
コード例 #7
0
    def check_RN008_selectividad(self, accessMethod, birthDateSt):
        if accessMethod != "Selectividad":
            return

        date_now = datetime.now()
        date_birth_student = datetime.strptime(birthDateSt, "%Y-%m-%d")
        diff = date_now - date_birth_student

        if diff.days // 365 < 16:
            raise BLLException("The student is younger than 16 years old")
コード例 #8
0
    def insert(self, dayWeek, startTime, endTime, teacherId):
        self.check_attributes_not_empty(dayWeek, startTime, endTime)
        self.check_weekday(dayWeek)
        self.check_RN018_PAD(teacherId, startTime, endTime)

        try:
            tutorialId = super().insert(dayWeek, startTime, endTime, teacherId)
        except DALException as exc:
            raise BLLException(exc) from exc

        return tutorialId
コード例 #9
0
 def check_RN018_PAD(self, teacherId, startTime, endTime):
     teacher = teacher_bll.get_by_OID(teacherId)
     if teacher["category"] == "Profesor Ayudante Doctor":
         start = datetime.strptime(startTime, "%H:%M:%S")
         end = datetime.strptime(endTime, "%H:%M:%S")
         total = end - start
         if total.seconds // 3600 > 2:
             raise BLLException(
                 "A PAD teacher cannot give more than 2 hours of tutorials a week."
             )
         tutorials_by_teacher = self.get_by_teacherId(teacherId)
         if tutorials_by_teacher is not None:
             for t in tutorials_by_teacher:
                 start = t["startTime"]
                 end = t["endTime"]
                 diff = end - start
                 total = total + diff
             if total.seconds // 3600 > 2:
                 raise BLLException(
                     "A PAD teacher cannot give more than 2 hours of tutorials a week."
                 )
コード例 #10
0
    def insert(self, dateAppointment, hourAppointment, tutorialId, studentId):
        self.check_attributes_not_empty(dateAppointment, hourAppointment,
                                        tutorialId, studentId)
        self.check_RN005_date_hour_correct(dateAppointment, hourAppointment,
                                           tutorialId)

        try:
            appointmentId = super().insert(dateAppointment, hourAppointment,
                                           tutorialId, studentId)
        except DALException as exc:
            raise BLLException(exc) from exc

        return appointmentId
コード例 #11
0
    def insert(self, name, acronym, n_credits, course, subject_type, degreeId):
        # Check that the name and acronym are not empty
        check_not_null(name, "The subject's name cannot be empty")
        check_not_null(acronym, "The subject's acronym cannot be empty")
        check_not_null(n_credits, "The subject's credits cannot be empty")

        # Insert the new subject
        try:
            oid = super().insert(name, acronym, n_credits, course,
                                 subject_type, degreeId)
        except DALException as exc:
            raise BLLException(exc) from exc

        return oid
コード例 #12
0
ファイル: TeacherBLL.py プロジェクト: marsamber/proyectoIISSI
    def insert(self, dni, firstName, surname, birthDate, email, category):
        self.check_attributes_not_empty(dni, firstName, surname, birthDate,
                                        email, category)
        self.check_category(category)
        self.check_dni_unique(dni)
        self.check_email_unique(email)
        self.check_RN017_email(email)

        try:
            teacherId = super().insert(dni, firstName, surname, birthDate,
                                       email, category)
        except DALException as exc:
            raise BLLException(exc) from exc

        return teacherId
コード例 #13
0
    def update(self, oid, name, acronym, n_credits, course, subject_type,
               degreeId):
        # Check that the name and acronym are not empty, and that the OID exists
        self.check_oid_exists(oid)
        check_not_null(name, "The subject's name cannot be empty")
        check_not_null(acronym, "The subject's acronym cannot be empty")
        check_not_null(n_credits, "The subject's credits cannot be empty")

        try:
            new_oid = super().update(oid, name, acronym, n_credits, course,
                                     subject_type, degreeId)
        except DALException as exc:
            raise BLLException(exc) from exc

        return new_oid
コード例 #14
0
    def insert(self, accessMethod, dniSt, firstNameSt, surnameSt, birthDateSt,
               emailSt):
        self.check_attributes_not_empty(accessMethod, dniSt, firstNameSt,
                                        surnameSt, birthDateSt, emailSt)
        self.check_accessMethod(accessMethod)
        self.check_dni_unique(dniSt)
        self.check_email_unique(emailSt)
        self.check_RN017_email(emailSt)
        self.check_RN008_selectividad(accessMethod, birthDateSt)

        try:
            studentId = super().insert(accessMethod, dniSt, firstNameSt,
                                       surnameSt, birthDateSt, emailSt)
        except DALException as exc:
            raise BLLException(exc) from exc

        return studentId
コード例 #15
0
 def check_weekday(self, day):
     lista = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
     if day not in lista:
         raise BLLException(f"Cannot add or update tutorial on {day}")
コード例 #16
0
ファイル: TeacherBLL.py プロジェクト: marsamber/proyectoIISSI
 def check_teacherId_exists(self, oid):
     teacher = self.get_by_OID(oid)
     if teacher is None:
         raise BLLException(f"There exists no teacher with ID {oid}")
コード例 #17
0
 def check_email_unique(self, email):
     for student in self.get_all():
         if email == student["emailSt"]:
             raise BLLException("Two people cannot have the same email")
コード例 #18
0
ファイル: TeacherBLL.py プロジェクト: marsamber/proyectoIISSI
 def check_email_unique(self, email):
     for teacher in self.get_all():
         if email == teacher["email"]:
             raise BLLException("Two people cannot have the same email")
コード例 #19
0
 def check_studentId_exists(self, oid):
     student = self.get_by_OID(oid)
     if student is None:
         raise BLLException(f"There exists no user with ID {oid}")
コード例 #20
0
 def check_tutorialId_exists(self, oid):
     tutorial = self.get_by_OID(oid)
     if tutorial is None:
         raise BLLException(f"There exists no tutorial with ID {oid}")
コード例 #21
0
 def check_appointmentId_exists(self, oid):
     appointment = self.get_by_OID(oid)
     if appointment is None:
         raise BLLException(f"There exists no appointment with ID {oid}")
コード例 #22
0
ファイル: TeacherBLL.py プロジェクト: marsamber/proyectoIISSI
 def check_dni_unique(self, dni):
     for teacher in self.get_all():
         if dni == teacher["dni"]:
             raise BLLException("Two people cannot have the same DNI")
コード例 #23
0
 def check_accessMethod(self, access):
     lista = ["Selectividad", "Ciclo", "Mayor", "Titulado Extranjero"]
     if access not in lista:
         raise BLLException(
             f"Cannot add or update student with accessMethod = {access}")
コード例 #24
0
ファイル: TeacherBLL.py プロジェクト: marsamber/proyectoIISSI
 def check_RN017_email(self, email):
     is_valid = validate_email(email)
     if not is_valid:
         raise BLLException(f"The email {email} is not valid.")
コード例 #25
0
 def check_dni_unique(self, dni):
     for student in self.get_all():
         if dni == student["dniSt"]:
             raise BLLException("Two people cannot have the same DNI")
コード例 #26
0
def check_not_null(value, msg):
    if value is None or (isinstance(value, str) and value.strip() == ""):
        raise BLLException(msg)
コード例 #27
0
 def check_oid_exists(self, oid):
     # Check that there exists a subject with the provided OID
     subj = super().get_by_oid(oid)
     if subj is None:
         raise BLLException("Cannot find a subject with oid " + str(oid))