class EthContact(db.Model): __tablename__ = 'eth_contact' address = db.Column(db.String(42), primary_key=True) name = db.Column(db.String(255), index=True) desc = db.Column(db.String(255)) email = db.Column(db.String(255), index=True) phone = db.Column(db.String(255), index=True) eth_balance = db.Column(db.Float(), default=0) ogn_balance = db.Column(db.Float(), default=0) dai_balance = db.Column(db.Float(), default=0) investor = db.Column(db.Boolean()) presale_interest = db.Column(db.Boolean()) dapp_user = db.Column(db.Boolean()) employee = db.Column(db.Boolean()) exchange = db.Column(db.Boolean()) company_wallet = db.Column(db.Boolean()) investor_airdrop = db.Column(db.Boolean()) token_count = db.Column(db.Integer()) transaction_count = db.Column(db.Integer()) tokens = db.Column(JSONB) last_updated = db.Column(db.DateTime(), server_default=db.func.now(), onupdate=db.func.now()) created_at = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) country_code = db.Column(db.String(2)) def __str__(self): return '%s' % (self.name)
class EmailList(db.Model): __tablename__ = 'email_list' email = db.Column(db.String(255), primary_key=True, autoincrement=False) unsubscribed = db.Column(db.Boolean()) created_at = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) def __str__(self): return '%s' % (self.email)
class Todo(db.Model): id = db.Column("id", db.Integer, primary_key=True ) description = db.Column("description", db.String(100)) complete = db.Column("complete", db.Boolean()) email = db.Column("email", db.String(100)) def __init__(self, description, complete, email): self.description = description self.complete = complete self.email = email
class User(db.Model): login = db.Column(db.String(8), primary_key=True) email = db.Column(db.String(100), default="") tel = db.Column(db.String(100), default="") is_admin = db.Column(db.Boolean(), default=False) date_join = db.Column(db.DateTime()) last_login = db.Column(db.DateTime()) active = db.Column(db.Boolean(), default=True) collections = db.relationship('Collection', backref='user', lazy='dynamic') def __init__(self, login): self.login = login self.email = "*****@*****.**" % login self.date_join = datetime.datetime.now() self.last_login = datetime.datetime.now() def __repr__(self): return '<User %r>' % self.login
class EmailList(db.Model): __tablename__ = 'email_list' email = db.Column(db.String(255), primary_key=True, autoincrement=False) unsubscribed = db.Column(db.Boolean()) created_at = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) ip_addr = db.Column(db.String(100)) country_code = db.Column(db.String(2)) first_name = db.Column(db.String(255)) last_name = db.Column(db.String(255)) # sendgrid feedback loop bounced = db.Column(db.Boolean()) spam_report = db.Column(db.Boolean()) blocked = db.Column(db.Boolean()) invalid = db.Column(db.Boolean()) def __str__(self): return '%s' % (self.email)
class Task(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(80)) description = db.Column(db.String(80)) done = db.Column(db.Boolean()) def __init__(self, title, description='', done=''): self.title = title self.description = description self.done = done
class Identity(db.Model): eth_address = db.Column(db.Numeric(precision=50, scale=0), primary_key=True) phone = db.Column(db.String(20), index=True) verified = db.Column(db.Boolean()) created_at = db.Column(db.DateTime(timezone=True), server_default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
class User(db.Model, UserMixin): id = db.Column(db.Integer(), primary_key=True) api_key = db.Column(db.String(255), unique=True) name = db.Column(db.String(50)) active = db.Column(db.Boolean()) roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic')) jenkins_key = db.Column(db.String(255)) rundeck_key = db.Column(db.String(255))
class SubjectTag(db.Model, Serialize): __tablename__ = 'tag' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100)) description = db.Column(db.TEXT) count = db.Column(db.Integer) sentiment = db.Column(db.TEXT) trending = db.Column(db.TEXT) created = db.Column(db.Integer) updated = db.Column(db.Integer) comment = db.Column(db.Boolean())
class User(db.Model): id = db.Column("id", db.Integer, primary_key=True) name = db.Column("name", db.String(100)) email = db.Column("email", db.String(100)) password = db.Column("password", db.String(100)) admin = db.Column("admin", db.Boolean()) def __init__(self, name, email, password, admin): self.name = name self.email = email self.password = password self.admin = admin
class User(db.Model, UserMixin): """ User model building off of flask-registration """ __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(60)) password = db.Column(db.String()) last_login_at = db.Column(db.DateTime()) current_login_at = db.Column(db.DateTime()) last_login_ip = db.Column(db.String()) current_login_ip = db.Column(db.String()) login_count = db.Column(db.Integer()) created = db.Column(db.Date()) company = db.Column(db.String) apis = db.relationship('API', secondary=apis, backref=db.backref('apis', lazy='dynamic')) active = db.Column(db.Boolean()) confirmed_at = db.Column(db.DateTime()) roles = db.relationship('Role', secondary=roles_users, backref=db.backref('user')) onboarded = db.Column(db.Boolean(), default=False) returning_visitors = db.relationship('GoogleAnalyticsReturningVisitors', secondary=returning_visitors, backref=db.backref('user')) signups = db.relationship('GoogleAnalyticsSignups', secondary=signups, backref=db.backref('user')) def __repr__(self): return '<User %s>' % self.email def as_dict(self): return { 'email': self.email, 'roles': [str(role) for role in self.roles], 'onboarded': self.onboarded }
class Supplier(db.Model): __tablename__ = 'suppliers' id = db.Column(db.String(36), default=lambda: str(uuid4()), primary_key=True) active = db.Column(db.Boolean(), default=True) company_name = db.Column(db.String(100), nullable=False) cnpj = db.Column(db.String(14), unique=True, nullable=False) trading_name = db.Column(db.String(100), nullable=False) phone = db.Column(db.String(11), nullable=False) email = db.Column(db.String(100), nullable=False) address = db.relationship(Address) address_id = db.Column(db.String(36), db.ForeignKey(Address.id), nullable=False) category = db.relationship(Category) category_id = db.Column(db.String(36), db.ForeignKey(Category.id), nullable=False) on_create = db.Column(db.DateTime, default=datetime.datetime.now) on_update = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now) def serialize(self) -> Dict[str, Union[bool, str]]: return { 'id': self.id, 'active': self.active, 'company_name': self.company_name, 'cnpj': self.cnpj, 'trading_name': self.trading_name, 'phone': self.phone, 'email': self.email, 'address_id': self.address_id, 'category_id': self.category_id, 'on_create': self.on_create, 'on_update': self.on_update } def serialize_summed_version(self) -> Dict[str, Union[bool, str]]: return { 'id': self.id, 'trading_name': self.trading_name, 'on_create': self.on_create, 'on_update': self.on_update } def __init__(self, **kwargs): super().__init__(**kwargs) validating_empty_fields(['description'], **kwargs) validating_if_field_is_not_str(['active', 'on_create', 'on_update'], **kwargs) validating_if_field_is_bool(['active'], **kwargs) validating_if_field_is_numeric(['phone', 'cnpj'], **kwargs) validating_if_field_is_alpha(['company_name', 'trading_name'], **kwargs) validating_email(**kwargs) validating_maximum_size_of_fields(**kwargs) validating_minimum_size_of_fields(**kwargs) validating_equal_size_of_fields(**kwargs)
class User(UserMixin, PkModel): """A user of the app.""" __tablename__ = "users" username = Column(db.String(80), unique=True, nullable=False) email = Column(db.String(80), unique=True, nullable=False) #: The hashed password password = Column(db.LargeBinary(128), nullable=True) created_at = Column(db.DateTime, nullable=False, default=dt.datetime.utcnow) first_name = Column(db.String(30), nullable=True) last_name = Column(db.String(30), nullable=True) active = Column(db.Boolean(), default=False) is_admin = Column(db.Boolean(), default=False) def __init__(self, username, email, password=None, **kwargs): """Create instance.""" super().__init__(username=username, email=email, **kwargs) if password: self.set_password(password) else: self.password = None def set_password(self, password): """Set password.""" self.password = bcrypt.generate_password_hash(password) def check_password(self, value): """Check password.""" return bcrypt.check_password_hash(self.password, value) @property def full_name(self): """Full user name.""" return f"{self.first_name} {self.last_name}" def __repr__(self): """Represent instance as a unique string.""" return f"<User({self.username!r})>"
class Note(db.Model): id = db.Column("id", db.Integer, primary_key=True) title = db.Column("title", db.String(200)) text = db.Column("text", db.String(100)) date = db.Column("date", db.String(50)) last_modified = db.Column("last_modified", db.String(50)) is_favorite = db.Column("is_favorite", db.Boolean()) is_published = db.Column("is_published", db.Boolean()) # can create a foreign key; referencing the id variable in the User class, so that is why it is lowercase u user_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False) comments = db.relationship("Comment", backref="note", cascade="all, delete-orphan", lazy=True) def __init__(self, title, text, date, user_id): self.title = title self.text = text self.date = date self.last_modified = date self.user_id = user_id self.is_favorite = False self.is_published = False
class User(db.Model, UserMixin): """Registered users of the sight, copied from the setup found in the flask admin auth example here: https://github.com/flask-admin/flask-admin/blob/master/examples/auth/app.py """ id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(255), unique=True, primary_key=True) password = db.Column(db.String(255)) active = db.Column(db.Boolean()) confirmed_at = db.Column(db.DateTime()) roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic'))
class Listing(db.Model): contract_address = db.Column(db.String(255), primary_key=True) owner_address = db.Column(db.String(255), index=True) registry_id = db.Column(db.Integer()) price = db.Column(db.Integer()) units = db.Column(db.Integer()) expired = db.Column(db.Boolean()) ipfs_hash = db.Column(db.String(255)) ipfs_data = db.Column(db.JSON()) created_at = db.Column(db.DateTime(timezone=True)) expires_at = db.Column(db.DateTime(timezone=True))
class User(db.Model, UserMixin): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(255), unique=True) username = db.Column(db.String(255)) password = db.Column(db.String(255)) last_login_at = db.Column(db.DateTime()) current_login_at = db.Column(db.DateTime()) last_login_ip = db.Column(db.String(100)) current_login_ip = db.Column(db.String(100)) login_count = db.Column(db.Integer) active = db.Column(db.Boolean()) fs_uniquifier = db.Column(db.String(255), unique=True, nullable=False) confirmed_at = db.Column(db.DateTime()) roles = db.relationship('Role', secondary='roles_users', backref=db.backref('users', lazy='dynamic'))
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) first_name = db.Column(db.String(255)) last_name = db.Column(db.String(255)) email = db.Column(db.String(255), unique=True) password = db.Column(db.String(255)) active = db.Column(db.Boolean()) confirmed_at = db.Column(db.DateTime(), default=datetime.datetime.now) roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic')) def __str__(self): return self.email
class Presale(db.Model): __tablename__ = 'presale' id = db.Column(db.Integer, primary_key=True) full_name = db.Column(db.String(255)) email = db.Column(db.String(255)) accredited = db.Column(db.Boolean()) entity_type = db.Column(db.String(255)) desired_allocation = db.Column(db.String(255)) desired_allocation_currency = db.Column(db.String(3)) citizenship = db.Column(db.String(2)) sending_addr = db.Column(db.String(255)) note = db.Column(db.Text()) def __str__(self): return '%s' % (self.email)
class Comment(db.Model, Serialize): __tablename__ = 'comment' id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer) post_id = db.Column(db.Integer) parent = db.Column(db.Integer) children=db.Column(db.TEXT) visible = db.Column(db.Boolean()) text = db.Column(db.TEXT) tag = db.Column(db.TEXT) upvote = db.Column(db.Integer) downvote = db.Column(db.Integer) modifier = db.Column(db.Integer) toponym=db.Column(db.String(200)) created = db.Column(db.Integer) updated = db.Column(db.Integer)
class Post(db.Model, Serialize): __tablename__ = 'post' id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer) upvote = db.Column(db.Integer) downvote = db.Column(db.Integer) sentiment = db.Column(db.TEXT) modifier = db.Column(db.Integer) title = db.Column(db.String(140)) link = db.Column(db.String(2000)) text = db.Column(db.TEXT) tags = db.Column(db.TEXT) toponym=db.Column(db.String(200)) created = db.Column(db.Integer) updated = db.Column(db.Integer) visible = db.Column(db.Boolean())
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(255), unique=True) password = db.Column(db.String(255)) active = db.Column(db.Boolean()) confirmed_at = db.Column(db.DateTime()) roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic')) last_login_at = db.Column(db.DateTime()) current_login_at = db.Column(db.DateTime()) last_login_ip = db.Column(db.String(255)) current_login_ip = db.Column(db.String(255)) login_count = db.Column(db.Integer) def __repr__(self): return '<models.User[email=%s]>' % self.email
class TokenTransaction(db.Model): __tablename__ = 'token_transaction' tx_hash = db.Column(db.String(66), primary_key=True) from_address = db.Column(db.String(42), index=True) to_address = db.Column(db.String(42), index=True) amount = db.Column(db.Float()) block_number = db.Column(db.Integer()) notification_sent = db.Column(db.Boolean()) timestamp = db.Column(db.DateTime(timezone=True)) last_updated = db.Column(db.DateTime(), server_default=db.func.now(), onupdate=db.func.now()) created_at = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) def __str__(self): return '%s' % (self.name)
class Person(db.Model): id = db.Column(db.Integer, primary_key=True) first_name = db.Column(db.String(60)) middle_name = db.Column(db.String(60), nullable=True) last_name = db.Column(db.String(60)) active = db.Column(db.Boolean(), default=True, nullable=False) date_added = db.Column(db.DateTime, default=func.now()) def __repr__(self): return '<Person ID=%s, %s %s %s>' % (self.id, self.first_name, self.middle_name, self.last_name) def __str__(self): return '%s, %s %s (%s)' % (self.last_name, self.first_name, self.middle_name, self.id)
class Product(db.Model): __tablename__ = 'products' id = db.Column(db.String(36), primary_key=True, default=lambda: str(uuid4())) name = db.Column(db.String(36), unique=True) cost_values = db.Column(db.Float(20)) unit_per_box = db.Column(db.Numeric(6)) weight_per_unit = db.Column(db.String(10)) measure_unit = db.Column(db.String(10), nullable=False) shelf_life = db.Column(db.String(10)) sku = db.Column(db.String(10), unique=True) description = db.Column(db.String(70)) created_at = db.Column(db.DateTime(timezone=True), default=func.now()) updated_at = db.Column(db.DateTime(timezone=True), onupdate=func.now()) deleted_at = db.Column(db.DateTime(timezone=True), default=None) is_active = db.Column(db.Boolean(10), default=True) id_product_line = db.Column( db.String(36), db.ForeignKey('product_line.id') ) def __init__(self, **kwargs): super().__init__(**kwargs) for keys in kwargs: if kwargs[keys] is None or kwargs[keys] == '': raise NullValueException(f'The field {keys} can not be null') def serialize(self): return { "id": self.id, "name": self.name, "cost_values": self.cost_values, "unit_per_box": int(self.unit_per_box), "weight_per_unit": self.weight_per_unit, 'measure_unit': self.measure_unit, "shelf_life": self.shelf_life, "sku": self.sku, "description": self.description, "id_product_line": self.id_product_line, "is_active": self.is_active, "created_at": self.created_at, "updated_at": self.updated_at, "deleted_at": self.deleted_at }
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String, unique=True, nullable=False) email = db.Column(db.String(100), unique=True, nullable=False) firstname = db.Column(db.String(80), nullable=False) lastname = db.Column(db.String(80), nullable=False) password = db.Column(db.String(300), nullable=False) active = db.Column(db.Boolean(), nullable=False) confirmed_at = db.Column(db.DateTime()) roles = db.relationship('Role', secondary=roles_users, backref=db.backref('users', lazy='dynamic')) submissions = db.relationship('Submission', backref='user', lazy='dynamic') def __repr__(self): return self.username def __unicode__(self): return self.username
class UserModel(UserMixin, db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(255), unique=True, nullable=False) email = db.Column(db.String(255), unique=True, nullable=False) _password = db.Column('password', db.String(255), nullable=False) active = db.Column(db.Boolean(), default=True) createTime = db.Column(db.DateTime, nullable=False, default=datetime.now) updateTime = db.Column(db.DateTime, nullable=False, default=datetime.now, onupdate=datetime.now) def __init__(self, email): self.email = email def _get_password(self): return self._password def _set_password(self, password): if password: password = password.strip() self._password = generate_password_hash(password) password_descriptor = property(_get_password, _set_password) password = synonym('_password', descriptor=password_descriptor) # フォームで送信されたパスワードの検証 def check_password(self, password): password = password.strip() if not password: return False return check_password_hash(self.password, password) # 認証処理 @classmethod def auth(cls, query, email, password): user = query(cls).filter(cls.email == email).first() if user is None: return None, False return user, user.check_password(password)
class Address(db.Model): __tablename__ = "addresses" id = db.Column(db.String(36), default=lambda: str(uuid4()), primary_key=True) active = db.Column(db.Boolean(), default=True) street = db.Column(db.String(100), nullable=False) number = db.Column(db.String(50), nullable=False) complement = db.Column(db.String(300)) zip_code = db.Column(db.String(11), nullable=False) city = db.Column(db.String(50), nullable=False) state = db.Column(db.String(50), nullable=False) on_create = db.Column(db.DateTime, default=datetime.datetime.now) on_update = db.Column(db.DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now) def serialize(self) -> Dict[str, Union[bool, str]]: return { 'id': self.id, 'active': self.active, 'street': self.street, 'number': self.number, 'complement': self.complement, 'zip_code': self.zip_code, 'city': self.city, 'state': self.state, 'on_create': self.on_create, 'on_update': self.on_update } def __init__(self, **kwargs): super().__init__(**kwargs) validating_empty_fields(['complement'], **kwargs) validating_if_field_is_not_str(['active', 'on_create', 'on_update'], **kwargs) validating_if_field_is_bool(['active'], **kwargs) validating_if_field_is_alpha_numeric(['street'], **kwargs) validating_if_field_is_numeric(['number', 'zip_code'], **kwargs) validating_if_field_is_alpha(['city', 'state'], **kwargs) validating_size_of_fields(**kwargs)
class Printer(db.Model): __tablename__ = "printers" id = db.Column(db.Integer, primary_key=True) vendor = db.Column(db.String(100), nullable=True, unique=True) product = db.Column(db.String(100), unique=True) in_ep = db.Column(db.Integer, nullable=True) out_ep = db.Column(db.Integer, nullable=True) active = db.Column(db.Boolean()) langu = db.Column(db.String(100)) value = db.Column(db.Integer) def __init__(self, vendor=" ", product=" ", in_ep=0, out_ep=0, active=False, langu='en', value=1): self.vendor = vendor self.product = product self.in_ep = in_ep self.out_ep = out_ep self.active = active self.value = value
class Test(db.Model): __tablename__ = "tests" id = db.Column(db.Integer, primary_key=True) #test_name = db.Column(db.String(100)) answers = db.Column(db.PickleType()) status = db.Column(db.Boolean(), default=False) #email = db.Column(db.String(255)) no_questions = db.Column(db.Integer()) def __init__(self, kwargs): self.id = kwargs.get('id') #self.test_name = kwargs.get('test_name') self.answers = kwargs.get('answers') #self.email = kwargs.get('email') self.no_questions = kwargs.get('no_questions') self.status = kwargs.get('status') @classmethod def getAll(cls): return Test.query.all()