class University(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(40), nullable=False, unique=True) country = db.Column(db.String(40), nullable=False) def getUNIVERSITY(id): return University.query.filter_by(id=id).first()
class Courses(db.Model): course_id = db.Column(db.String(20), primary_key=True) uni_id = db.Column(db.Integer, db.ForeignKey('university.id'), nullable=False) name = db.Column(db.String(40), nullable=False, unique=True) faculty_id = db.Column(db.Integer, db.ForeignKey('faculty.faculty_id'), nullable=False)
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) #username=db.Column(db.String(25),nullable=False,unique=True) password = db.Column(db.String(150), nullable=False) email = db.Column(db.String(40), nullable=False, unique=True) university_id = db.Column(db.Integer, db.ForeignKey('university.id'), nullable=False) st_fa = db.Column(db.Boolean, nullable=False) #True if Faculty uni_admin_check = db.Column(db.Boolean, nullable=False) #True if Uniadmin
class Faculty(db.Model): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) firstname = db.Column(db.String(20), nullable=False) lastname = db.Column(db.String(20), nullable=False) def getFaculty(uni_id): #uni_id is admin id FacultyList = [] for uzer in User.GetUserOfUni(uni_id): if Faculty.query.filter_by(user_id=uzer.id).first(): FacultyList.append( Faculty.query.filter_by(user_id=uzer.id).first()) return FacultyList
class Student(db.Model): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) firstname = db.Column(db.String(20), nullable=False) lastname = db.Column(db.String(20), nullable=False) def getStudent(uni_id): #uni_id is admin uni id studentlist = [] for uzer in User.GetUserOfUni(uni_id): if Student.query.filter_by(user_id=uzer.id).first(): studentlist.append( Student.query.filter_by(user_id=uzer.id).first()) return studentlist def getStudentFromUserID(userid): return Student.query.filter_by(user_id=userid).first()
class College(db.Model): id = db.Column(db.Integer, primary_key=True) uni_id = db.Column(db.Integer, db.ForeignKey('university.id'), nullable=False) name = db.Column(db.String(40), nullable=False) def getCollege(uni_admin_id): return College.query.filter_by(uni_id=uni_admin_id).all()
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) password = db.Column(db.String(150), nullable=False) email = db.Column(db.String(40), nullable=False, unique=True) university_id = db.Column(db.Integer, db.ForeignKey('university.id'), nullable=False) st_fa = db.Column(db.Boolean, nullable=False) #True if Faculty uni_admin_check = db.Column(db.Boolean, nullable=False) #True if Uniadmin def get_reset_token(self, expires_sec=1800): s = Serializer(app.config['SECRET_KEY'], expires_sec) return s.dumps({'user_id': self.id}).decode('utf-8') def GetUser(id): return User.query.filter_by(id=id).all() def GetUserOfUni(uni_admin_uni_id): return User.query.filter_by(university_id=uni_admin_uni_id).all()
class Courses(db.Model): id = db.Column(db.Integer, primary_key=True) uni_id = db.Column(db.Integer, db.ForeignKey('university.id'), nullable=False) name = db.Column(db.String(40), nullable=False) faculty_id = db.Column(db.Integer, db.ForeignKey('faculty.id'), nullable=False) department_id = db.Column(db.Integer, db.ForeignKey('department.id'), nullable=False) def getCourse(uni_admin_id): #will also work for faculty-course table return Courses.query.filter_by(uni_id=uni_admin_id).all()
class Feedback(db.Model): id = db.Column(db.Integer, primary_key=True) note_id = db.Column(db.Integer, db.ForeignKey('notes.id'), nullable=False) faculty_id = db.Column(db.Integer, db.ForeignKey('faculty.id'), nullable=False) feedback = db.Column(db.String(500), nullable=False) def fbl(student_user_id): #Returns all the feedback for a given student. student = Student.query.filter_by(user_id=student_user_id).first() Feedbackstudent = [] for n in Notes.query.filter_by(student_id=student.id): for f in Feedback.query.all(): if f.note_id == n.id: Feedbackstudent.append(f) return Feedbackstudent
class Department(db.Model): department_id = db.Column(db.Integer, primary_key=True) uni_id = db.Column(db.Integer, db.ForeignKey('university.id'), nullable=False) name = db.Column(db.String(40), nullable=False, unique=True)
class University(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(40), nullable=False, unique=True) country = db.Column(db.String(40), nullable=False)
class Faculty(db.Model): faculty_id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) firstname = db.Column(db.String(20), nullable=False) lastname = db.Column(db.String(20), nullable=False)
class Uni_admin(db.Model): uni_ad_id = db.Column(db.Integer, primary_key=True) #admin id user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) firstname = db.Column(db.String(20), nullable=False) lastname = db.Column(db.String(20), nullable=False)