コード例 #1
0
ファイル: models.py プロジェクト: merissab44/Grocery
class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), nullable=False)
    password = db.Column(db.String(80), nullable=False)
    shopping_list_items = db.relationship('GroceryItem',
                                          secondary='shopping_list_table',
                                          back_populates='users_shopping_list')
コード例 #2
0
class User(UserMixin, db.Model):
    '''User model'''
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), nullable=False)
    password = db.Column(db.String(150), nullable=False)
    items = db.relationship('GroceryItem',
                            secondary='shopping_cart',
                            back_populates='users')
コード例 #3
0
class User(db.Model, UserMixin):
    """User Item"""
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), nullable=False)
    password = db.Column(db.String(80), nullable=False)
    created_by_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    created_by = db.relationship('User')
    shopping_list_items = db.relationship('GroceryItem', secondary='shopping_list', back_populates='user_items')
コード例 #4
0
class User(db.Model, UserMixin):
    """User model."""
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), nullable=False)
    password = db.Column(db.String(256), nullable=False)
    shopping_list_items = db.relationship(
        'GroceryItem', secondary='user_groceryitem_association')
コード例 #5
0
ファイル: models.py プロジェクト: RogueNPC/BEW-1.2-Auth-Work
class GroceryStore(db.Model):
    """Grocery Store model."""
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(80), nullable=False)
    address = db.Column(db.String(200), nullable=False)
    items = db.relationship('GroceryItem', back_populates='store')
    created_by_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    created_by = db.relationship('User')
コード例 #6
0
ファイル: models.py プロジェクト: RogueNPC/BEW-1.2-Auth-Work
class User(db.Model, UserMixin):
    """User model"""
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), nullable=False, unique=True)
    password = db.Column(db.String(200), nullable=False)
    shopping_list_items = db.relationship('GroceryItem',
                                          secondary='user_item',
                                          back_populates='created_by')
コード例 #7
0
class User(UserMixin, db.Model):
    """ User Model """
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), nullable=False, unique=True)
    password = db.Column(db.String(200), nullable=False)

    shopping_list_items = db.relationship("GroceryItem",
                                          secondary="shopping_list")
コード例 #8
0
ファイル: models.py プロジェクト: sree-chikati/grocery-store
class User(db.Model, UserMixin):
    """User model."""
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(50), nullable=False)
    password = db.Column(db.String(150), nullable=False)
    shopping_list_items = db.relationship('GroceryItem', secondary='shopping_list', back_populates = 'shopping_list')
    def __str__(self):
        return f'{self.username}'
コード例 #9
0
class GroceryStore(db.Model):
    """Grocery Store model."""
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(80), nullable=False)
    address = db.Column(db.String(200), nullable=False)
    items = db.relationship('GroceryItem', back_populates='store')

    def __str__(self):
        return str(self.title)
コード例 #10
0
ファイル: models.py プロジェクト: Kou-kun42/BEW-1.2-Forms
class User(db.Model, UserMixin):
    """User model."""
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(42), nullable=False)
    password = db.Column(db.String(80), nullable=False)
    shopping_list_items = db.relationship(
        "GroceryItem",
        secondary="shopping_list",
        back_populates="shopping_lists"
    )
コード例 #11
0
ファイル: models.py プロジェクト: lotsofluck/GroceryStore
class GroceryStore(db.Model):
    """Grocery Store model."""
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(80), nullable=False)
    address = db.Column(db.String(200), nullable=False)
    items = db.relationship('GroceryItem', back_populates='store')
    created_by = db.relationship("User")
    created_by_id = db.Column(db.Integer, db.ForeignKey("user.id"))

    def __str__(self):
        return f"{self.title}"
コード例 #12
0
class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), nullable=False, unique=True)
    password = db.Column(db.String(200), nullable=False)

    shopping_list_items = db.relationship('GroceryItem',
                                          secondary='shopping_list',
                                          back_populates='shopping_list_user')

    def __repr__(self):
        return f'<User: {self.username}>'
コード例 #13
0
class User(UserMixin, db.Model):
    """User model."""
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), nullable=False, unique=True)
    password = db.Column(db.String(200), nullable=False)
    # Add many-to-many relationship between User and GroceryItem
    shopping_list_items = db.relationship(
        'GroceryItem', secondary='shopping_list', back_populates='users_who_shopped')

    # Display username for created_by credits
    def __repr__(self):
        return f'<User: {self.username}>'
コード例 #14
0
class GroceryStore(db.Model):
    """Grocery Store model."""
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(80), nullable=False)
    address = db.Column(db.String(200), nullable=False)
    items = db.relationship('GroceryItem', back_populates='store')

    # Include string representations for the drop-down menu
    def __str__(self):
        return f'<Grocery Store: {self.title}>'

    def __repr__(self):
        return f'<Grocery Store: {self.title}>'
コード例 #15
0
class User(UserMixin, db.Model):
    """Grocery Store model."""
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(50), nullable=False)
    password = db.Column(db.String(50), nullable=False)
    cart_items = db.relationship('GroceryItem',
                                 secondary='shopping_cart',
                                 back_populates='users_cart')

    def __str__(self):
        return f'{self.username}'

    def __repr__(self):
        return f'{self.username}'
