コード例 #1
0
class User(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    nickname = db.Column(db.String(100))
    phone = db.Column(db.String(120), unique=True)
    online = db.Column(db.Boolean)
    talks = db.relationship('Talk', secondary=talk_users_table)
    key = db.Column(db.String(36))

    def __str__(self):
        return self.phone or ''
コード例 #2
0
class Answered(db.Model):
    __tablename__ = 'answered'

    id = db.Column(db.Integer, primary_key=True)

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

    schema_id = db.Column(db.Integer, db.ForeignKey('schema.id'))

    posted = db.Column(db.DateTime)

    form = db.Column(db.JSON)
コード例 #3
0
class Person(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    nickname = db.Column(db.String(100))
    phone = db.Column(db.String(120), unique=True)
    online = db.Column(db.Boolean)
    talks = db.relationship('Talk', secondary=talk_people_table)

    def __str__(self):
        if self.online:
            return self.nickname + " (online)"
        return self.nickname + " (offline)"
コード例 #4
0
class Message(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    talk_id = db.Column(db.Integer, db.ForeignKey('talk.id'))
    sender_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    sender = db.relationship('User',
                             backref=db.backref('messages', lazy='dynamic'))
    date_start = db.Column(db.DateTime)
    message = db.Column(db.Text())

    def __str__(self):
        return self.message[:30] + ' ...'
コード例 #5
0
class PromoDetails(db.Model):
    __tablename__ = 'promo_details'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    promo_id = db.Column(db.Integer, db.ForeignKey('promos.id'))
    product_id = db.Column(db.Integer, db.ForeignKey('products.id'))
    quantity = db.Column(db.Integer, nullable=False)
    target_product_id = db.Column(db.Integer, nullable=False)

    def __init__(self, promo_id, product_id, quantity, target_product_id):
        self.promo_id = promo_id
        self.product_id = product_id
        self.quantity = quantity
        self.target_product_id = target_product_id
コード例 #6
0
ファイル: form_schema.py プロジェクト: MarcioOrdonez/web-form
class Schema(db.Model):
    __tablename__ = 'schema'

    id = db.Column(db.Integer,
                   primary_key=True)

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

    created = db.Column(db.DateTime)
    
    schema = db.Column(db.JSON)
コード例 #7
0
class User(UserMixin, db.Model):
    __tablename__ = 'user'

    id = db.Column(db.Integer,
                   primary_key=True)

    email = db.Column(db.String(80),
                      index=True,
                      unique=False,
                      nullable=False)
    
    password = db.Column(db.String(200),
                         primary_key=False,
                         unique=False,
                         nullable=False)
コード例 #8
0
class Product(db.Model):
    __tablename__ = "products"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    product_id = db.Column(db.String(255), unique=True, nullable=False)
    product_name = db.Column(db.String(255), nullable=False)
    price = db.Column(db.Float, nullable=False)

    #promo_details = db.relationship('PromoDetails', secondary='product_promo')

    def __init__(self, product_id, product_name, price):
        self.product_id = product_id
        self.product_name = product_name
        self.price = price

    def __repr__(self):
        return '<Product: id: {}'.format(self.product_id)
コード例 #9
0
class User(db.Model, BaseModel):
    __tablename__ = 'auth_user'

    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(120), unique=True)
    password = db.Column(db.String(120))

    def __init__(self, email=None, password=None):
        if email:
            self.email = email.lower()
        if password:
            self.set_password(password)

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

    def check_password(self, password):
        return check_password_hash(self.password, password)
コード例 #10
0
class Talk(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(120))
    date_start = db.Column(db.DateTime)
    users = db.relationship('User', secondary=talk_users_table)
    # messages = db.relationship('Message', secondary=talk_messages_table)
    admin_id = db.Column(db.Integer(), db.ForeignKey(User.id))
    is_group = db.Column(db.Boolean)
    messages = db.relationship('Message', backref='talk', lazy='dynamic')

    def __str__(self):
        # TODO: Retornar o nome do grupo ou o nome do outro integrante da conversa.
        return self.name

    def _is_group_admin(self, id, group):
        """
            Verifica se o usuário é admin do grupo
        :param user:
        :param group:
        :return: Retorna o objeto do grupo quando verdadeiro
            retorna False quando o usário nao é admin do grupo.
        """
        return True
コード例 #11
0
class Promo(db.Model):

    __tablename__ = "promos"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    promo_code = db.Column(db.String(255), nullable=False, unique=True)
    # Conditional Promo
    is_flat = db.Column(db.Boolean, nullable=False, default=True)
    # percentage(True) or amount(False)
    discount_type = db.Column(db.Boolean, nullable=False, default=True)
    amount = db.Column(db.Float, nullable=False, default=0)
    least_amount = db.Column(db.Float, nullable=False, default=0)
    valid = db.Column(db.Boolean, nullable=False, default=True)

    #promo_details = db.relationship('PromoDetails', secondary='promo_relations')

    def __init__(self, promo_code, is_flat, discount_type, amount,
                 least_amount):
        self.promo_code = promo_code
        self.is_flat = is_flat
        self.discount_type = discount_type
        self.amount = amount
        self.least_amount = least_amount
コード例 #12
0
# coding: utf-8
from src.server import app, db

talk_people_table = db.Table(
    'talk_people', db.Model.metadata,
    db.Column('talk_id', db.Integer, db.ForeignKey('talk.id')),
    db.Column('person_id', db.Integer, db.ForeignKey('person.id')))


class Person(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    nickname = db.Column(db.String(100))
    phone = db.Column(db.String(120), unique=True)
    online = db.Column(db.Boolean)
    talks = db.relationship('Talk', secondary=talk_people_table)

    def __str__(self):
        if self.online:
            return self.nickname + " (online)"
        return self.nickname + " (offline)"
コード例 #13
0
# coding: utf-8
from src.server import app, db

talk_users_table = db.Table(
    'talk_users', db.Model.metadata,
    db.Column('talk_id', db.Integer, db.ForeignKey('talk.id')),
    db.Column('user_id', db.Integer, db.ForeignKey('user.id'))
)


class User(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    nickname = db.Column(db.String(100))
    phone = db.Column(db.String(120), unique=True)
    online = db.Column(db.Boolean)
    talks = db.relationship('Talk', secondary=talk_users_table)
    key = db.Column(db.String(36))

    def __str__(self):
        return self.phone or ''