Exemple #1
0
class Board(db.Model):
    __tablename__ = 'boards'

    id = db.Column(db.Integer, primary_key=True, nullable=False)
    uid = db.Column(db.Integer, nullable=False)
    message = db.Column(db.String(255, convert_unicode=True), nullable=False)
    created_at = db.Column(db.DateTime, nullable=False, default=datetime.now)
    updated_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.now,
                           onupdate=datetime.now)
Exemple #2
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)

    body = db.Column(db.String(140))
    created_at = db.Column(db.DateTime, index=True, default=datetime.utcnow)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))

    __searchable__ = ['body']

    def __repr__(self):
        return '<Post {}>'.format(self.body)
Exemple #3
0
class Label(db.Model):
    """
    Model for Label
    A label is a company that funds an artist to make music
    """
    __tablename__ = 'labels'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(128))
    bio = db.Column(db.String)
    uri = db.Column(db.String)
    small_image = db.Column(db.String)
Exemple #4
0
class Portfolio_Page_Update(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    title = db.Column(db.String(100), nullable=False, default="Portfolio")
    subtitle = db.Column(db.Text, nullable=True, default="mi bezonas suoj")
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    def __repr__(self):
        return f"Portfolio_Page_Update('{self.title}', '{self.subtitle}')"
Exemple #5
0
class TeamChallenge(db.Model):
    __tablename__ = "team_challenge"

    id = db.Column(db.String(128), primary_key=True)
    team1_id = db.Column(db.String(128), db.ForeignKey("team.id"))
    team2_id = db.Column(db.String(128), db.ForeignKey("team.id"))

    mode = db.Column(db.String(128))
    start = db.Column(db.DateTime, default=func.now())
    end = db.Column(db.DateTime, default=func.now())

    status = db.Column(db.String(32))

    _team1 = db.relationship("Team", foreign_keys=[team1_id])
    _team2 = db.relationship("Team", foreign_keys=[team2_id])
    _matches = db.relationship(
        "Roster",
        primaryjoin=
        "or_(Roster.team_id==TeamChallenge.team1_id, Roster.team_id==TeamChallenge.team2_id)",
        foreign_keys="[Roster.team_id]")
class Category(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    active = db.Column(db.Boolean, default=True, nullable=False)
    name = db.Column(db.String(64))
    subcategories = relationship("Subcategory",
                                 order_by=Subcategory.name,
                                 back_populates="category",
                                 cascade="delete")
    products = relationship("Product",
                            order_by=Product.title,
                            back_populates="category")
Exemple #7
0
class Blog_Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    title = db.Column(db.String(100), nullable=False)
    content = db.Column(db.Text, nullable=False)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    def __repr__(self):
        return f"Blog_Post('{self.title}', '{self.date_posted}')"
Exemple #8
0
class SequenceTermCategories(db.Model):
    id                      = db.Column(db.Integer, primary_key=True, autoincrement=True)
    sequence_term_cat_label = db.Column(db.String(16), nullable=False)
    description             = db.Column(db.Text)
    domain                  = db.Column(db.String(32))
    vacant2                 = db.Column(db.String(16))
    vacant3                 = db.Column(db.String(16))
    visibility              = db.Column(db.String(16))
    status                  = db.Column(db.String(16))
    created_by              = db.Column(db.String(16))
    last_edited_by          = db.Column(db.String(16))
    date_created            = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    last_edited             = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
Exemple #9
0
class UserIP(db.Model):
    __tablename__ = 'UserIP'

    joinID = db.Column(db.String(100), primary_key=True)
    userID = db.Column(db.String(100), db.ForeignKey('UserInfo.userID'))
    ipAddress = db.Column(db.String(100))
    createTime = db.Column(db.DateTime)

    def __init__(self,
                 joinID=None,
                 userID=None,
                 ipAddress=None,
                 createTime=None):
        self.joinID = joinID
        self.userID = userID
        self.ipAddress = ipAddress
        self.createTime = createTime

    def __repr__(self):
        return self.joinID
Exemple #10
0
class Passport(db.Model):
    id = db.Column(db.Integer, primary_key=True)

    name = db.Column(db.String(20), nullable=False)

    email = db.Column(db.String(120), unique=True, nullable=False)

    passport_picture = db.Column(db.String(20), nullable=False)

    date_of_birth = db.Column(db.String(20), nullable=False)

    phone = db.Column(db.Integer, nullable=False)

    address = db.Column(db.Text, nullable=False)

    verification = db.Column(db.String(60),
                             nullable=False,
                             default='notverified')

    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)

    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    def get_reset_token(self, expires_sec=1800):
        s = serializer(app.config['SECRET_KEY'], expires_sec)
        return s.dumps({'user_id': self.id}).decode('utf-8')

    @staticmethod
    def verify_reset_token(token):
        s = serializer(app.config['SECRET_KEY'])

        try:
            user_id = s.loads(token)['user_id']
        except:
            return None
        return Passport.query.get(user_id)

    def __repr__(self):
        return f"Passport('{self.name}', '{self.email}', '{self.passport_picture}', '{self.date_of_birth}', '{self.date_posted}','{self.verification}')"
Exemple #11
0
class CustomizedTender(db.Model):

    __tablename__ = 'CustomizedTender'
    tenderID = db.Column(db.String(100), primary_key=True)
    title = db.Column(db.Text)
    createTime = db.Column(db.DateTime)
    userID = db.Column(db.String(100))
    url = db.Column(db.Text)

    def __init__(self, tenderID=None, title=None, createTime=None,
                 userID=None, url=None):
        self.tenderID = tenderID
        self.title = title
        self.createTime = createTime
        self.userID = userID
        self.url = url

    @staticmethod
    def create(info):
        customizedTender = CustomizedTender(
            tenderID=info['tenderID'],
            title=info['title'],
            createTime=info['createTime'],
            userID=info['userID'],
            url=info['url'],
        )
        db.session.add(customizedTender)
        return (True, info['tenderID'])

    @staticmethod
    def generate(c):
        res = {}
        res['tenderID'] = c.tenderID
        res['title'] = c.title
        res['createTime'] = str(c.createTime)[0:10]
        res['userID'] = c.userID
        res['url'] = c.url
        return res

    def __repr__(self):
        return self.tenderID
Exemple #12
0
class Comment(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    text = db.Column(db.String(300), nullable=False)
    date = db.Column(db.DateTime, nullable=False, default=datetime.now)
    writer_email = db.Column(db.Integer,
                             db.ForeignKey('user.email'),
                             nullable=False)

    def __repr__(self):
        return 'Comment id: %s by User with email: %s' % (self.id,
                                                          self.writer_email)
Exemple #13
0
class Wsrecord(Base):
    __tablename__ = 'wsrecord'

    recordId = db.Column(INTEGER(11), primary_key=True)
    stationId = db.Column(db.String(50))
    At = db.Column(BIGINT(20), index=True)
    Humidity = db.Column(db.Float)
    Moisture = db.Column(db.Float)
    Pressure = db.Column(db.Float)
    Temperature = db.Column(db.Float)
    WindDirection = db.Column(INTEGER(11))
    WindSpeed = db.Column(db.Float)
Exemple #14
0
class WatchlistItem(db.Model):
    __tablename__ = 'watchlist_item'
    id = db.Column(db.Integer, primary_key=True)
    ticker_name = db.Column(db.String(), unique=False, nullable=False)
    notes = db.Column(db.String(), nullable=False, default='')
    sector = db.Column(db.String(), nullable=False)
    date_added = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.today())
    user_id = db.Column(db.Integer,
                        db.ForeignKey('user.id', ondelete="CASCADE"),
                        nullable=False)
    tags = db.relationship('WatchlistItemTag',
                           backref='item',
                           lazy=True,
                           cascade="all, delete, delete-orphan",
                           passive_deletes=True)
    db.UniqueConstraint(user_id, ticker_name)

    def __repr__(self):
        return f"WatchlistTicker('{self.ticker_name}', '{self.date_added})"
Exemple #15
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True)
    password = db.Column(db.String(64))
    authenticated = db.Column(db.Boolean, default=False)
    settings = db.relationship("Settings", backref='user', lazy='dynamic')

    def get_id(self):
        return self.username

    def is_authenticated(self):
        return self.authenticated

    def is_anonymous(self):
        return False

    def is_active(self):
        return True

    def __repr__(self):
        return "<User {}>".format(self.username)
