예제 #1
0
class Show(db.Model):
    __tablename__ = 'shows'
    id = db.Column(db.Integer, primary_key=True)
    artist_id = db.Column(db.Integer,
                          db.ForeignKey('artists.id'),
                          nullable=False)
    venue_id = db.Column(db.Integer,
                         db.ForeignKey('venues.id'),
                         nullable=False)
    start_time = db.Column(db.DateTime, nullable=False)
    created_at = db.Column(db.DateTime,
                           nullable=False,
                           server_default=func.now())

    def is_past(self):
        if self.start_time < datetime.today():
            return True
        return False

    def artist_dict(self):
        return {
            'artist_id': self.artist_id,
            'artist_name': self.artist.name,
            'artist_image_link': self.artist.image_link,
            'start_time': self.start_time.strftime('%Y-%m-%d %H:%M:%S')
        }

    def venue_dict(self):
        return {
            "venue_id": self.venue_id,
            "venue_name": self.venue.name,
            "venue_image_link": self.venue.image_link,
            "start_time": self.start_time.strftime('%Y-%m-%d %H:%M:%S')
        }
예제 #2
0
class Show(db.Model):
    __tablename__ = 'Show'
    id = db.Column(db.Integer, primary_key=True)
    start_time = db.Column(db.DateTime, nullable=False)
    end_time = db.Column(db.DateTime, nullable=False)
    venue_id = db.Column(db.Integer, db.ForeignKey('Venue.id'), nullable=False)
    artist_id = db.Column(db.Integer,
                          db.ForeignKey('Artist.id'),
                          nullable=False)
예제 #3
0
class Show(db.Model):
    __tablename__ = 'Show'
    id = db.Column(db.Integer, primary_key=True)
    start_time = db.Column(db.DateTime())
    artist_id = db.Column(db.Integer, db.ForeignKey('Artist.id'))
    artist = db.relationship('Artist',
                             backref=db.backref('shows', cascade="all,delete"))
    venue_id = db.Column(db.Integer, db.ForeignKey('Venue.id'))
    venue = db.relationship('Venue',
                            backref=db.backref('shows', cascade="all,delete"))
예제 #4
0
class Show(db.Model):
    __tablename__ = 'Show'
    id = db.Column(db.Integer, primary_key=True)
    start_time = db.Column(db.DateTime(), nullable=False)
    venue_id = db.Column(db.Integer, db.ForeignKey('Venue.id'), nullable=False)
    artist_id = db.Column(db.Integer,
                          db.ForeignKey('Artist.id'),
                          nullable=False)

    def __repr__(self):
        return f'{self.id}: Show starts at {self.start_time}'
예제 #5
0
class Show(db.Model):
    __tablename__ = 'show'

    id = db.Column(db.Integer, primary_key=True)
    venue_id = db.Column(db.Integer, db.ForeignKey('venue.id'), nullable=False)
    artist_id = db.Column(db.Integer,
                          db.ForeignKey('artist.id'),
                          nullable=False)
    start_time = db.Column(db.TIMESTAMP(timezone=True))
    venue = db.relationship('Venue', backref='show_venue')
    artist = db.relationship('Artist', backref='show_artist')
예제 #6
0
class Availability(db.Model):
    __tablename__ = 'availability'

    id = db.Column(db.Integer, primary_key=True)
    artist_id = db.Column(db.Integer, db.ForeignKey('artists.id'))
    from_time = db.Column(db.DateTime, nullable=False)
    to_time = db.Column(db.DateTime, nullable=False)
예제 #7
0
class City(db.Model):
    __tablename__ = 'City'

    id = db.Column(db.Integer, primary_key=True)
    city = db.Column(db.String(120), nullable=False, unique=True)
    state_id = db.Column(db.Integer, db.ForeignKey('State.id'), nullable=False)
    venues = db.relationship('Venue', backref='city_', lazy=True)
    artists = db.relationship('Artist', backref='city_', lazy=True)
예제 #8
0
class Show(db.Model):
    __tablename__ = 'shows'

    id = db.Column(db.Integer, primary_key=True)
    artist_id = db.Column(db.Integer,
                          db.ForeignKey('artists.id'),
                          nullable=False)
    venue_id = db.Column(db.Integer,
                         db.ForeignKey('venues.id'),
                         nullable=False)
    start_time = db.Column(db.DateTime, nullable=True)
    created_at = db.Column(
        db.DateTime,
        nullable=True,
    )
    updated_at = db.Column(
        db.DateTime,
        nullable=True,
    )
예제 #9
0
class Artist(db.Model):
    __tablename__ = 'Artist'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)
    phone = db.Column(db.String(120))
    website = db.Column(db.String(256))
    image_link = db.Column(db.String(500))
    facebook_link = db.Column(db.String(120))
    city_id = db.Column(db.Integer, db.ForeignKey('City.id'), nullable=False)
    shows = db.relationship('Show', backref='_artist', lazy=True)
    seeking_venue = db.Column(db.Boolean, unique=False, default=True)
    seeking_description = db.Column(db.Text(), nullable=True)
    shows = db.relationship('Show', backref='artist_', lazy=True)
    genres = db.relationship('Genre',
                             secondary=artist_genres,
                             lazy='subquery',
                             backref=db.backref('_artist', lazy=True))
예제 #10
0
from fyyur import db

#----------------------------------------------------------------------------#
# Models.
#----------------------------------------------------------------------------#

GenreVenue = db.Table(
    'genre_venue',
    db.Column('venue_id',
              db.Integer,
              db.ForeignKey('venues.id'),
              primary_key=True,
              nullable=False),
    db.Column('genre_id',
              db.Integer,
              db.ForeignKey('genres.id'),
              primary_key=True,
              nullable=False))

ArtistGenre = db.Table(
    'artist_genre',
    db.Column('artist_id',
              db.Integer,
              db.ForeignKey('artists.id'),
              primary_key=True,
              nullable=False),
    db.Column('genre_id',
              db.Integer,
              db.ForeignKey('genres.id'),
              primary_key=True,
              nullable=False))
예제 #11
0
    artists = db.relationship('Artist', backref='city_', lazy=True)


class Genre(db.Model):
    __tablename__ = 'Genre'

    id = db.Column(db.Integer, primary_key=True)
    genre = db.Column(db.String(120), nullable=False, unique=True)


# Many to Many association table for venue and genres
venue_genres = db.Table(
    'Venue_Genres',
    db.Column('venue_id',
              db.Integer,
              db.ForeignKey('Venue.id'),
              primary_key=True),
    db.Column('genre_id',
              db.Integer,
              db.ForeignKey('Genre.id'),
              primary_key=True))


class Venue(db.Model):
    __tablename__ = 'Venue'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)
    address = db.Column(db.String(120))
    phone = db.Column(db.String(120))
    website = db.Column(db.String(256))