Esempio n. 1
0
class ObjectsIpgroups(db.Model):
    __tablename__ = __objects_ipgroups_tablename__
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True)
    description = db.Column(db.String(255))

    # directly access secondary entities,
    # such as group -> mapping -> objs
    ipaddrs = relationship(ObjectsIpaddrs,
                           backref='ObjectsIpgroups',
                           secondary=lambda: ObjectsIpaddrsIpgroups.__table__)

    ipaddr_id = association_proxy('ipaddrs', 'id')
    ipaddr_name = association_proxy('ipaddrs', 'name')

    # auto update mapping table
    mapping = relationship('ObjectsIpaddrsIpgroups',
                           backref='ObjectsIpgroups',
                           cascade='save-update, delete, delete-orphan, merge')

    def __init__(self):

        pass

    def __repr__(self):
        return '<Name %r>' % self.name
Esempio n. 2
0
class CustomerBusinessgrps(db.Model):
    __tablename__ = __customer_businessgrps_tablename__
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True)
    description = db.Column(db.String(254))
    isdel = db.Column(db.Boolean, default=False)

    # directly access secondary entities,
    # such as group -> mapping -> objs
    businesses = relationship(
        CustomerBusinesses,
        backref='CustomerBusinessgrps',
        secondary=lambda: CustomerBusinessesBusinessgrps.__table__)

    business_id = association_proxy('businesses', 'id')
    business_name = association_proxy('businesses', 'name')

    # auto update mapping table
    mapping = relationship('CustomerBusinessesBusinessgrps',
                           backref='CustomerBusinessgrps',
                           cascade='save-update, delete, delete-orphan, merge')

    def __init__(self):
        pass

    def __repr__(self):
        return '<Name %r>' % self.name
Esempio n. 3
0
class CustomerBusinesses(db.Model):
    __tablename__ = __customer_businesses_tablename__
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True)
    cat = db.Column(db.Integer)
    lat = db.Column(db.Float)
    long = db.Column(db.Float)
    deal = db.Column(db.Integer)
    #image_url = db.Column(db.String(254))
    description = db.Column(db.String(254))

    #detail_id = db.Column(db.Integer, db.ForeignKey('CustomerBusinessDetails.id'))
    #detail = db.relationship('CustomerBusinessDetails', backref='CustomerBusinesses')
    detail = db.relationship(
        'CustomerBusinessDetails',
        backref='CustomerBusinessDetails.business_id',
        primaryjoin=
        'CustomerBusinesses.id==CustomerBusinessDetails.business_id',
        lazy='joined',
        uselist=False)

    #detail = db.relationship('CustomerBusinessDetails', foreign_keys='CustomerBusinessDetails.business_id', backref=__customer_businesses_tablename__, lazy='joined')
    #detail_id = relationship('CustomerBusinessDetails', cascade='all,delete,delete-orphan', backref='CustomerBusinessDetails')

    #description = relationship('CustomerBusinessDetails', uselist=False,
    #        backref="CustomerBusinesses")
    #description = relationship('CustomerBusinessDetails', foreign_keys='CustomerBusinessDetails.description', backref=__customer_business_details_tablename__, lazy='joined')

    isdel = db.Column(db.Boolean, default=False)

    def __init__(self):
        pass

    def __repr__(self):
        return '<Name %r>' % self.name
Esempio n. 4
0
class Student(BaseModel, db.Model):
    # Main model
    __tablename__ = 'student'
    # Autoincrementing, unique primary key
    uid = db.Column(db.Integer(), primary_key=True)
    # Student data
    name = db.Column(db.String(120), nullable=False)
    email = db.Column(db.String(120), nullable=False, unique=True)
    phone = db.Column(db.String(120), nullable=False)
    # Relationships
    enrollments = db.relationship('Enrollment',
                                  back_populates='student',
                                  cascade='all,delete,delete-orphan')
    grades = db.relationship('Grade',
                             back_populates='student',
                             cascade='all,delete,delete-orphan')

    # Methods
    def __init__(self, name=None, email=None, phone=None):
        self.name = name
        self.email = email
        self.phone = phone

    # Return full details.
    def full(self):
        return {
            'uid': self.uid,
            'name': self.name,
            'email': self.email,
            'phone': self.phone,
        }

    # Return truncated details.
    def short(self):
        return {'uid': self.uid, 'name': self.name}

    # Return full details with enrollments.
    def with_enrollments(self):
        return {
            'uid':
            self.uid,
            'name':
            self.name,
            'email':
            self.email,
            'phone':
            self.phone,
            'enrollments': [{
                'uid': enrollment.uid,
                'title': enrollment.course.title,
                'days': enrollment.course.days,
                'start_time': enrollment.course.start_time,
                'end_time': enrollment.course.end_time
            } for enrollment in self.enrollments]
        }
