示例#1
0
class Announcement(db.Model):
    __tablename__ = "announcements"
    id = db.Column(db.Integer, primary_key=True)
    subject = db.Column(db.String(100), nullable=False)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    message = db.Column(db.Text, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)

    def __repr__(self):
        return f"Announcements('{self.subject}', '{self.date_posted}')"
示例#2
0
class Hostel(db.Model):
    __tablename__ = "hostels"
    hostel_id = db.Column(db.Integer, primary_key=True)
    hostel_name = db.Column(db.String(30), unique=True)
    occupants = db.relationship('User', backref='hostel')
    rooms = db.relationship('Room', backref='hostel')
    beds = db.relationship('Beds', backref='hostel')
    desc = db.Column(db.Text, nullable=False)
    img = db.Column(db.String, nullable=False)

    def __repr__(self):
        return f"Hostel('{self.hostel_id}', '{self.hostel_name}')"
示例#3
0
class Images(db.Model):
    __tablename__ = "images"
    image_id = db.Column(db.Integer, primary_key=True)
    image_file = db.Column(db.String, nullable=False)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    processed = db.Column(db.String(10), nullable=False, default="False")
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)

    def __repr__(self):
        return f"Images('{self.image_id}', '{self.date_posted}', '{self.processed}')"
示例#4
0
class User(db.Model, UserMixin):
    __tablename__ = "users"
    id = db.Column(db.Integer, primary_key=True)
    firstname = db.Column(db.String(20), nullable=False)
    lastname = db.Column(db.String(20), nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    number = db.Column(db.String(10), unique=True, nullable=False)
    gender = db.Column(db.String(10), nullable=False)
    role = db.Column(db.String(10), nullable=False, default="student")
    password = db.Column(db.String(60), nullable=False)
    hostel_id = db.Column(db.Integer, db.ForeignKey('hostels.hostel_id'))
    room_id = db.Column(db.String, db.ForeignKey('rooms.room_num'))
    images = db.relationship('Images', backref='user')
    announcements = db.relationship('Announcement', backref='user')

    def __repr__(self):
        return f"Student('{self.firstname}', '{self.lastname}', '{self.email}')"