class EventType(db.Model): __tablename__ = 'event_type' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String()) description = db.Column(db.String()) create_at = db.Column(db.DateTime, index=True, default=datetime.utcnow()) updated_at = db.Column(db.DateTime, index=True, default=datetime.utcnow()) events = db.relationship("Events", backref="event_type", lazy=True) image = db.Column(db.String(), nullable=True) def __repr__(self): return f"<EventType {self.id} {self.name}>" def insert(self): db.session.add(self) db.session.commit() def delete(self): db.session.delete(self) db.session.commit() def update(self): db.session.commit() @property def serialize(self): return { "id": self.id, "name": self.name, "description": self.description, "created_at": self.create_at, "updated_at": self.updated_at, "image": self.image }
class Users(db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) first_name = db.Column(db.String()) last_name = db.Column(db.String()) email = db.Column(db.String(), nullable=False, unique=True) phone = db.Column(db.Integer) created_at = db.Column(db.DateTime, index=True, default=datetime.now) updated_at = db.Column(db.DateTime, index=True, default=datetime.utcnow) meta = {'allow_inheritance': True} @property def serialize(self): return { "id": self.id, "firstname": self.first_name, "lastname": self.last_name, "email": self.email, "phone": self.phone, "created_at": self.created_at, "updated_at": self.updated_at } def __repr__(self): return f"<User {self.id} {self.name}>"
class User(sa.Model, UserMixin): id = sa.Column(sa.Integer, primary_key=True) username = sa.Column(sa.String(80), unique=True, nullable=False) email = sa.Column(sa.String(120), unique=True) password_hash = sa.Column(sa.String(100)) first_name = sa.Column(sa.String(80)) last_name = sa.Column(sa.String(80)) def set_password(self, password): self.password_hash = generate_password_hash(password) def check_password(self, password): return check_password_hash(self.password_hash, password) def __repr__(self): return '<User %r>' % self.username
class Events(db.Model): __tablename__ = 'events' id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String()) description = db.Column(db.String()) start_date_time = db.Column(db.DateTime, index=True, default=datetime.utcnow) event_location = db.Column(db.String()) image = db.Column(db.String()) event_type_id = db.Column(db.Integer, db.ForeignKey("event_type.id")) organizer_id = db.Column(db.Integer, db.ForeignKey('users.id')) tickets = db.relationship("Tickets", backref="events", lazy=True) def __repr__(self): return f"<Events {self.id} {self.title}>" def insert(self): db.session.add(self) db.session.commit() def delete(self): db.session.delete(self) db.session.commit() def update(self): db.session.commit() @property def serialize(self): return { "id": self.id, "title": self.title, "description": self.description, "start_date": self.start_date_time, "address": self.event_location, "image_url": self.image, "event_type_id": self.event_type_id, "organizer_id": self.organizer_id, "tickets": [ticket.serialize for ticket in self.tickets] }
class dbKey(sqlalchemy.Model): __tablename__ = 'UG_KEYBOX' id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True) Rkey = sqlalchemy.Column(sqlalchemy.String(32), unique=True) num = sqlalchemy.Column(sqlalchemy.Integer) def __init__(self, Rkey, num): self.Rkey = Rkey self.num = num def __repr__(self): return '%r:%r' % (self.Rkey, self.num)
class Users(db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) first_name = db.Column(db.String()) last_name = db.Column(db.String()) email = db.Column(db.String(), nullable=False, unique=True) phone = db.Column(db.String()) password_hash = db.Column(db.String()) created_at = db.Column(db.DateTime, index=True, default=datetime.utcnow) updated_at = db.Column(db.DateTime, index=True, default=datetime.utcnow) events = db.relationship('Events', backref='users', lazy=True) def insert(self): db.session.add(self) db.session.commit() def delete(self): db.session.delete(self) db.session.commit() def update(self): db.session.commit() @property def serialize(self): return { "id": self.id, "firstname": self.first_name, "lastname": self.last_name, "email": self.email, "phone": self.phone, "created_at": self.created_at, "updated_at": self.updated_at, "events": [event.serialize for event in self.events] } def __repr__(self): return f"<User {self.id} {self.name}>"
class Role(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String())
class dbMac(sqlalchemy.Model): __tablename__ = 'UG_MACBOX' id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True) userMac = sqlalchemy.Column(sqlalchemy.String(32), unique=True)