Exemple #16
0
class Jogg(db.Model):
    """
    Jogg Model to store user_id, start and end time as well as start and end locations of the jog
    """
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
    start_time = db.Column(db.DateTime, nullable=False, default=datetime.now)
    end_time = db.Column(db.DateTime, nullable=False, default=datetime.now)
    start_lat = db.Column(db.Integer, nullable=False)
    start_lon = db.Column(db.Integer, nullable=False)
    start_location = composite(Location, start_lat, start_lon)
    start_weather = db.Column(db.String(5000), unique=False, nullable=False)
    end_lat = db.Column(db.Integer, nullable=False)
    end_lon = db.Column(db.Integer, nullable=False)
    end_location = composite(Location, end_lat, end_lon)
    end_weather = db.Column(db.String(5000), unique=False, nullable=False)
    created_date = db.Column(db.DateTime, nullable=False, default=datetime.now)

    def __repr__(self):
        return f"Jogg('id': '{self.id}', 'user': '******', start_location': '{self.start_location}'," \
               f" 'end_location': '{self.end_location}', 'start_weather': '{self.start_weather}', 'end_weather': '{self.end_weather}')"
Exemple #17
0
class WatchlistItemTag(db.Model):
    __tablename__ = 'watchlist_tags'
    id = db.Column(db.Integer, primary_key=True)
    tag_content = db.Column(db.String(), nullable=False)
    ticker_id = db.Column(db.Integer,
                          db.ForeignKey('watchlist_item.id',
                                        ondelete="CASCADE"),
                          nullable=False)
    db.UniqueConstraint(ticker_id, tag_content)

    def __repr__(self):
        return f"WatchlistItemTag('{self.tag_content}', '{self.ticker_id}')"
