Beispiel #1
0
class Author(DeclarativeBase):
    __tablename__ = 'author'

    id = Field(Integer, primary_key=True)
    email = Field(Unicode(100), unique=True, index=True, json='email',
                  pattern=r'(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)', watermark='Email',
                  example="*****@*****.**")
    title = Field(Unicode(50), index=True, min_length=2, watermark='First Name')
    first_name = Field(Unicode(50), index=True, json='firstName', min_length=2, watermark='First Name')
    last_name = Field(Unicode(100), json='lastName', min_length=2, watermark='Last Name')
    phone = Field(
        Unicode(10), nullable=True, json='phone', min_length=10,
        pattern=r'\d{3}[-\.\s]??\d{3}[-\.\s]??\d{4}|\(\d{3}\)\s*\d{3}[-\.\s]??\d{4}|\d{3}[-\.\s]??\d{4}',
        watermark='Phone'
    )
    name = composite(FullName, first_name, last_name, readonly=True, json='fullName', protected=True)
    _password = Field('password', Unicode(128), index=True, json='password', protected=True, min_length=6)
    birth = Field(Date)
    weight = Field(Float(asdecimal=True))

    def _set_password(self, password):
        self._password = '******' % password

    def _get_password(self):  # pragma: no cover
        return self._password

    password = synonym('_password', descriptor=property(_get_password, _set_password), info=dict(protected=True))
Beispiel #2
0
class Member(ActivationMixin, ModifiedMixin, FilteringMixin, PaginationMixin,
             OrderingMixin, DeclarativeBase):
    __tablename__ = 'member'

    id = Field(Integer, primary_key=True)
    email = Field(
        Unicode(100),
        unique=True,
        index=True,
        json='email',
        pattern=r'(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)',
        message='Should be a valid email',
        example="*****@*****.**",
        label='Email',
        watermark='Please enter your email',
    )
    title = Field(Unicode(50),
                  index=True,
                  min_length=2,
                  watermark='Title',
                  label='Title')
    first_name = Field(Unicode(50),
                       index=True,
                       json='firstName',
                       min_length=2,
                       watermark='First Name',
                       label='First Name')
    last_name = Field(Unicode(100),
                      json='lastName',
                      min_length=2,
                      watermark='Last Name',
                      not_none=True,
                      label='Last Name')
    phone = Field(
        Unicode(10), nullable=True, json='phone', min_length=10,
        pattern= \
            r'\d{3}[-\.\s]??\d{3}[-\.\s]??\d{4}|\(\d{3}\)\s*\d{3}[-\.\s]??'
            r'\d{4}|\d{3}[-\.\s]??\d{4}',
        pattern_description='The phone number cannot contain alphabet',
        watermark='Phone',
        label='Phone'
    )
    name = composite(FullName,
                     first_name,
                     last_name,
                     readonly=True,
                     json='fullName',
                     label='Name')
    _password = Field('password',
                      Unicode(128),
                      index=True,
                      json='password',
                      protected=True,
                      min_length=6,
                      label='Password')
    birth = Field(Date)
    weight = Field(Float(asdecimal=True),
                   default=50,
                   python_type=(float, '999 Float required'),
                   label='Weight')
    _keywords = relationship('Keyword',
                             secondary='member_keywords',
                             protected=False)
    keywords = association_proxy('_keywords',
                                 'keyword',
                                 creator=lambda k: Keyword(keyword=k))
    visible = Field(Boolean, nullable=True)
    last_login_time = Field(DateTime, json='lastLoginTime')
    books = relationship('Book', protected=False)

    def _set_password(self, password):
        self._password = '******' % password

    def _get_password(self):  # pragma: no cover
        return self._password

    password = synonym('_password',
                       descriptor=property(_get_password, _set_password),
                       protected=True)

    _avatar = Field('avatar', Unicode(255), nullable=True, protected=True)

    def _set_avatar(self, avatar):  # pragma: no cover
        self._avatar = 'avatar:%s' % avatar

    def _get_avatar(self):  # pragma: no cover
        return self._avatar

    avatar = synonym('_avatar',
                     descriptor=property(_get_avatar, _set_avatar),
                     protected=False,
                     json='avatarImage')
Beispiel #3
0
class Member(ActivationMixin, ModifiedMixin, FilteringMixin, PaginationMixin,
             OrderingMixin, DeclarativeBase):
    __tablename__ = 'member'

    id = Field(Integer, primary_key=True)
    email = Field(
        Unicode(100),
        unique=True,
        index=True,
        json='email',
        pattern=r'(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)',
        watermark='Email',
        example="*****@*****.**",
        message='Invalid email address, please be accurate!',
        icon='email.svg')
    title = Field(Unicode(50),
                  index=True,
                  min_length=2,
                  watermark='First Name')
    first_name = Field(Unicode(50),
                       index=True,
                       json='firstName',
                       min_length=2,
                       watermark='First Name')
    last_name = Field(Unicode(100),
                      json='lastName',
                      min_length=2,
                      watermark='Last Name')
    phone = Field(
        Unicode(10),
        nullable=True,
        json='phone',
        min_length=10,
        pattern=
        r'\d{3}[-\.\s]??\d{3}[-\.\s]??\d{4}|\(\d{3}\)\s*\d{3}[-\.\s]??\d{4}|\d{3}[-\.\s]??\d{4}',
        watermark='Phone')
    name = composite(FullName,
                     first_name,
                     last_name,
                     readonly=True,
                     json='fullName')
    _password = Field('password',
                      Unicode(128),
                      index=True,
                      json='password',
                      protected=True,
                      min_length=6)
    birth = Field(Date)
    weight = Field(Float(asdecimal=True), default=50)
    _keywords = relationship('Keyword', secondary='member_keywords')
    keywords = association_proxy('_keywords',
                                 'keyword',
                                 creator=lambda k: Keyword(keyword=k))
    visible = Field(Boolean, nullable=True)
    last_login_time = Field(DateTime, json='lastLoginTime')
    books = relationship('Book')

    def _set_password(self, password):
        self._password = '******' % password

    def _get_password(self):  # pragma: no cover
        return self._password

    password = synonym('_password',
                       descriptor=property(_get_password, _set_password),
                       info=dict(protected=True))