class Showing(db.Model): id = db.Column(db.Integer, primary_key=True) time = db.Column(db.String(10), nullable=False) movie_id = db.Column(db.Integer, db.ForeignKey('movie.id'), nullable=False) movie = db.relationship('Movie', backref=db.backref('showing', lazy=True)) theater_id = db.Column(db.Integer, db.ForeignKey('theater.id'), nullable=False) theater = db.relationship('Theater', backref=db.backref('showing', lazy=True)) def __repr__(self): return "{} {} in Theater {}".format(self.time, self.movie, self.theater_id)
class Movie(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100), unique=True, nullable=False) genre_id = db.Column(db.Integer, db.ForeignKey('genre.id'), nullable=False) genre = db.relationship('Genre', backref=db.backref('movie', lazy=True)) cast = db.relationship('Actor', secondary=movies_actors_association, lazy=True, backref=db.backref('movies', lazy=True)) def __repr__(self): return self.title
class Simulation(db.Model): id = db.Column(db.Integer, primary_key=True) owner = db.Column(db.Integer, db.ForeignKey('users.id')) owner_relationship = db.relationship('User', backref=db.backref('simulations', lazy='dynamic')) parent = db.Column(db.Integer, db.ForeignKey('simulation.id'), nullable=True) # protein name * protein = db.Column(db.String(500)) # force field * force_field = db.Column(db.String(500)) # engine * engine = db.Column(db.String(255)) # title * title = db.Column(db.String(255), unique=True) # date * date = db.Column(db.DateTime) def __init__(self, owner, title, engine, force_field, protein, parent=None): self.date = datetime.utcnow() self.owner = owner self.title = title self.engine = engine self.force_field = force_field self.protein = protein if parent is not None: self.parent = parent
class SimFile(db.Model): id = db.Column(db.Integer, primary_key=True) filename = db.Column(db.String(255)) simulation = db.Column(db.Integer, db.ForeignKey('simulation.id')) simulation_relationship = db.relationship('Simulation', backref=db.backref('files', lazy='dynamic')) def __init__(self, filename, simulation): self.filename = filename self.simulation = simulation.id
class Theater(db.Model): id=db.Column(db.Integer,primary_key=True) rowNumber=db.Column(db.Integer) #for configurable theater sizes rowSize=db.Column(db.Integer) #for configurable theater sizes location_id = db.Column(db.Integer, db.ForeignKey('location.id'), nullable=False) location = db.relationship('Location', backref=db.backref('theater', lazy=True)) seats = db.relationship('Seat', back_populates='theater', lazy=True) def __repr__(self): return "{}x{} Theater. id: {}".format(self.rowNumber, self.rowSize, self.id)
class User(db.Model, UserMixin): __tablename__ = "users" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(255)) email = db.Column(db.String(255), unique=True) password = db.Column(db.String(255)) active = db.Column(db.Boolean()) confirmed_at = db.Column(db.DateTime()) roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic')) def __str__(self): return '<User id=%s email=%s>' % (self.id, self.email)
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) first_name = db.Column(db.String(255)) last_name = db.Column(db.String(255)) email = db.Column(db.String(255), unique=True) password = db.Column(db.String(255)) active = db.Column(db.Boolean()) confirmed_at = db.Column(db.DateTime()) roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic')) #reservations = db.relationship('Seat',back_populates='user', lazy=True) @classmethod def find_by_username(cls, username): return cls.query.filter_by(email=username).first() def __str__(self): return self.email
title = db.Column(db.String(255), unique=True) # date * date = db.Column(db.DateTime) def __init__(self, owner, title, engine, force_field, protein, parent=None): self.date = datetime.utcnow() self.owner = owner self.title = title self.engine = engine self.force_field = force_field self.protein = protein if parent is not None: self.parent = parent Simulation.parent_relationship = db.relationship('Simulation', backref=db.backref('child', lazy='dynamic'), remote_side=Simulation.id) @app.route('/simulations/new/', methods=['GET', 'POST']) def new_sim(): if request.method == 'POST': owner = current_user title = request.form.get('title', None) engine = request.form.get('engine', None) force_field = request.form.get('force_field', None) protein = request.form.get('protein', None) if title is None or engine is None or force_field is None or protein is None: abort(401) sim = Simulation(owner=owner.id, title=title, engine=engine, force_field=force_field, protein=protein) db.session.add(sim)
# date * date = db.Column(db.DateTime) def __init__(self, owner, title, engine, force_field, protein, parent=None): self.date = datetime.utcnow() self.owner = owner self.title = title self.engine = engine self.force_field = force_field self.protein = protein if parent is not None: self.parent = parent Simulation.parent_relationship = db.relationship( "Simulation", backref=db.backref("child", lazy="dynamic"), remote_side=Simulation.id ) @app.route("/simulations/new/", methods=["GET", "POST"]) def new_sim(): if request.method == "POST": owner = current_user title = request.form.get("title", None) engine = request.form.get("engine", None) force_field = request.form.get("force_field", None) protein = request.form.get("protein", None) if title is None or engine is None or force_field is None or protein is None: abort(401) sim = Simulation(owner=owner.id, title=title, engine=engine, force_field=force_field, protein=protein) db.session.add(sim)