コード例 #16
0
class GroceryStore(db.Model):
    """Grocery Store model."""
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(80), nullable=False)
    address = db.Column(db.String(200), nullable=False)
    items = db.relationship('GroceryItem', back_populates='store')
    # Add created_by field to see the user who added the store
    created_by_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    created_by = db.relationship('User')

    # Include string representations for the drop-down menu
    def __str__(self):
        return f'<Grocery Store: {self.title}>'

    def __repr__(self):
        return f'<Grocery Store: {self.title}>'
コード例 #17
0
ファイル: models.py プロジェクト: lotsofluck/GroceryStore
class User(db.Model, UserMixin):
    """User Model"""
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(50), nullable=False)
    password = db.Column(db.String(50), nullable=False)
    shopping_list_items = db.relationship(
        "GroceryItem",
        secondary="shopping_list_table",
        back_populates="user_shopping_list",
    )

    shopping_list_table = db.Table(
        "shopping_list_table",
        db.Column("grocery_item", db.Integer,
                  db.ForeignKey("grocery_item.id")),
        db.Column("user", db.Integer, db.ForeignKey("user.id")),
    )
コード例 #18
0
class GroceryItem(db.Model):
    """Grocery Item model."""
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    price = db.Column(db.Float(precision=2), nullable=False)
    category = db.Column(db.Enum(ItemCategory), default=ItemCategory.OTHER)
    photo_url = db.Column(URLType)
    store_id = db.Column(db.Integer,
                         db.ForeignKey('grocery_store.id'),
                         nullable=False)
    store = db.relationship('GroceryStore', back_populates='items')
コード例 #19
0
class GroceryItem(db.Model):
    """Grocery Item model."""
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    price = db.Column(db.Float(precision=2), nullable=False)
    category = db.Column(db.Enum(ItemCategory), default=ItemCategory.OTHER)
    photo_url = db.Column(URLType)
    store_id = db.Column(
        db.Integer, db.ForeignKey('grocery_store.id'), nullable=False)
    store = db.relationship('GroceryStore', back_populates='items')
    # Add created_by field to see the user who added the item
    created_by_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    created_by = db.relationship('User')
    # Add many-to-many relationship between User and GroceryItem
    users_who_shopped = db.relationship(
        'User', secondary='shopping_list', back_populates='shopping_list_items')
コード例 #20
0
ファイル: models.py プロジェクト: lotsofluck/GroceryStore
class GroceryItem(db.Model):
    """Grocery Item model."""
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    price = db.Column(db.Float(precision=2), nullable=False)
    category = db.Column(db.Enum(ItemCategory), default=ItemCategory.OTHER)
    photo_url = db.Column(URLType)
    store_id = db.Column(db.Integer,
                         db.ForeignKey('grocery_store.id'),
                         nullable=False)
    store = db.relationship('GroceryStore', back_populates='items')
    created_by = db.relationship("User")
    created_by_id = db.Column(db.Integer, db.ForeignKey("user.id"))
    user_shopping_list = db.relationship("User",
                                         secondary="shopping_list_table",
                                         back_populates="shopping_list_items")
コード例 #21
0
class GroceryItem(db.Model):
    """Grocery Item model."""
    __tablename__ = 'grocery_item'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    price = db.Column(db.Float(precision=2), nullable=False)
    category = db.Column(db.Enum(ItemCategory), default=ItemCategory.OTHER)
    photo_url = db.Column(URLType)
    store_id = db.Column(db.Integer,
                         db.ForeignKey('grocery_store.id'),
                         nullable=False)
    store = db.relationship('GroceryStore', back_populates='items')
    created_by_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    created_by = db.relationship('User')
    shopping_lists = db.relationship('User',
                                     secondary='user_groceryitem_association')
コード例 #22
0
class GroceryItem(db.Model):
    """Grocery Item model."""
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    price = db.Column(db.Float(precision=2), nullable=False)
    category = db.Column(db.Enum(ItemCategory), default=ItemCategory.OTHER)
    photo_url = db.Column(URLType)

    store_id = db.Column(db.Integer,
                         db.ForeignKey('grocery_store.id'),
                         nullable=False)
    store = db.relationship('GroceryStore', back_populates='items')
    """ Foreign Key column (to store the user’s id)"""
    created_by_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    """ Relationship (to store the User object itself) """
    created_by = db.relationship('User')

    customer = db.relationship("User", secondary="shopping_list")
コード例 #23
0
class GroceryItem(db.Model):
    """Grocery Item model."""
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    price = db.Column(db.Float(precision=2), nullable=False)
    category = db.Column(db.Enum(ItemCategory), default=ItemCategory.OTHER)
    photo_url = db.Column(URLType)
    store_id = db.Column(db.Integer,
                         db.ForeignKey('grocery_store.id'),
                         nullable=False)
    store = db.relationship('GroceryStore', back_populates='items')
    created_by_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    created_by = db.relationship('User')
    users_cart = db.relationship('User',
                                 secondary='shopping_cart',
                                 back_populates='cart_items')

    def __str__(self):
        return f'<Item: {self.name}>'

    def __repr__(self):
        return f'<Item: {self.name}>'
コード例 #24
0
class User(UserMixin, db.Model):
    """User model."""
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(25), nullable=False)
    password = db.Column(db.String(80), nullable=False)
    shopping_list_items = db.relationship('GroceryItem')
コード例 #25
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(24), nullable=False, unique=True)
    password = db.column(db.String(80))

    shopping_list_items = db.relationship('GroceryItem')