Esempio n. 5
0
class PoliciesSecurities(db.Model):
    __tablename__ = __policies_security_tablename__

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True)

    # directly access secondary entities,
    # such as group -> mapping -> objs
    srcIpAddrs = relationship('ObjectsIpaddrs',
                              backref='ObjectsIpaddrs',
                              secondary=\
                              lambda: PoliciesSecuritiesIpAddrs.__table__)
    # auto get mapping value
    srcIpAddrs_id = association_proxy('srcIpAddrs', 'id')
    srcIpAddrs_name = association_proxy('srcIpAddrs', 'name')

    # auto update mapping table in Create
    srcIpAddrsMapping = relationship('PoliciesSecuritiesIpAddrs',
                                     backref='ObjectsIpaddrs',
                                     cascade='save-update, delete,'\
                                     ' delete-orphan, merge')




    srcIpGroups = relationship('ObjectsIpgroups',
                              backref='ObjectsIpgroups',
                              secondary=\
                              lambda: PoliciesSecuritiesIpGroups.__table__)
    # auto get mapping value
    srcIpGroups_id = association_proxy('srcIpGroups', 'id')
    srcIpGroups_name = association_proxy('srcIpGroups', 'name')

    # auto update mapping table in Create
    srcIpGroupsMapping = relationship('PoliciesSecuritiesIpGroups',
                                     backref='ObjectsIpgroups',
                                     cascade='save-update, delete,'\
                                     ' delete-orphan, merge')

    #dstIpAddrs= Column(db.Integer, ForeignKey('ObjectsIpaddrs.id'), primary_key=True)
    #dstIpGroups = Column(db.Integer, ForeignKey('ObjectsIpgroups.id'), primary_key=True)

    action = db.Column('action', Integer)
    logging = db.Column('logging', Integer)
    enabled = db.Column('enabled', Integer)
    ipprofileLogOnly = db.Column('ipprofileLogOnly', Boolean)

    description = db.Column(db.String(255))

    def __init__(self):
        pass

    def __repr__(self):
        return '<Name %r>' % self.name
Esempio n. 6
0
class AdminGroup(db.Model):
    __tablename__ = __user_admingroup_tablename__
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64))
    permission = db.Column(db.String(64))
    user_id = db.Column(db.Integer, ForeignKey(Users.id), primary_key=True)
    isdel = db.Column(db.Boolean, default=False)

    #LEFT OUTER JOIN `User`
    #user_obj = relationship('User', lazy='joined', cascade='all')
    #user_obj = relationship('User', lazy='dynamic', cascade='all')
    #username = Column(String(32), index=True, server_default='', nullable=False)
    #friends = relationship('Friend', backref='Friend.friend_id',primaryjoin='User.id==Friend.user_id', lazy='dynamic')
    #chat_memb = db.relationship('user', secondary=chat_members,
    #                                    backref=db.backref('chats', lazy='dynamic'))
    #chat.query.join(user.chats).filter(user.id == 1).all()
    #subq = sess.query(Score.user_id, func.sum(Score.amount).label('score_increase')).\
    #        filter(Score.created_at > someday).\
    #        group_by(Score.user_id).subquery()
    #sess.query(User).join((subq, subq.c.user_id==User.user_id)).order_by(subq.c.score_increase)

    def __init__(self):
        pass

    def serialize():
        return {
            '_id': 1,
            'username': self.name,
            'fullname': u'George Washington'
            # other fields that you need in the json
        }

    def __repr__(self):
        #    return self.__dict__
        #    return "<"+self.__tablename__+"('{}','{}','{}')>".format(
        #            self.id, self.permission, self.name)

        #    return '"{Name:%r}"' % self.name
        #    return '<Name: %r>' % self.name
        #    #return { 'id': self.id, 'permission': self.permission, 'name': self.name }
        #    #return '<id: %r, permission: %r, name:%r>' % self.id, self.permission, self.name
        #    #return '<id: %r, permission: %r, name:%r>' % self.id, self.permission, self.name
        return 'id: "{}", permission: "{}", name: "{}"'.format(
            self.id, self.permission, self.name)

    #    return '{id: %d, permission: %s, name:%s}'.format(self.id, self.permission, self.name)
    #    #return '"Name %r"' % self.name
    #    #return '<Name %r>' % self.name

    @staticmethod
    def verify_auth_token(token):
        pass
