From dd492c903bb1ffcdaa8c7be356815fd4ba23fc74 Mon Sep 17 00:00:00 2001 From: ranasalim1 Date: Wed, 12 Nov 2025 21:51:57 -0400 Subject: [PATCH 1/4] Update readme.md Test Commit & Push --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index a39f0d0..7b33c41 100644 --- a/readme.md +++ b/readme.md @@ -61,3 +61,5 @@ Intended users: administrators, staff reviewers, and students at educational ins Run unit and integration tests via the Flask CLI testing command. Example commands: - `flask test user int` — or - `flask test user unit` — or `flask test user` — runs tests related to the `user` tests, including both integration (`int`) and unit (`unit`) scopes. + +## TEST COMMIT & PUSH From 7d14d89b4efff8463dec4a153f296321b344ccee Mon Sep 17 00:00:00 2001 From: Allin Ramjit Date: Wed, 26 Nov 2025 15:48:58 -0400 Subject: [PATCH 2/4] Remove logic from App/models/staff.py --- App/models/staff.py | 75 +++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 53 deletions(-) diff --git a/App/models/staff.py b/App/models/staff.py index 7279d59..ddd6285 100644 --- a/App/models/staff.py +++ b/App/models/staff.py @@ -3,58 +3,27 @@ class Staff(User): - __tablename__ = "staff" - staff_id = db.Column(db.Integer, db.ForeignKey("users.user_id"), primary_key=True) - - #relationaship to LoggedHours - loggedhours = db.relationship('LoggedHours', backref='staff', lazy=True, cascade="all, delete-orphan") +_tablename_ = "staff" +staff_id = db.Column(db.Integer, db.ForeignKey("users.user_id"), primary_key=True) - #Inheritance, Staff is a child of User - __mapper_args__ = { - "polymorphic_identity": "staff" - } - #calls parent constructor - def __init__(self, username, email, password): - super().__init__(username, email, password, role="staff") +#relationaship to LoggedHours +loggedhours = db.relationship('LoggedHours', backref='staff', lazy=True, cascade="all, delete-orphan") - def __repr__(self): - - return f"[Staff ID= {str(self.staff_id):<3} Name= {self.username:<10} Email= {self.email}]" - - def get_json(self): - return{ - 'staff_id': self.staff_id, - 'username': self.username, - 'email': self.email - } - - # Method to create a new staff member - def create_staff(username, email, password): - newstaff = Staff(username=username, email=email, password=password) - db.session.add(newstaff) - db.session.commit() - return newstaff - - # Method for staff to approve or deny requests - def approve_request(self, request): - from App.models import LoggedHours - if request.status != 'pending': - return None - # Mark request as approved - request.status = 'approved' - # Create a LoggedHours entry - logged = LoggedHours(student_id=request.student_id, staff_id=self.staff_id, hours=request.hours, status='approved') - db.session.add(logged) - db.session.commit() - return logged - - #Method to deny a request - def deny_request(self, request): - if request.status != 'pending': - return False - request.status = 'denied' - db.session.commit() - return True - - - \ No newline at end of file +#Inheritance, Staff is a child of User +_mapper_args_ = { +"polymorphic_identity": "staff" +} +#calls parent constructor +def _init_(self, username, email, password): +super().__init__(username, email, password, role="staff") + +def _repr_(self): + +return f"[Staff ID= {str(self.staff_id):<3} Name= {self.username:<10} Email= {self.email}]" + +def get_json(self): +return{ +'staff_id': self.staff_id, +'username': self.username, +'email': self.email +} From 22fe56c585771f8d67fc69bd238ba2c9733ea58a Mon Sep 17 00:00:00 2001 From: Satyam Date: Wed, 26 Nov 2025 17:13:27 -0400 Subject: [PATCH 3/4] Update student.py --- App/models/student.py | 43 +++++++------------------------------------ 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/App/models/student.py b/App/models/student.py index 5d1cf2c..b2fc970 100644 --- a/App/models/student.py +++ b/App/models/student.py @@ -3,56 +3,27 @@ class Student(User): - __tablename__ = "student" + _tablename_ = "student" student_id = db.Column(db.Integer, db.ForeignKey("users.user_id"), primary_key=True) - + #relationship to LoggedHours and Request both One-to-Many loggedhours = db.relationship('LoggedHours', backref='student', lazy=True, cascade="all, delete-orphan") requests = db.relationship('Request', backref='student', lazy=True, cascade="all, delete-orphan") #Inheritance setup - __mapper_args__ = { + _mapper_args_ = { "polymorphic_identity": "student" } #calls parent constructor - def __init__(self, username, email, password): - super().__init__(username, email, password, role="student") + def _init_(self, username, email, password): + super()._init_(username, email, password, role="student") - def __repr__(self): + def _repr_(self): return f"[Student ID= {str(self.student_id):<3} Name= {self.username:<10} Email= {self.email}]" - + def get_json(self): return{ 'student_id': self.student_id, 'username': self.username, 'email': self.email } - - # Method to create a new student - def create_student(username, email, password): - newstudent = Student(username=username, email=email, password=password) - db.session.add(newstudent) - db.session.commit() - return newstudent - - # Method for student to request hours - def request_hours_confirmation(self, hours): - from App.models import Request - request = Request(student_id=self.student_id, hours=hours, status='pending') - db.session.add(request) - db.session.commit() - return request - - # Method to calculate total approved hours and accolades - def accolades(self): - # Only count approved logged hours - total_hours = sum(lh.hours for lh in self.loggedhours if lh.status == 'approved') - accolades = [] - if total_hours >= 10: - accolades.append('10 Hours Milestone') - if total_hours >= 25: - accolades.append('25 Hours Milestone') - if total_hours >= 50: - accolades.append('50 Hours Milestone') - return accolades - From e675ed5abbfdbc183388a5a3efdd16d31d5bf83e Mon Sep 17 00:00:00 2001 From: Allin Ramjit Date: Wed, 26 Nov 2025 21:53:58 -0400 Subject: [PATCH 4/4] Removed logic from App/models/staff.py --- App/models/staff.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/App/models/staff.py b/App/models/staff.py index ddd6285..f0fe9f4 100644 --- a/App/models/staff.py +++ b/App/models/staff.py @@ -3,27 +3,27 @@ class Staff(User): -_tablename_ = "staff" -staff_id = db.Column(db.Integer, db.ForeignKey("users.user_id"), primary_key=True) + __tablename__ = "staff" + staff_id = db.Column(db.Integer, db.ForeignKey("users.user_id"), primary_key=True) -#relationaship to LoggedHours -loggedhours = db.relationship('LoggedHours', backref='staff', lazy=True, cascade="all, delete-orphan") + #relationaship to LoggedHours + loggedhours = db.relationship('LoggedHours', backref='staff', lazy=True, cascade="all, delete-orphan") -#Inheritance, Staff is a child of User -_mapper_args_ = { -"polymorphic_identity": "staff" -} -#calls parent constructor -def _init_(self, username, email, password): -super().__init__(username, email, password, role="staff") + #Inheritance, Staff is a child of User + __mapper_args__ = { + "polymorphic_identity": "staff" + } + #calls parent constructor + def __init__(self, username, email, password): + super().__init__(username, email, password, role="staff") -def _repr_(self): + def __repr__(self): -return f"[Staff ID= {str(self.staff_id):<3} Name= {self.username:<10} Email= {self.email}]" + return f"[Staff ID= {str(self.staff_id):<3} Name= {self.username:<10} Email= {self.email}]" -def get_json(self): -return{ -'staff_id': self.staff_id, -'username': self.username, -'email': self.email -} + def get_json(self): + return{ + 'staff_id': self.staff_id, + 'username': self.username, + 'email': self.email + } \ No newline at end of file