Exemple #18
0
class Type2(db.Model):
    __tablename__ = 'Type2'
    typeID = db.Column(db.String(100), primary_key=True)
    typeName = db.Column(db.String(100))
    superTypeID = db.Column(db.String(100), db.ForeignKey('Type1.typeID'))

    type3 = db.relationship('Type3', backref='Type2', lazy='dynamic')

    def __init__(self, typeID=None, typeName=None, superTypeID=None):
        self.typeID = typeID
        self.typeName = typeName
        self.superTypeID = superTypeID

    @staticmethod
    def generate(type2):
        res = {}
        res['typeID'] = type2.typeID
        res['typeName'] = type2.typeName
        res['superTypeID'] = type2.superTypeID

        return res
Exemple #19
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(30), unique=True, nullable=False)
    password = db.Column(db.String(60), nullable=False)
    lastUpdated = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)

    interest1 = db.Column(db.String(60), nullable=False)
    interest2 = db.Column(db.String(60), nullable=False)
    interest3 = db.Column(db.String(60), nullable=False)

    otp_secret = db.Column(db.String(16), nullable=False)

    GIFs = db.relationship("UserGIF", backref="user", lazy=True)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # self.otp_secret = base64.b32encode(os.urandom(10)).decode()
        self.otp_secret = pyotp.random_base32()

    def get_auth_uri(self):
        servicer = 'CMSC388J-2FA'

        return ('otpauth://totp/{0}:{1}?secret={2}&issuer={0}'.format(
            servicer, self.username, self.otp_secret))

    def verify_totp(self, token):
        totp_client = pyotp.TOTP(self.otp_secret)
        return totp_client.verify(token)
Exemple #20
0
class Match(db.Model):
    __tablename__ = "match"

    id = db.Column(db.String(128), primary_key=True)
    createdAt = db.Column(db.DateTime)
    duration = db.Column(db.Integer)
    gameMode = db.Column(db.String(128))
    shardId = db.Column(db.String(128))
    patchVersion = db.Column(db.String(128))
    endGameReason = db.Column(db.String(128))
    queue = db.Column(db.String(128))

    rosters = db.relationship("Roster", backref="match")

    @hybrid_property
    def left(self):
        for roster in self.rosters:
            if roster.side == "left/blue":
                return roster

    @hybrid_property
    def right(self):
        for roster in self.rosters:
            if roster.side == "right/red":
                return roster

    def __init__(self, **kwargs):
        super(Match, self).__init__(**kwargs)
