class Post(db.Model): __tablename__ = 'post' id = db.Column(db.Integer, primary_key=True) title = db.Column(db.VARCHAR(50)) slug = db.Column(db.VARCHAR(50)) content = db.Column(db.VARCHAR(100)) id_user = db.Column(db.Integer, db.ForeignKey('user.id')) user = db.relationship('User', backref=db.backref('Post', lazy='dynamic')) id_post_type = db.Column(db.Integer, db.ForeignKey('post_type.id')) post_type = db.relationship('Post_type', backref=db.backref('Post', lazy='dynamic')) createdtime = db.Column(db.DateTime) updatetime = db.Column(db.DateTime) deletedtime = db.Column(db.DateTime) deleted = db.Column(db.Boolean) def __init__(self, title, content, id_post_type, id_user): self.title = title self.content = content self.id_post_type = id_post_type self.id_user = id_user self.slug = slugify(unicode(self.title)) self.createdtime = datetime.datetime.now() self.updatetime = datetime.datetime.now() self.deleted = 0 def __repr__(self): return "<Post: %s>"%self.title
class Post_type(db.Model): __tablename__ = 'post_type' id = db.Column(db.Integer, primary_key=True) post_type = db.Column(db.VARCHAR(10)) created_by = db.Column(db.Integer, db.ForeignKey('user.id')) user = db.relationship('User', backref=db.backref('Post_type', lazy='dynamic')) description = db.Column(db.VARCHAR(45))
class Social_Media(db.Model): __tablename__ = 'social_media' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.VARCHAR(15)) atr = db.Column(db.VARCHAR(2)) createdtime = db.Column(db.DateTime) updatedtime = db.Column(db.DateTime) deletedtime = db.Column(db.DateTime) deleted = db.Column(db.Boolean)
class Social_Media_User(db.Model): __tablename__ = 'social_media_user' id = db.Column(db.Integer, primary_key=True) id_socmed = db.Column(db.Integer, db.ForeignKey('social_media.id')) social_media = db.relationship('Social_Media', backref=db.backref('socmed_user', lazy='dynamic')) id_user = db.Column(db.Integer, db.ForeignKey('user.id')) user = db.relationship('User', backref=db.backref('socmed_user', lazy='dynamic')) value = db.Column(db.VARCHAR(45)) createdtime = db.Column(db.DateTime) updatedtime = db.Column(db.DateTime) deletedtime = db.Column(db.DateTime) deleted = db.Column(db.Boolean)
class Comment(db.Model): __tablename__ = 'comment' id = db.Column(db.Integer, primary_key=True) id_post = db.Column(db.Integer, db.ForeignKey('post.id')) post = db.relationship('Post', backref=db.backref('Comment', lazy='dynamic')) id_user = db.Column(db.Integer, db.ForeignKey('user.id')) user = db.relationship('User', backref=db.backref('Comment', lazy='dynamic')) desc = db.Column(db.VARCHAR(50)) createdtime = db.Column(db.DateTime) updatetime = db.Column(db.DateTime) deletedtime = db.Column(db.DateTime) deleted = db.Column(db.Boolean) def __init__(self, id_post, id_user, desc): self.id_post = id_post self.id_user = id_user self.desc = desc self.createdtime = datetime.datetime.now() self.updatetime = datetime.datetime.now() self.deleted = 0
class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) full_name = db.Column(db.VARCHAR(45)) username = db.Column(db.VARCHAR(15), unique=True) password = db.Column(db.VARCHAR(128)) email = db.Column(db.VARCHAR(30), unique=True) bio = db.Column(db.VARCHAR(20)) picture = db.Column(db.VARCHAR(50)) updatedtime = db.Column(db.DateTime) createdtime = db.Column(db.DateTime) deletedtime = db.Column(db.DateTime) deleted = db.Column(db.Boolean) last_login = db.Column(db.DateTime) id_type_user = db.Column(db.Integer, db.ForeignKey('user_type.id')) type_user = db.relationship('User_Type', backref=db.backref('user', lazy='dynamic')) def __init__(self, full_name, username, email, password): self.full_name = full_name self.username = username self.email = email self.password = generate_password_hash(password) self.createdtime = datetime.datetime.now() self.updatedtime = datetime.datetime.now() self.deleted = 0 self.id_type_user = 5 def is_authenticated(self): return True def is_active(self): return True def get_id(self): return unicode(self.id) def is_anonymous(self): return False def __repr__(self): return "<Username: %s>"%self.username
class User_Type(db.Model): __tablename__ = 'user_type' id = db.Column(db.Integer, primary_key=True) type = db.Column(db.VARCHAR(10))