Esempio n. 7
0
class CustomerBusinessComments(db.Model):
    __tablename__ = __customer_business_comments_tablename__
    id = db.Column(db.Integer, primary_key=True)
    business_id = db.Column(db.Integer,
                            ForeignKey(CustomerBusinesses.id),
                            primary_key=True)
    # FIXME: not use hard code in ForeignKey('users.id'))
    user_id = db.Column(db.Integer, ForeignKey('users.id'), primary_key=True)

    #user = db.relationship('Users')
    #user = db.relationship('Users', backref='CustomerBusinessComments')
    #user = db.relationship('Users', backref='CustomerBusinessComments', primaryjoin='Users.comment_id==CustomerBusinessComments.id', lazy='joined')
    #user = relationship('Users', foreign_keys='Users.comment_id',
    #        # we dont need delete all->readd
    #        cascade='save-update, delete-orphan',
    #        backref=__user_users_tablename__, lazy='joined')
    #user = relationship('Users',
    #            #primaryjoin='CustomerBusinessComments.user_id == Users.id',
    #                backref=backref(__customer_business_comments_tablename__, lazy='joined'))

    content = db.Column(db.String(254))
    #rate = db.Column(db.Integer)

    mtime = db.Column(DateTime, default=datetime.utcnow())
    ctime = db.Column(DateTime, default=datetime.utcnow())
    isdel = db.Column(db.Boolean, default=False)

    def __init__(self):
        pass

    def __repr__(self):
        return '<Name %r>' % self.__tablename__
Esempio n. 8
0
class CustomerBusinessDeals(db.Model):
    __tablename__ = __customer_business_deals_tablename__
    id = db.Column(db.Integer, primary_key=True)
    business_id = db.Column(db.Integer,
                            ForeignKey(CustomerBusinesses.id),
                            primary_key=True)
    title = db.Column(db.String(254))
    description = db.Column(db.String(254))

    mtime = db.Column(DateTime, default=datetime.utcnow())
    ctime = db.Column(DateTime, default=datetime.utcnow())
    isdel = db.Column(db.Boolean, default=False)

    def __init__(self):
        pass

    def __repr__(self):
        return '<Name %r>' % self.__tablename__
Esempio n. 9
0
class Users(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    idsocial = db.Column(db.String(250), unique=True)
    name = db.Column(db.String(250))
    lastname = db.Column(db.String(250))
    email = db.Column(db.String(150), unique=True)
    password = db.Column(db.String(250))
    rol = db.Column(db.Integer)
    email_verified_at = db.Column(db.String)
    remember_token = db.Column(db.String(400))
    photo = db.Column(db.String(400))
    phone = db.Column(db.String(20))
Esempio n. 10
0
class Grade(BaseModel, db.Model):
    # Main model
    __tablename__ = 'grade'
    # Autoincrementing, unique primary key
    uid = db.Column(db.Integer, primary_key=True)
    # Grade data
    student_uid = db.Column(db.Integer,
                            db.ForeignKey('student.uid'),
                            nullable=False)
    course_uid = db.Column(db.Integer,
                           db.ForeignKey('course.uid'),
                           nullable=False)
    grade = db.Column(db.String(120), nullable=False)
Esempio n. 11
0
class Online(db.Model):
    __tablename__ = __user_online_tablename__
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    sid = db.Column(db.String(64))
    latest = db.Column(DateTime, default=datetime.utcnow())
    user_id = Column(db.Integer, ForeignKey(Users.id), primary_key=True)

    #user_id = relationship('', cascade='all,delete', backref='User')

    def __init__(self):
        pass

    def __repr__(self):
        return '<latest: %r>' % self.latest
Esempio n. 12
0
class Pushno(db.Model):
    __tablename__ = __pushno_tablename__
    id = db.Column(db.Integer, primary_key=True)
    # (1, 'andriod'), (2, 'ios')
    type = db.Column(db.Integer)
    dev_id = db.Column(db.String(254))
    user_id = db.Column(db.Integer, ForeignKey('users.id'), primary_key=True)
    business_id = db.Column(db.Integer,
                            ForeignKey(CustomerBusinesses.id),
                            primary_key=True)

    mtime = db.Column(DateTime, default=datetime.utcnow())
    ctime = db.Column(DateTime, default=datetime.utcnow())
    isdel = db.Column(db.Boolean, default=False)

    def __init__(self):
        pass

    def __repr__(self):
        return '<Name %r>' % self.__tablename__
Esempio n. 13
0
class ObjectsIpaddrs(db.Model):
    __tablename__ = __objects_ipaddrs_tablename__
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True)
    type = db.Column(db.String(6))
    ipVersion = db.Column(db.String(4))
    addr1 = db.Column(db.String(46))
    addr2 = db.Column(db.String(46))
    description = db.Column(db.String(255))

    def __init__(self):
        pass

    def __repr__(self):
        return '<Name %r>' % self.name