Exemple #21
0
class Part(db.Model):
    __tablename__ = 'parts'
    no = db.Column(db.String(255), primary_key=True, nullable=False)
    set_no = db.Column(db.String(255), db.ForeignKey('sets.no'), primary_key=True, nullable=False)
    color_id = db.Column(db.String(255), primary_key=True, nullable=False)
    color_name = db.Column(db.String(255), nullable=False)
    color_code = db.Column(db.String(255), nullable=False)
    color_type = db.Column(db.String(255), nullable=False)
    name = db.Column(db.Text(150), nullable=False)
    type = db.Column(db.String(255), nullable=False)
    category_id = db.Column(db.String(255), nullable=False)
    owned_quantity = db.Column(db.Integer())
    quantity = db.Column(db.Integer())
    extra_quantity = db.Column(db.Integer())
    is_alternate = db.Column(db.Boolean())
    is_counterpart = db.Column(db.Boolean())
    thumbnail_url = db.Column(db.String(255))
    __table_args__ = (
        db.UniqueConstraint("no", "set_no", "color_id"),
    )

    def __init__(self, no, set_no, name, type, category_id, color_id, color_name, color_code, color_type, owned_quantity, quantity, extra_quantity, is_alternate, is_counterpart, thumbnail_url):
        self.no = no
        self.set_no = set_no
        self.name = name
        self.type = type
        self.category_id = category_id
        self.color_id = color_id
        self.color_name = color_name
        self.color_code = color_code
        self.color_type = color_type
        self.owned_quantity = owned_quantity
        self.quantity = quantity
        self.extra_quantity = extra_quantity
        self.is_alternate = is_alternate
        self.is_counterpart = is_counterpart
        self.thumbnail_url = thumbnail_url

    def __repr__(self):
        return '<Part %r>' % self.no

    # subclass JSONEncoder
    class PartEncoder(JSONEncoder):
        def default(self, o):
            return o.__dict__
