Пример #1
0
class Picture(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String, nullable=False)
    url = db.Column(db.String, unique=True, nullable=False)
    date_create = db.Column(db.DateTime, default=datetime.utcnow)
    user_id = db.Column(db.Integer(),
                        db.ForeignKey('user.id', ondelete='CASCADE'),
                        index=True)
    comments = db.relationship('Comment', backref='picture')

    def __repr__(self):
        return '<Pictures {} {}>'.format(self.name, self.url)
Пример #2
0
class News(db.Model):
    # autoincrement=True !!!
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    title = db.Column(db.String, nullable=False)
    url = db.Column(db.String, unique=True, nullable=False)
    published = db.Column(db.DateTime, nullable=False)
    text = db.Column(db.Text, nullable=True)

    def comments_count(self):
        return Comment.query.filter(Comment.news_id==self.id).count()

    def __repr__(self):
        return '<News {} {}>'.format(self.title, self.url)
Пример #3
0
class EbayCategories(db.Model):
    __tablename__ = 'ebay_categories'
    id = db.Column(db.Integer, primary_key=True)
    category_name = db.Column('categoryname', db.String(50), nullable=False)
    category_level = db.Column('categorylevel', db.Integer, nullable=False)
    category_id = db.Column('categoryid',
                            db.Integer,
                            unique=True,
                            nullable=False)
    categoryparent_id = db.Column('categoryparentid', db.Integer)

    def __repr__(self):
        return '<category_name={} category_id={}>'.format(
            self.category_name, self.category_id)
Пример #4
0
class Comment(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date_create = db.Column(db.DateTime, default=datetime.utcnow)
    date_update = db.Column(db.DateTime,
                            default=datetime.utcnow,
                            onupdate=datetime.utcnow)
    comment = db.Column(db.Text, nullable=False)
    picture_id = db.Column(db.Integer(),
                           db.ForeignKey('picture.id', ondelete='CASCADE'),
                           index=True)

    def comments_count(self):
        return Comment.query.filter(Comment.id == self.id).count()

    def __repr__(self):
        return '<Comments {} {}>'.format(self.user_id, self.comment)
Пример #5
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True, unique=True)
    password = db.Column(db.String(100))
    role = db.Column(db.String(10), index=True)

    def set_password(self, password):
        self.password = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password, password)

    @property
    def is_admin(self):
        return self.role == 'admin'

    def __repr__(self):
        return '<User {}>'.format(self.username)
Пример #6
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), unique=True)
    password = db.Column(db.String(128))
    role = db.Column(db.String(10), index=True)
    pictures = db.relationship('Picture', backref='user')

    @property
    def is_user(self):
        return self.role == 'user'

    def set_password(self, password):
        self.password = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password, password)

    def __repr__(self):
        return '<User {}>'.format(self.username)
Пример #7
0
class Comment(db.Model):
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    text = db.Column(db.Text, nullable=False)
    created = db.Column(db.DateTime, nullable=False, default=datetime.now())
    news_id = db.Column(
        db.Integer,
        db.ForeignKey('news.id', ondelete='CASCADE'),
        index=True,
    )
    user_id = db.Column(
        db.Integer,
        db.ForeignKey('user.id', ondelete='CASCADE'),
        index=True,
    )
    news = relationship('News', backref='comments')
    user = relationship('User', backref='comments')

    def __repr__(self):
        return '<Comment {}>'.format(self.id)
Пример #8
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(50), index=True, unique=True)
    password = db.Column(db.String(128))
    email = db.Column(db.String(120), unique=True, nullable=True)
    role = db.Column(db.String(10))
    session_id = db.Column(db.String(50), nullable=True)
    session_id_status = db.Column(db.Boolean, nullable=True)
    hard_expiration_time = db.Column(db.DateTime, nullable=True)
    token = db.Column(db.String(100), nullable=True)
    token_status = db.Column(db.Boolean, nullable=True)

    def set_password(self, password):
        self.password = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password, password)

    @property
    def is_admin(self):
        return self.role == 'admin'

    def __repr__(self):
        return '<User name={} id={}>'.format(self.username, self.id)
Пример #9
0
class UserData(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    artist = db.Column(db.String, nullable=False)
    title = db.Column(db.String, nullable=False)
    comment = db.Column(db.String, nullable=True)
    notes = db.Column(db.String, nullable=False)
    created = db.Column(db.DateTime, nullable=False, default=datetime.now())
    user_id = db.Column(db.Integer,
                        db.ForeignKey('user.id', ondelete='CASCADE'),
                        index=True)

    user = relationship('User', backref='UserData')

    def __repr__(self):
        #return 'UserData {}'.format(self.id)
        return f'{self.id}, {self.artist}, {self.title}, {self.comment}'
Пример #10
0
class FavoriteSearches(db.Model):
    __tablename__ = 'favorite_searches'
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(
        db.Integer,
        db.ForeignKey('user.id', ondelete='CASCADE'),
        index=True
    )
    query_name = db.Column(db.String(50), nullable=False)
    user_query = db.Column(db.String(100), nullable=False)
    chosen_categoryid = db.Column(db.Integer, nullable=False)
    filter_request = db.Column(db.Text, nullable=False)
    date_of_creation = db.Column(
        db.DateTime,
        nullable=False,
        default=datetime.now(),
        )
    statistic_status = db.Column(db.Boolean, nullable=True)
    statistic_start_date = db.Column(db.DateTime, nullable=True)
    user = relationship('User', backref='favorite_searches')

    def __repr__(self):
        return '<user_id={} query={} filter_request={}>'.format(
            self.user_id, self.user_query, self.filter_request)
Пример #11
0
class StatisticItems(db.Model):
    __tablename__ = 'statistic_items'
    id = db.Column(db.Integer, primary_key=True)
    query_id = db.Column(
        db.Integer,
        db.ForeignKey('favorite_searches.id', ondelete='CASCADE'),
        index=True,
        nullable=False,
    )
    item_id = db.Column(db.String(50), nullable=False)
    item_name = db.Column(db.String(200), nullable=True)
    item_current_price = db.Column(db.String(10), nullable=False)
    end_time = db.Column(db.DateTime, nullable=False)
    final_price = db.Column(db.Integer, nullable=True)
    item_url = db.Column(db.String(200), nullable=False)
    bids = db.Column(db.Integer, nullable=True)
    favorite_searches = relationship(
        'FavoriteSearches',
        backref='statistic_items',
        )

    def __repr__(self):
        return '<query_id={} end_time={} final_price={}>'.format(
            self.query_id, self.end_time, self.final_price)