diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4d8f606 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "python.testing.unittestArgs": [ + "-v", + "-s", + "./project", + "-p", + "*test.py" + ], + "python.testing.pytestEnabled": false, + "python.testing.unittestEnabled": true +} \ No newline at end of file diff --git a/project/ada_uml/ada.py b/project/ada_uml/ada.py new file mode 100644 index 0000000..8574488 --- /dev/null +++ b/project/ada_uml/ada.py @@ -0,0 +1,81 @@ +import psycopg2 + +class data_base: + def __init__(self): + self.db_params = { + "dbname": "postgres", + "user": "myuser", + "password": "qwerty", + "host": "localhost" + } + + def connect(self): + return psycopg2.connect(**self.db_params) + + def close(self, conn, cur): + if cur: + cur.close() + if conn: + conn.close() + +class Employee: + def __init__(self, name, age, salary): + self.name = name + self.age = age + self.salary = salary + + def display_info(self): + print(f"Name: {self.name}, Age: {self.age}, Salary: {self.salary}") + + def add2db(self): + conn = None + cur = None + try: + conn = self.db.connect() + cur = conn.cursor() + cur.execute("INSERT INTO patient_db (pat_id, pat_fio, pat_born, medcard_id) VALUES (%s, %s, %s, %s)",\ + (self.pat_id, self.pat_fio, self.pat_born, self.medcardc_id)) + conn.commit() + finally: + self.db.close(conn, cur) + +class Developer(Employee): + def __init__(self, name, age, salary, programming_languages): + super().__init__(name, age, salary) + self.programming_languages = programming_languages + + def display_tech_stack(self): + print(f"{self.name}'s tech stack: {', '.join(self.programming_languages)}") + +class Department: + def __init__(self, name, code, manager): + self.name = name + self.code = code + self.manager = manager + + def get_manager_info(self): + return f"The manager of the department {self.name} is {self.manager}" + +class Project: + def __init__(self, name): + self.name = name + + def assign_team(self, team): + print(f"The team for project {self.name} has been assigned: {', '.join(team)}") + +class ProgrammingLanguage: + def __init__(self, name, type): + self.name = name + self.type = type + + def display_info(self): + print(f"Programming language: {self.name}, Type: {self.type}") + +class Technology: + def __init__(self, name, description): + self.name = name + self.description = description + + def display_tech_info(self): + print(f"Technology: {self.name}, Description: {self.description}") + diff --git a/project/uml/done_ada.vsdx b/project/ada_uml/done_ada.vsdx similarity index 100% rename from project/uml/done_ada.vsdx rename to project/ada_uml/done_ada.vsdx diff --git a/project/uml/done_uea.vsdx b/project/uml_uea/done_uea.vsdx similarity index 100% rename from project/uml/done_uea.vsdx rename to project/uml_uea/done_uea.vsdx diff --git a/project/classes.py b/project/uml_uea/uea.py similarity index 83% rename from project/classes.py rename to project/uml_uea/uea.py index 789c87f..1cb105d 100644 --- a/project/classes.py +++ b/project/uml_uea/uea.py @@ -70,14 +70,13 @@ class doctor: finally: self.db.close(conn, cur) - def workload_check(self, timetable): + def workload_check(self, time_of_appoint): #как сделать? conn = None cur = None try: conn = self.db.connect() cur = conn.cursor() - if (timetable.loanAmount <= 50000): - # что вместо апдейта? + if (self.time_of_appoint == time_of_appoint): cur.execute("UPDATE loan_applications SET status = %s WHERE application_id = %s", ('approved', timetable.applicationID)) else: cur.execute("UPDATE loan_applications SET status = %s WHERE application_id = %s", ('rejected', timetable.applicationID)) @@ -97,18 +96,19 @@ class DocAppointment: self.appointment_id = appointment_id self.patient = patient self.status = status + self.time_of_appoint self.db = db - def addToDatabase(self): - conn = None - cur = None - try: - conn = self.database.connect() - cur = conn.cursor() - cur.execute("INSERT INTO loan_applications (client_id, loan_amount, status) VALUES (%s, %s, %s)", (self.client.clientID, self.loanAmount, self.status)) - conn.commit() - finally: - self.database.close(conn, cur) + # def addToDatabase(self): + # conn = None + # cur = None + # try: + # conn = self.database.connect() + # cur = conn.cursor() + # cur.execute("INSERT INTO appointment (client_id, loan_amount, status) VALUES (%s, %s, %s)", (self.client.clientID, self.loanAmount, self.status)) + # conn.commit() + # finally: + # self.database.close(conn, cur) def del_appoint(self): conn = None @@ -127,7 +127,8 @@ class DocAppointment: try: conn = self.database.connect() cur = conn.cursor() - cur.execute("INSERT INTO appointment (appointment_id, patient, status) VALUES (%s, %s, %s)", self.appointment_id, self.patient, self.status) + cur.execute("INSERT INTO appointment (appointment_id, patient, status, time_of_appoint) VALUES (%s, %s, %s, %s)",\ + self.appointment_id, self.patient, self.status, self.time_of_appoint) conn.commit() finally: self.database.close(conn, cur) \ No newline at end of file