Exemple #22
0
class Application(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    app_date = db.Column(db.DateTime, default=get_cst)
    name = db.Column(db.String(75), nullable=False)
    join_how = db.Column(db.String(50), nullable=False)
    find_how = db.Column(db.String(200), nullable=False)
    self_description = db.Column(db.String(2000), nullable=False)
    b_tag = db.Column(db.String(50))
    have_auth = db.Column(db.String(20), nullable=False)
    play_when = db.Column(db.String(1000), nullable=False)
    # status is for where in the application process this is?
    status = db.Column(db.String(50), nullable=False, default="Accepted")
    note = db.Column(db.String(2000))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    user = db.relationship("User", back_populates="application")

    def __repr__(self):
        return f"Application('{self.name}', '{self.app_date}', '{self.user_id}', '{self.join_how}', {self.find_how}, \
Exemple #23
0
class Quote(db.Model):
    __tablename__ = 'quote'
    id = db.Column(db.Integer, primary_key=True)
    #initiated when Quote object is first created
    ticker_name = db.Column(db.String(), nullable=False, unique=True)
    exchange = db.Column(db.String(), nullable=False)
    timezone = db.Column(db.String(), nullable=False)
    current_price = db.Column(db.String(), nullable=False)
    change = db.Column(db.String(), nullable=False)
    change_percent = db.Column(db.String(), nullable=False)
    last_updated = db.Column(db.DateTime, nullable=False)
    #other things that are are updated by streamer
    day_high = db.Column(db.String(), nullable=True)
    day_low = db.Column(db.String(), nullable=True)
    day_volume = db.Column(db.String(), nullable=True)

    def __repr__(self):
        return f'Quote({self.ticker_name}, {self.current_price}, {self.last_updated})'
Exemple #24
0
class RevokedTokenModel(db.Model):
    __tablename__ = 'revoked_tokens'
    id = db.Column(db.Integer, primary_key=True)
    jti = db.Column(db.String())

    def add(self):
        db.session.add(self)
        db.session.commit()

    @classmethod
    def is_jti_blacklisted(cls, jti):
        query = cls.query.filter_by(jti=jti).first()
        return bool(query)
Exemple #25
0
class Coordinateur(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    nom = db.Column(db.String(120), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    image_file = db.Column(db.String(20), nullable=True, default='default.jpg')
    password = db.Column(db.String(60), nullable=False)

    def get_reset_token(self, expires_sec=1800):
        s = Serializer(app.config['SECRET_KEY'], expires_in=expires_sec)
        return s.dumps({'coordo_id': self.id}).decode('utf-8')

    @staticmethod
    def verify_reset_token(token):
        s = Serializer(app.config['SECRET_KEY'])
        try:
            coordo_id = s.loads(token)['coordo_id']
        except:
            return None
        return Coordinateur.query.get(coordo_id)

    def __repr__(self):
        return f"Coordo : {self.nom}, {self.email}"
Exemple #26
0
class Participant(db.Model):
    __tablename__ = "participant"

    id = db.Column(db.String(128), primary_key=True)
    player_id = db.Column(db.String(128), db.ForeignKey("player.id"))
    roster_id = db.Column(db.String(128), db.ForeignKey("roster.id"))

    actor = db.Column(db.String(128))
    kills = db.Column(db.Integer)
    assists = db.Column(db.Integer)
    deaths = db.Column(db.Integer)
    crystalMineCaptures = db.Column(db.Integer)
    goldMindCaptures = db.Column(db.Integer)
    krakenCaptures = db.Column(db.Integer)
    turrentCaptures = db.Column(db.Integer)

    winner = db.Column(db.Boolean)

    farm = db.Column(db.Integer)
    minionKills = db.Column(db.Integer)
    nonJungleMinionKills = db.Column(db.Integer)
    jungleKills = db.Column(db.Integer)

    firstAfkTime = db.Column(db.Integer)
    wentAfk = db.Column(db.Boolean)
    itemGrants = db.Column(db.PickleType)
    itemSells = db.Column(db.PickleType)
    itemUses = db.Column(db.PickleType)
    items = db.Column(db.PickleType)

    skinKey = db.Column(db.String(128))
    karmaLevel = db.Column(db.Integer)
    level = db.Column(db.Integer)
    skillTier = db.Column(db.Integer)

    createdAt = db.Column(db.DateTime, default=func.now())

    def __init__(self, **kwargs):
        super(Participant, self).__init__(**kwargs)
Exemple #27
0
class CompanyAssistant(db.Model):
    __tablename__ = 'CompanyAssistant'

    companyID = db.Column(db.String(100), primary_key=True)
    companyName = db.Column(db.String(100))
    foreignCompanyID = db.Column(db.String(100))

    def __init__(self,
                 companyID=None,
                 companyName=None,
                 foreignCompanyID=None):
        self.companyID = companyID
        self.companyName = companyName
        self.foreignCompanyID = foreignCompanyID

    @staticmethod
    def generate(o):
        res = {}
        res['companyID'] = o.companyID
        res['companyName'] = o.companyName
        res['foreignCompanyID'] = o.foreignCompanyID
        return res
Exemple #28
0
class Category(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(40), unique=True, nullable=False)
    movies = db.relationship('Movie',
                             secondary=categories,
                             lazy='subquery',
                             backref=db.backref('categories', lazy=True))

    def __repr__(self):
        return f"Category('{self.name}')"

    def __lt__(self, other):
        return self.name < other.name
Exemple #29
0
class Zip_to_latlong(db.Model):

    __tablename__ = 'zip_to_latlong'

    id = db.Column(db.Integer, index=True, primary_key=True)
    zip_code = db.Column(db.String(5), index=True, unique=True)
    lat_ = db.Column(db.Float(10))
    long_ = db.Column(db.Float(10))

    def __init__(self, zip_code, lat_, long_):
        self.zip_code = zip_code
        self.lat_ = lat_
        self.long_ = long_
Exemple #30
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(30), nullable=False)
    date_posted = db.Column(db.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    content = db.Column(db.Text, nullable=False)
    # user.id is in lower case because here we are accessing the database table and
    # attribute name instead of the class name.
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)

    def __repr__(self):
        return f'User: ("{self.id}", "{self.title}", "{self.date_posted}")'