예제 #1
0
class Component(db.Model):
    """Components model for tracking product components.

    The model is used to keep a record of the components for which
    the bugs can be filed. This provides a more targeted approach to
    classifying the busg inside the system.
    """

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    component_name = db.Column(db.String(100),
                               unique=True,
                               nullable=False,
                               index=True)
    product_id = db.Column(db.Integer, db.ForeignKey(Product.id))
    product = db.relationship("Product", lazy=True)
    component_owner = db.Column(db.Integer, db.ForeignKey(User.id))

    def __repr__(self):
        """Component model representation."""
        return "<Component {}>".format(self.component_name)
예제 #2
0
class ActivationKey(db.Model):
    """Activation key model for storing activation key records for the user.

    The model is responsible for storing the records of the activation key
    on a per user basis.
    """

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    user_id = db.Column(db.Integer, db.ForeignKey(User.id))
    activation_key = db.Column(db.String(64), unique=True, nullable=False)

    def __repr__(self):
        """Activation key model representation."""
        return "<ActivationKey {}>".format(self.user_id)
class Version(db.Model):
    """Version information model.

    The model is used to store the information of the product versions
    on a per product basis.
    """

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    version = db.Column(db.String(20), nullable=False)
    product_id = db.Column(db.Integer, db.ForeignKey(Product.id))

    def __repr__(self):
        """Version model representation."""
        return "<Version {}>".format(self.version)
예제 #4
0
class Product(db.Model):
    """Product defintion model.

    The model is used to store the information related to the products
    for which the users can file a bug.
    """

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    product_name = db.Column(db.String(100),
                             nullable=False,
                             unique=True,
                             index=True)
    category_id = db.Column(db.Integer, db.ForeignKey(Category.id))
    category = db.relationship("Category", lazy=True)

    def __repr__(self):
        """Product model representation."""
        return "<Product {}>".format(self.product_name)
class User(db.Model):
    """User data model for storing user account information.

    The model is responsible for storing the account information on a
    per user basis and providing access to it for authentication
    purposes.
    """

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String(50),
                         unique=True,
                         index=True,
                         nullable=False)
    password = db.Column(db.String(512), nullable=False)
    email = db.Column(db.String(255), unique=True, nullable=False, index=True)
    user_role = db.Column(db.Integer, db.ForeignKey(Role.id))
    role = db.relationship("Role", lazy=False)
    joining_date = db.Column(db.DateTime, nullable=False)
    last_login = db.Column(db.DateTime, nullable=False)
    account_status = db.Column(db.Boolean, nullable=False, default=False)

    def __repr__(self):
        """User model representation."""
        return "<user {}>".format(self.username)