コード例 #1
0
class Event(db.Model):
    __tablename__ = 'event'
    id = db.Column(db.String, primary_key=True)
    name = db.Column(db.String, nullable=False)
    description = db.Column(db.String, nullable=False)
    start_time = db.Column(db.DateTime, nullable=False)
    user_id = db.Column(db.String, db.ForeignKey('user.id'))
コード例 #2
0
class Admin(db.Model):

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(50), nullable=False, unique=True)
    _salt = db.Column(db.String(255), nullable=False)
    _password = db.Column(db.String(255), nullable=False)

    def __str__(self):

        return "Admin: <id={1}, username={0}, password={2}, salt={3}>".format(
            self.username, self.id, self._password, self._salt)

    def __repr__(self):

        return "Admin: <id={1}, username={0}, password={2}, salt={3}>".format(
            self.username, self.id, self._password, self._salt)

    @property
    def password(self):

        return (self._salt, self._password)

    @password.setter
    def password(self, plain_password):

        self._salt, self._password = Utils.hash_password(plain_password)
コード例 #3
0
ファイル: amazon.py プロジェクト: davidmaignan/giftsmarts
class UserProduct(db.Model):
    __tablename__ = 'user_product'
    user_id = db.Column(db.String, db.ForeignKey('user.id'), primary_key=True)
    product_id = db.Column(db.String,
                           db.ForeignKey('product.id'),
                           primary_key=True)
    category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
    product = db.relationship("Product", back_populates="users")
    user = db.relationship("User", back_populates="products")
    category = db.relationship("Category", back_populates="user_products")
    active = db.Column(db.Boolean, default=True)
    wish_list = db.Column(db.Boolean, default=False)
コード例 #4
0
class FriendRelationship(db.Model):
    __tablename__ = 'friend_relationships'
    id = db.Column(db.Integer, primary_key=True)
    owner_id = db.Column(db.String, db.ForeignKey('user.id'))
    friend_id = db.Column(db.String, db.ForeignKey('user.id'))
    relation_type = db.Column(db.Integer,
                              db.ForeignKey('friend_relationship_type.id'),
                              nullable=True)
    active = db.Column(db.Boolean, default=True)
    relationship = db.relationship(FriendRelationshipType)
    from_owner = db.relationship(User,
                                 primaryjoin=(owner_id == User.id),
                                 backref='to_relations')
    to_friend = db.relationship(User,
                                primaryjoin=(friend_id == User.id),
                                backref='from_relations')
コード例 #5
0
class User(db.Model):
    __tablename__ = 'user'
    id = db.Column(db.String, primary_key=True)
    name = db.Column(db.String(255), nullable=False)
    profile_url = db.Column(db.String, nullable=False)
    access_token = db.Column(db.String, nullable=False)
    birthday = db.Column(db.Date, nullable=False)
    posts = db.relationship('Post', backref='user_post', lazy='dynamic')
    events = db.relationship('Event', backref='user_event', lazy='dynamic')
    to_friends = association_proxy('to_relations', 'to_friend')
    from_owners = association_proxy('from_relations', 'from_owner')
    categories = relationship("Category",
                              secondary=user_categories,
                              lazy='subquery')
    products = relationship("UserProduct",
                            back_populates="user",
                            lazy='subquery')
コード例 #6
0
ファイル: user.py プロジェクト: jaorr95/python-session-redis
class User(db.Model):

	id = db.Column(db.Integer, primary_key=True, autoincrement=True)
	name = db.Column(db.String(50), nullable=False)
	lastname = db.Column(db.String(50), nullable=False)
	email = db.Column(EmailType, nullable=False, unique=True)
	user_type = db.Column(db.Integer, nullable=False, default=2)
	_salt = db.Column(db.String(255), nullable=False)
	_password = db.Column(db.String(255), nullable=False)

	def __str__(self):

		return "User: <id={2}, name={0}, lastname={1}, email={3}>".format(self.name,
			self.lastname, self.id, self.email)

	def __repr__(self):

		return "User: <id={2}, name={0}, lastname={1}, email={3}>".format(self.name,
			self.lastname, self.id, self.email)

	@property
	def password(self):

		return (self._salt, self._password)

	@password.setter
	def password(self, plain_password):

		self._salt, self._password = Utils.hash_password(plain_password) 
コード例 #7
0
class Comment(db.Model):
    __tablename__ = 'comment'
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String, db.ForeignKey('user.id'))
    subject = db.Column(db.String, nullable=False)
    feedback = db.Column(db.String, nullable=False)
    created = db.Column(db.DateTime, default=db.func.now())
    is_contacted = db.Column(db.String, nullable=False)
コード例 #8
0
ファイル: amazon.py プロジェクト: davidmaignan/giftsmarts
class Product(db.Model):
    __tablename__ = 'product'
    id = db.Column(db.String, primary_key=True)
    users = db.relationship("UserProduct", back_populates="product")
コード例 #9
0
ファイル: post.py プロジェクト: davidmaignan/giftsmarts
class Post(db.Model):
    __tablename__ = 'post'
    id = db.Column(db.String, primary_key=True)
    story = db.Column(db.String, nullable=False)
    created = db.Column(db.DateTime, nullable=False)
    user_id = db.Column(db.String, db.ForeignKey('user.id'))
コード例 #10
0
ファイル: authtoken.py プロジェクト: davidmaignan/giftsmarts
class AuthToken(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    token = db.Column(db.String(128), unique=False, nullable=False)
    expiration = db.Column(db.DateTime,
                           default=(datetime.now() + timedelta(minutes=15)))
    user_id = db.Column(db.String, db.ForeignKey('user.id'))
コード例 #11
0
class Category(db.Model):
    __tablename__ = 'category'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255), nullable=False, unique=True)
    user_products = db.relationship("UserProduct", back_populates="category")
コード例 #12
0
from app.config.config import db
from sqlalchemy.orm.exc import NoResultFound

user_categories = db.Table(
    'user_categories', db.Column("user_id", db.String,
                                 db.ForeignKey("user.id")),
    db.Column("category_id", db.Integer, db.ForeignKey("category.id")))


class Category(db.Model):
    __tablename__ = 'category'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255), nullable=False, unique=True)
    user_products = db.relationship("UserProduct", back_populates="category")


class CategoryActions:
    model = Category

    @classmethod
    def filter(cls, user, **kwargs):
        if 'id' in kwargs and kwargs['id'] is not None:
            return cls.model.query.filter_by(id=kwargs['id']).all()
        else:
            return cls.model.query.all()

    @classmethod
    def find_all(cls):
        return cls.model.query.all()

    @classmethod
コード例 #13
0
class FriendRelationshipType(db.Model):
    __tablename__ = 'friend_relationship_type'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255), nullable=False, unique=True)
コード例 #14
0
ファイル: useremail.py プロジェクト: davidmaignan/giftsmarts
class UserEmail(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(256), unique=True, nullable=False)
    confirmed_at = db.Column(db.DateTime, default=datetime.now())
    user_id = db.Column(db.String, db.ForeignKey('user.id'))
コード例 #15
0
class UserProfile(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    firstname = db.Column(db.String(64), unique=True)
    lastname = db.Column(db.String(64), unique=True)