Esempio n. 14
0
class CustomerBusinessPics(db.Model):
    __tablename__ = __customer_business_pics_tablename__
    id = db.Column(db.Integer, primary_key=True)
    business_id = db.Column(db.Integer,
                            ForeignKey(CustomerBusinesses.id),
                            primary_key=True)
    # (1, 'icon'), (2, 'bg'), (3, 'gallery')
    type = db.Column(db.Integer)
    height = db.Column(db.Integer)
    width = db.Column(db.Integer)
    path = db.Column(db.String(254))
    #icon = db.Column(db.String(254))
    #bg = db.Column(db.String(254))

    mtime = db.Column(DateTime, default=datetime.utcnow())
    ctime = db.Column(DateTime, default=datetime.utcnow())
    isdel = db.Column(db.Boolean, default=False)

    def __init__(self):
        pass

    def __repr__(self):
        return '<Name %r>' % self.__tablename__
Esempio n. 15
0
class Course(BaseModel, db.Model):
    __tablename__ = 'course'

    # Autoincrementing, unique primary key
    uid = db.Column(db.Integer(), primary_key=True)

    # Course data
    title = db.Column(db.String(120), nullable=False)
    days = db.Column(db.String(240), nullable=False)
    start_time = db.Column(db.String(120), nullable=False)
    end_time = db.Column(db.String(120), nullable=False)
    description = db.Column(db.String(1000), nullable=False)

    # Relationships
    assignments = db.relationship('Assignment',
                                  back_populates='course',
                                  cascade='all,delete,delete-orphan')
    enrollments = db.relationship('Enrollment',
                                  back_populates='course',
                                  cascade='all,delete,delete-orphan')

    # enrollments = db.relationship('Enrollment', back_populates='student',
    #                               lazy=True)

    # Methods
    def __init__(self,
                 title=None,
                 days=None,
                 start_time=None,
                 end_time=None,
                 description=None):
        self.title = title
        self.days = days
        self.start_time = start_time
        self.end_time = end_time
        self.description = description

    # Return full details
    def full(self):
        return {
            'uid':
            self.uid,
            'title':
            self.title,
            'instructors': [{
                'uid': assignment.instructor.uid,
                'name': assignment.instructor.name,
            } for assignment in self.assignments],
            'days': ([day.capitalize() for day in self.days.split(',')]
                     if type(self.days) != list else self.days),
            'start time':
            self.start_time,
            'end time':
            self.end_time,
            'description':
            self.description
        }

    # Return truncated details.
    def short(self):
        return {'uid': self.uid, 'title': self.title}

    def with_students(self):
        return {
            'uid':
            self.uid,
            'title':
            self.title,
            'students': [{
                'uid': enrollment.student.uid,
                'name': enrollment.student.name,
                'email': enrollment.student.email,
                'phone': enrollment.student.phone,
                'enrollment_uid': enrollment.uid
            } for enrollment in self.enrollments],
            'days': ([day.capitalize() for day in self.days.split(',')]
                     if type(self.days) != list else self.days),
            'start time':
            self.start_time,
            'end time':
            self.end_time,
            'description':
            self.description
        }

    def with_instructors(self):
        return {
            'uid':
            self.uid,
            'title':
            self.title,
            'instructors': [{
                'uid': assignment.instructor.uid,
                'name': assignment.instructor.name,
                'email': assignment.instructor.email,
                'phone': assignment.instructor.phone,
                'assignment_uid': assignment.uid
            } for assignment in self.assignments],
            'days': ([day.capitalize() for day in self.days.split(',')]
                     if type(self.days) != list else self.days),
            'start time':
            self.start_time,
            'end time':
            self.end_time,
            'description':
            self.description
        }
