コード例 #1
0
ファイル: experiment.py プロジェクト: psemchyshyn/Aliens
class Experiment(db.Model):
    __tablename__ = "Experiment"
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.DateTime, default=datetime.utcnow)
    human_id = db.Column(db.Integer, db.ForeignKey("Human.id"), nullable=False)
    spaceship_id = db.Column(db.Integer, db.ForeignKey("Spaceship.id"), nullable=False)
    human = db.relationship("Human", backref=db.backref("experiments", lazy=True))
    aliens = db.relationship("Alien", secondary=experiment_aliens, backref=db.backref("experiments", lazy=True))
    spaceship = db.relationship("Spaceship", backref=db.backref("experiments", lazy=True))

    def __init__(self, human, alien, spaceship):
        self.human = human
        self.alien = alien
        self.spaceship = spaceship
コード例 #2
0
ファイル: escape.py プロジェクト: psemchyshyn/Aliens
class Escape(db.Model):
    __tablename__ = "Escape"
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.DateTime, default=datetime.utcnow)
    human_id = db.Column(db.Integer, db.ForeignKey("Human.id"), nullable=False)
    spaceship_id = db.Column(db.Integer,
                             db.ForeignKey("Spaceship.id"),
                             nullable=False)
    human = db.relationship("Human", backref=db.backref("escapes", lazy=True))
    spaceship = db.relationship("Spaceship",
                                backref=db.backref("escapes", lazy=True))

    def __init__(self, human, spaceship):
        self.human = human
        self.spaceship = spaceship
コード例 #3
0
class Cemetery(db.Model):
    __tablename__ = "Cemetery"
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.DateTime, default=datetime.utcnow)
    killer_id = db.Column(db.Integer,
                          db.ForeignKey("Human.id"),
                          nullable=False)
    alien_id = db.Column(db.Integer, db.ForeignKey("Alien.id"), nullable=False)
    killer = db.relationship("Human", backref=db.backref("killed", lazy=True))
    alien = db.relationship("Alien",
                            backref=db.backref("cemetery",
                                               lazy=True,
                                               uselist=False))

    def __init__(self, human, alien):
        self.human = human
        self.alien = alien
コード例 #4
0
class Commutation(db.Model):
    __tablename__ = "Commutation"
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.DateTime, default=datetime.utcnow)
    human_id = db.Column(db.Integer, db.ForeignKey("Human.id"), nullable=False)
    alien_id = db.Column(db.Integer, db.ForeignKey("Alien.id"), nullable=False)
    from_id = db.Column(db.Integer, db.ForeignKey("Spaceship.id"), nullable=False)
    to_id = db.Column(db.Integer, db.ForeignKey("Spaceship.id"), nullable=False)
    from_ship = db.relationship("Spaceship", backref=db.backref("transferred", lazy=True), foreign_keys=[from_id])
    to_ship = db.relationship("Spaceship", backref=db.backref("accepted", lazy=True), foreign_keys=[to_id])
    human = db.relationship("Human", backref=db.backref("commutations", lazy=True))
    alien = db.relationship("Alien", backref=db.backref("commutations", lazy=True))

    def __init__(self, human, alien, frm, to):
        self.human = human
        self.alien = alien
        self.frm = frm
        self.to = to
コード例 #5
0
ファイル: excursion.py プロジェクト: psemchyshyn/Aliens
class Excursion(db.Model):
    __tablename__ = "Excursion"
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.DateTime, default=datetime.utcnow)
    alien_id = db.Column(db.Integer, db.ForeignKey("Alien.id"), nullable=False)
    guide = db.relationship("Alien",
                            backref=db.backref("excursions", lazy=True))
    participants = db.relationship("Human",
                                   secondary=excursion_humans,
                                   backref=db.backref("excursions", lazy=True))

    def __init__(self, human, alien, spaceship):
        self.human = human
        self.alien = alien
        self.spaceship = spaceship
コード例 #6
0
ファイル: experiment.py プロジェクト: psemchyshyn/Aliens
from aliens import db
from datetime import datetime


experiment_aliens = db.Table('ExperimentAliens',
    db.Column('experiment_id', db.Integer, db.ForeignKey('Experiment.id'), primary_key=True),
    db.Column('alien_id', db.Integer, db.ForeignKey('Alien.id'), primary_key=True)
)

class Experiment(db.Model):
    __tablename__ = "Experiment"
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.DateTime, default=datetime.utcnow)
    human_id = db.Column(db.Integer, db.ForeignKey("Human.id"), nullable=False)
    spaceship_id = db.Column(db.Integer, db.ForeignKey("Spaceship.id"), nullable=False)
    human = db.relationship("Human", backref=db.backref("experiments", lazy=True))
    aliens = db.relationship("Alien", secondary=experiment_aliens, backref=db.backref("experiments", lazy=True))
    spaceship = db.relationship("Spaceship", backref=db.backref("experiments", lazy=True))

    def __init__(self, human, alien, spaceship):
        self.human = human
        self.alien = alien
        self.spaceship = spaceship
コード例 #7
0
ファイル: excursion.py プロジェクト: psemchyshyn/Aliens
from aliens import db
from datetime import datetime

excursion_humans = db.Table(
    'ExcursionHuman',
    db.Column('excursion_id',
              db.Integer,
              db.ForeignKey('Excursion.id'),
              primary_key=True),
    db.Column('human_id',
              db.Integer,
              db.ForeignKey('Human.id'),
              primary_key=True))


class Excursion(db.Model):
    __tablename__ = "Excursion"
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.DateTime, default=datetime.utcnow)
    alien_id = db.Column(db.Integer, db.ForeignKey("Alien.id"), nullable=False)
    guide = db.relationship("Alien",
                            backref=db.backref("excursions", lazy=True))
    participants = db.relationship("Human",
                                   secondary=excursion_humans,
                                   backref=db.backref("excursions", lazy=True))

    def __init__(self, human, alien, spaceship):
        self.human = human
        self.alien = alien
        self.spaceship = spaceship