Пример #1
0
class Entrant(Base):
    __tablename__ = 'entrants'
    '''
    table containing the list of entrants for each event 
    It manages the many to many relationship between members and events downloaded
    from USFA fencing AND results downloaded from fencingtimelive
    '''
    # Design is based upon Chapter 56 of Flask mega tutorial. 
    # it will require a 
    # Changes required:
    # 1. [ ] Remove "id_" column. The member_id/event_id combo is unique
    # 2. [ ] Add an "entrants" relationship to the Event table
    # 3. [ ] Remove the "event" relationship in this table
    # 4. [ ] Add a "bouts" relationship to this table below
    # 5. [ ] Future - support for teams
    id_ = db.Column(db.Integer, primary_key = True, autoincrement = False)  # <== does this need to be here. Member/Event is unique
    member_id = db.Column(db.Integer, db.ForeignKey('members.id_'))  # entrant can be a team so could be 1 to many
    event_id = db.Column(db.Integer, db.ForeignKey('events.id_'))
    ### Build out code for many to many relatioship 
    ### between event and member here
    ### and connects back to itself via the bout table
    initial_seeding = db.Column(db.Integer)
    seeding_after_pools = db.Column(db.Integer)
    final_placing = db.Column(db.Integer)
    rating_earned = db.Column(db.String(5))
    created_on = db.Column(db.DateTime, default=dt.now)
    updated_on = db.Column(db.DateTime, default=dt.now, onupdate=dt.now)
    event = db.relationship('Event',backref = 'entrants')  
Пример #2
0
class Tournament(Base):
    __tablename__ = 'tournaments'
    
    id_ = db.Column(db.Integer,primary_key = True,autoincrement = False)    # USFA ID
    ft_id = db.Column(db.String(80))                  # Fencing Time Live ID
    venue = db.Column(db.String(80))
    city =  db.Column(db.String(80))
    state = db.Column(db.String(15))
    name = db.Column(db.String(80))  #tournament name
    opens = db.Column(db.DateTime)   # tournament registration opens
    closes = db.Column(db.DateTime)   # registration deadline
    withdraw = db.Column(db.DateTime) # withdrawal deadline
    start = db.Column(db.DateTime)   #tournament start date
    end = db.Column(db.DateTime)    # tournament end date
    region = db.Column(db.String(15)) 
    type = db.Column(db.String(20))
    season_id = db.Column(db.Integer,db.ForeignKey ('seasons.id_'))   # Creates the link to the season instance
    status = db.Column(db.String(15))  # <-this changed
    created_on = db.Column(db.DateTime, default=dt.now)
    updated_on = db.Column(db.DateTime, default=dt.now, onupdate=dt.now)
    events = db.relationship('Event',
                                order_by = 'Event.start', 
                                backref = 'tournament',
                                lazy='dynamic',
                                cascade = "all,delete, delete-orphan")

    def __repr__(self):
        return f'{self.name}, {self.city}, {self.state}, {dt.strftime(self.start, "%B %d, %Y")}'
Пример #3
0
class Bout(Base):
    __tablename__='bouts'
    '''
    This table is contains the results of completed bouts downloaded 
    from fencingtimelive
    '''
    # Changes required based upon Ch 56 of FMT.
    # this table connects two entrants to one another
    # similar to the Followers.Followed realtionship 
    id_ = db.Column(db.Integer, primary_key = True, autoincrement = False) 
    red_member_id = db.Column(db.Integer, db.ForeignKey('members.id_'))  
    green_member_id = db.Column(db.Integer,db.ForeignKey('members.id_'))
    event_id = db.Column(db.Integer, db.ForeignKey('events.id_'))
    pool_id = db.Column(db.Integer)
    round = db.Column(db.Integer)
    red_score = db.Column(db.Integer)
    green_score = db.Column(db.Integer)
    referee = db.Column(db.String(40))
    winner = db.Column(db.Integer,db.ForeignKey('members.id_'))
Пример #4
0
class User(UserMixin,Base):
    __tablename__ = 'users'
    id = db.Column(db.Integer,primary_key=True)
    username = db.Column(db.String(64), index=True, unique=True)
    email = db.Column(db.String(120), index=True, unique=True)
    password_hash = db.Column(db.String(120))
    member_id = db.Column(db.Integer,db.ForeignKey('members.id_'))

    def __repr__(self):
        return '<User {}'.format(self.username)

    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)
Пример #5
0
class Event(Base):
    '''
    A fencing competition comprised of a number of entrants, individual or team. 
    Each tournament is made up of one or more events
    '''
    __tablename__ = 'events'

    id_ = db.Column(db.Integer, primary_key=True, autoincrement=False)
    name = db.Column(db.String(40), nullable=False)
    type = db.Column(db.String(20),nullable=True)  #<=== changed to 20 in 7fa9b0f30ee7
    weapon = db.Column(db.String(10), nullable=False)
    gender = db.Column(db.String(10), nullable=False) #<==changed to 10 in a485de8c06db
    abbreviation = db.Column(db.String(10),nullable=True)  # <= changed to 10 in 6a3ff88da143
    count = db.Column(db.Integer,nullable=True)   # entrant count
    rating = db.Column(db.String(2),nullable=True)  # calculated rating of event 
    tournament_id = db.Column(db.Integer,db.ForeignKey('tournaments.id_'))
    start = db.Column(db.DateTime)
    status = db.Column(db.String(10), nullable = True)
    created_on = db.Column(db.DateTime, default=dt.now)
    updated_on = db.Column(db.DateTime, default=dt.now, onupdate=dt.now)

    def __repr__(self):
        return f'{self.name}, {self.rating} event with {self.count} entrants'