Esempio n. 16
0
class Users(db.Model, UserMixin):
    __tablename__ = __user_users_tablename__
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64))
    login = db.Column(db.String(64), unique=True)
    #email =  db.Column(db.String(255))
    description = db.Column(db.String(255))
    avatar_url = db.Column(db.String(254))
    passHash = db.Column(db.String(64))
    preferences = db.Column(db.String(64))
    #sid = db.Column(db.String(64))
    #latest = db.Column(db.DateTime, ForeignKey(Online.id))
    user = None

    #admingroup_id = Column(db.Integer, ForeignKey(User.id), primary_key=True)
    admingroup = relationship(
        'AdminGroup',
        foreign_keys='AdminGroup.user_id',
        # we dont need delete all->readd
        cascade='save-update, delete-orphan',
        backref=__user_users_tablename__,
        lazy='joined')
    #admingroup = relationship('AdminGroup', foreign_keys='AdminGroup.user_id', backref=__user_users_tablename__, lazy='dynamic')
    #admingroup = relationship('AdminGroup', foreign_keys='AdminGroup.user_id', backref=__user_users_tablename__, lazy='joined', collection_class=mapped_collection(lambda user: {'admingroup': user.__dict__}))
    online = relationship('Online',
                          foreign_keys='Online.user_id',
                          backref=__user_users_tablename__,
                          lazy='joined')
    online_id = relationship('Online',
                             cascade='all,delete,delete-orphan',
                             backref='User')
    admingroupStr = None
    #comment_id = Column(db.Integer, ForeignKey(CustomerBusinessComments.id))
    isdel = db.Column(db.Boolean, default=False)

    # LEFT OUTER JOIN
    #admingroup_obj = relationship('AdminGroup', lazy='joined', cascade='all')

    def __init__(self):
        pass

    def __repr__(self):
        return '<Name %r>' % self.name

    def get_id(self):
        return self.id

    def is_active(self):
        return True

    def is_authenticated(self):
        """
        Returns `True`. User is always authenticated. Herp Derp.
        """
        return True

    def is_anonymous(self):
        """
        Returns `False`. There are no Anonymous here.
        """
        return False

    def get_id(self):
        """
        Assuming that the user object has an `id` attribute, this will take
        that and convert it to `unicode`.
        """
        try:
            #return unicode(self.id)
            return str(self.id).encode('utf-8')
        except AttributeError:
            raise NotImplementedError("No `id` attribute - override get_id")

    def __eq__(self, other):
        """
        Checks the equality of two `UserMixin` objects using `get_id`.
        """
        if isinstance(other, UserMixin):
            return self.get_id() == other.get_id()
        return NotImplemented

    def __ne__(self, other):
        """
        Checks the inequality of two `UserMixin` objects using `get_id`.
        """
        equal = self.__eq__(other)
        if equal is NotImplemented:
            return NotImplemented
        return not equal

    #@property
    #def value(self):
    #    return self.admingroup and self.admingroup.name

    def generate_auth_token(self, expiration=600):
        s = Serializer(app.config['SECRET_KEY'], expires_in=expiration)
        #print("s=", s)
        return s.dumps({'id': self.id})

    @staticmethod
    def verify_auth_token(token):
        s = Serializer(app.config['SECRET_KEY'])
        logger.debug('verify_auth_token s: %s', s)
        try:
            data = s.loads(token)
        except SignatureExpired:
            return None  # valid token, but expired
        except BadSignature:
            return None  # invalid token

        user = Users.query.get(data['id'])
        return user
Esempio n. 17
0
class Instructor(BaseModel, db.Model):
    # Main model
    __tablename__ = 'instructor'

    # Autoincrementing, unique primary key
    uid = db.Column(db.Integer(), primary_key=True)

    # Instructor data
    name = db.Column(db.String(120), nullable=False)
    email = db.Column(db.String(120), nullable=False, unique=True)
    phone = db.Column(db.String(129), nullable=False)
    bio = db.Column(db.String(1000), nullable=False)

    # Relationships
    assignments = db.relationship('Assignment',
                                  back_populates='instructor',
                                  cascade='all,delete,delete-orphan')
    grades = db.relationship('Grade',
                             back_populates='instructor',
                             cascade='all,delete,delete-orphan')

    # Methods
    def __init__(self, name=None, email=None, phone=None, bio=None):
        self.name = name
        self.email = email
        self.phone = phone
        self.bio = bio

