diff --git a/App/models/staff.py b/App/models/staff.py index 7279d59..f0fe9f4 100644 --- a/App/models/staff.py +++ b/App/models/staff.py @@ -5,7 +5,7 @@ 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") @@ -18,43 +18,12 @@ 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 - } - - # 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 + } \ No newline at end of file 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 - 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