Exemplo n.º 1
0
class WebUsers(db.Model):
    """ defines table name """
    __tablename__ = 'webusers'
    __table_args__ = {'extend_existing': True}
    """ defines attributes """
    uid = db.Column(db.String(30), primary_key=True)
    password = db.Column(db.String(30), nullable=False)
    # is super field determines if this uer is an admin
    is_super = db.Column(db.Boolean, nullable=False, default=False)
    """ defines relationships and cascade delete constraints """
    students = db.relationship("Students", cascade="all,delete")
    webadmins = db.relationship("WebAdmins", cascade="all,delete")
    bids = db.relationship("Bids", cascade="all,delete")
Exemplo n.º 2
0
class Lectures(db.Model):
    """ defines table name """
    __tablename__ = 'lectures'
    __table_args__ = {'extend_existing': True}
    """ defines attributes """
    lnum = db.Column(db.Integer, primary_key=True)
    modcode = db.Column(db.String(100),
                        db.ForeignKey('modules.modcode'),
                        primary_key=True)
    quota = db.Column(db.Integer, nullable=False)
    deadline = db.Column(db.DateTime, nullable=False)
    """ defines relationship """
    slots = db.relationship("Slots", cascade="all")
    bids = db.relationship("Bids", cascade="all, delete")
    gets = db.relationship("Gets", cascade="all, delete")
Exemplo n.º 3
0
class Faculties(db.Model):
    """ defines table name """
    __tablename__ = 'faculties'
    __table_args__ = {'extend_existing': True}

    """ defines attributes """
    fname = db.Column(db.String(100), primary_key=True)

    """ defines relationships """
    # passive_deletes -> sets the fname in affected minors/majors to default
    minors = db.relationship(
        "Minors", passive_deletes="all", cascade="save-update")
    majors = db.relationship(
        "Majors", passive_deletes="all", cascade="save-update")
    modules = db.relationship(
        "Modules", passive_deletes="all", cascade="save-update")
Exemplo n.º 4
0
class Modules(db.Model):
    """ defines table name """
    __tablename__ = 'modules'
    __table_args__ = {'extend_existing': True}
    """ defines attributes """
    modcode = db.Column(db.String(100), primary_key=True)
    modname = db.Column(db.String(100), nullable=False)
    descriptions = db.Column(db.Text)
    fname = db.Column(db.String(100),
                      db.ForeignKey('faculties.fname'),
                      default='NUS')
    workload = db.Column(db.Integer, nullable=False)
    """ defines relationships """
    lectures = db.relationship("Lectures", passive_deletes="all")
    prerequisites = db.relationship("Prerequisites", cascade="all, delete")
    preclusions = db.relationship("Preclusions", cascade="all, delete")
Exemplo n.º 5
0
class Students(db.Model):
    """ defines table name """
    __tablename__ = 'students'
    __table_args__ = {'extend_existing': True}
    """ defines attributes """
    # UID serves as a primary key as well as a FK which references webuser table
    uid = db.Column(db.String(30),
                    db.ForeignKey('webusers.uid'),
                    primary_key=True)
    name = db.Column(db.String(100), nullable=False)
    enroll = db.Column(db.Date, nullable=False)
    """ defines relationships and cascade delete constraints """
    exchanges = db.relationship("Exchanges", cascade="all,delete")
    minoring = db.relationship("Minoring", cascade="all, delete, save-update")
    bids = db.relationship("Bids", cascade="all, delete, save-update")
    gets = db.relationship("Gets", cascade="all, delete, save-update")
    completions = db.relationship("Completions",
                                  cascade="all, delete, save-update")
Exemplo n.º 6
0
class Minors(db.Model):
    """ defines table name """
    __tablename__ = 'minors'
    __table_args__ = {'extend_existing': True}
    """ defines attributes """
    min_name = db.Column(db.String(100), primary_key=True)
    fname = db.Column(db.String(100),
                      db.ForeignKey('faculties.fname'),
                      default='NUS')
    """ defines relationships """
    minoring = db.relationship("Minoring", cascade="all, delete, save-update")