# Return full details.

    def full(self):
        return {
            'uid': self.uid,
            'name': self.name,
            'email': self.email,
            'phone': self.phone,
            'bio': self.bio
        }

    # Return truncated details.
    def short(self):
        return {'uid': self.uid, 'name': self.name, 'bio': self.bio}

    # Return full details with assignments.
    def with_assignments(self):
        return {
            'uid':
            self.uid,
            'name':
            self.name,
            'email':
            self.email,
            'phone':
            self.phone,
            'bio':
            self.bio,
            'assignments': [{
                'uid': assignment.uid,
                'title': assignment.course.title,
                'days': assignment.course.days,
                'start_time': assignment.course.start_time,
                'end_time': assignment.course.end_time
            } for assignment in self.assignments]
        }
Esempio n. 18
0
class CustomerBusinessDetails(db.Model):
    __tablename__ = __customer_business_details_tablename__
    id = db.Column(db.Integer, primary_key=True)
    business_id = db.Column(db.Integer,
                            ForeignKey(CustomerBusinesses.id),
                            primary_key=True)

    meta = db.relationship(
        CustomerBusinesses,
        backref='CustomerBusinesses.id',
        primaryjoin=
        'CustomerBusinesses.id==CustomerBusinessDetails.business_id',
        lazy='joined',
        uselist=False)

    #business_id = relationship('CustomerBusinesses',
    #        foreign_keys='CustomerBusinessDetails.business_id',
    #        backref=__customer_businesses_tablename__, lazy='joined')
    #name = relationship('CustomerBusinesses',
    #        foreign_keys='CustomerBusinessDetails.name',
    #        backref=__customer_businesses_tablename__, lazy='joined')
    #cat = relationship('CustomerBusinesses',
    #        foreign_keys='CustomerBusinessDetails.cat',
    #        backref=__customer_businesses_tablename__, lazy='joined')
    #lat = relationship('CustomerBusinesses',
    #        foreign_keys='CustomerBusinessDetails.lat',
    #        backref=__customer_businesses_tablename__, lazy='joined')
    #long = relationship('CustomerBusinesses',
    #        foreign_keys='CustomerBusinessDetails.long',
    #        backref=__customer_businesses_tablename__, lazy='joined')
    #deal = relationship('CustomerBusinesses',
    #        foreign_keys='CustomerBusinessDetails.deal',
    #        backref=__customer_businesses_tablename__, lazy='joined')
    #image_url = relationship('CustomerBusinesses',
    #        foreign_keys='CustomerBusinessDetails.image_url',
    #        backref=__customer_businesses_tablename__, lazy='joined')

    open = db.Column(db.String(4))
    close = db.Column(db.String(4))
    dist = db.Column(db.Integer)
    address = db.Column(db.String(254))
    meals = db.Column(db.String(253))
    features = db.Column(db.String(254))

    #like_users = relationship('Users', backref="CustomerBusinessDetails")
    #like_users = db.relationship('Users', backref='Users.like_id', primaryjoin='CustomerBusinesses.id==Users.like_id', lazy='joined')

    #likes_user_avatar = relationship('Users',
    #        foreign_keys='Users.avatar',
    #        backref=__user_users_tablename__, lazy='joined')

    #comments = db.relationship('CustomerBusinessComments',
    #        backref='CustomerBusinessComments.business_id',
    #        primaryjoin='CustomerBusinessComments.business_id==CustomerBusinessDetails.business_id', lazy='joined')
    #rates = relationship('CustomerBusinessRates',
    #        backref='CustomerBusinessDetails',
    #        secondary=lambda: CustomerBusinessDetailsRates.__table__)
    # directly access secondary entities,
    # such as group -> mapping -> objs
    comments = relationship(
        'CustomerBusinessComments',
        backref='CustomerBusinessDetails',
        secondary=lambda: CustomerBusinessDetailsComments.__table__)

    #business_id = association_proxy('businesses', 'id')
    #business_name = association_proxy('businesses', 'name')

    ## auto update mapping table
    #mapping = relationship('CustomerBusinessDetailsComments',
    #        backref='CustomerBusinessDetails',
    #        cascade='save-update, delete, delete-orphan, merge')

    mtime = db.Column(DateTime, default=datetime.utcnow())
    ctime = db.Column(DateTime, default=datetime.utcnow())
    isdel = db.Column(db.Boolean, default=False)

    def __init__(self):
        pass

    def __repr__(self):
        return '<Name %r>' % self.__tablename__