Exemplo n.º 1
0
class Demand(Base):
    __tablename__ = 'demand'
    id = db.Column(db.Integer, primary_key=True, nullable=False)
    name = db.Column(db.String(100), nullable=False)
    description = db.Column(db.String(1000), nullable=False)
    funcionalities = db.Column(db.String(300), nullable=False)
    platform = db.Column(db.String(100), nullable=False)
    final_date = db.Column(db.Date, nullable=False)
    proposals = db.relationship('Proposal', backref='demand', lazy=True)
    project = db.relationship('Project', backref='demand', lazy=True)
    client_id = db.Column(db.Integer,
                          db.ForeignKey('client.id'),
                          nullable=False)

    # project = db.relationship('Project', uselist=False)
    # project_id = db.Column(db.Integer, db.ForeignKey('project.id'))

    def __init__(self, name, description, funcionalities, platform, final_date,
                 client_id):
        self.name = name
        self.description = description
        self.funcionalities = funcionalities
        self.platform = platform
        self.final_date = final_date
        self.client_id = client_id

    def __repr__(self):
        return "Demand('{}', '{}', '{}', '{}', '{}', '{}', '{}')".format(
            self.id, self.name, self.description, self.funcionalities,
            self.platform, self.final_date, self.client_id)
Exemplo n.º 2
0
class ServiceProvider(User):
    __tablename__ = 'service_provider'
    id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True)
    projects = db.relationship('AssociationServiceProviderProject',
                               back_populates='service_provider')
    proposals = db.relationship('AssociationServiceProviderProposal',
                                back_populates='service_provider')
    skills = db.Column(db.String(100), nullable=False)
    curriculum = db.Column(db.String(1000), nullable=False)
    proposal_id = db.Column(db.Integer, db.ForeignKey('proposal.id'))
    cost_per_project = db.Column(db.Float, nullable=False)
    __mapper_args__ = {
        'polymorphic_identity': 'service_provider',
    }

    def __init__(self, name, email, password, skills, curriculum,
                 cost_per_project):
        User.__init__(self, name, email, password)
        self.skills = skills
        self.curriculum = curriculum
        self.cost_per_project = cost_per_project

    def __repr__(self):
        return "Service Provider('{}', '{}', '{}', '{}', '{}', '{}', '{}')".format(
            self.id, self.name, self.skills, self.type, self.projects,
            self.cost_per_project, self.proposals)
Exemplo n.º 3
0
class Project(Base):
    __tablename__ = 'project'
    id = db.Column(db.Integer, primary_key=True, nullable=False)
    cost = db.Column(db.Float, nullable=False)
    final_date = db.Column(db.Date, nullable=False)
    spending = db.Column(db.Float, nullable=False)
    tasks_completed = db.Column(db.Integer, nullable=True)
    finalized = db.Column(db.Boolean, unique=False, default=False)
    # Relationships
    client_id = db.Column(db.Integer,
                          db.ForeignKey('client.id'),
                          nullable=False)
    service_providers = db.relationship('AssociationServiceProviderProject',
                                        back_populates='project')
    demand_id = db.Column(db.Integer,
                          db.ForeignKey('demand.id'),
                          nullable=False)
    origin_demand = db.relationship('Demand', foreign_keys=[demand_id])

    # team
    # demand = db.relationship('Demand', uselist=False)
    # problems_solved
    # tasks_completed

    def __repr__(self):
        return "Project('{}', '{}', '{}', '{}', '{}', '{}', '{}')".format(
            self.id, self.cost, self.final_date, self.spending, self.client_id,
            self.service_providers, self.origin_demand)
Exemplo n.º 4
0
class ProductMovement(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.String(15), nullable=False)
    fromLocationId = db.Column(db.Integer, db.ForeignKey(Location.id))
    toLocationId = db.Column(db.Integer, db.ForeignKey(Location.id))
    productId = db.Column(db.Integer, db.ForeignKey(Product.id))
    fromLocation = db.relationship(Location, foreign_keys=[fromLocationId])
    toLocation = db.relationship(Location, foreign_keys=[toLocationId])
    productName = db.relationship(Product, foreign_keys=[productId])
    productQuantity = db.Column(db.Integer,
                                db.CheckConstraint('productQuantity > 0'))

    def __repr__(self):
        return f'{self.date}\t{self.fromLocation}\t{self.toLocation}\t{self.productName}\t{self.productQuantity}'
Exemplo n.º 5
0
class Client(User):
    __tablename__ = 'client'
    id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True)
    projects = db.relationship('Project', backref='client', lazy=True)
    demands = db.relationship('Demand', backref='client', lazy=True)

    def __init__(self, name, email, password):
        User.__init__(self, name, email, password)
    
    def __repr__(self):
        return "Client('{}', '{}', '{}', '{}', '{}')".format(self.id, self.name, self.email, self.type, self.projects)
    __mapper_args__ = {
        'polymorphic_identity': 'client',
    }
Exemplo n.º 6
0
class User(db.Model, UserMixin):
    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(25), unique=True, nullable=False)
    email = db.Column(db.String(255), unique=True, nullable=False)
    password = db.Column(db.String(60), nullable=False)

    messages = db.relationship('Message', lazy=True, backref='user')
    chats = db.relationship('Chat',
                            secondary=chat_user,
                            backref=db.backref('users'))

    def __repr__(self):
        return f"<User {self.username} {self.email}>"
Exemplo n.º 7
0
class User(db.Model):
	id = db.Column(db.Integer, primary_key=True)
	nickname = db.Column(db.String(120), index=True, unique=True)
	password = db.Column(db.String(255))
	## 1>n relationship to class File, allow file to backref user
	files = db.relationship('File',backref='user',lazy='dynamic')
	rank_id = db.Column(db.Integer, db.ForeignKey('rank.id'))
	mb_used = db.Column(db.Integer)

	########## uses flask_login extension
	@property
	def is_authenticated(self):
		return True
	@property
	def is_active(self):
		return True
	@property
	def is_anonymous(self):
		return False

	def get_id(self):
		return str(self.id)

	def __repr__(self):
		return 'User %r' % (self.nickname)
Exemplo n.º 8
0
class User(db.Model, UserMixin):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    active = db.Column('is_active',
                       db.Boolean(),
                       nullable=False,
                       server_default='1')

    # User authentication information. The collation='NOCASE' is required
    # to search case insensitively when USER_IFIND_MODE is 'nocase_collation'.
    email = db.Column(db.String(255, collation='NOCASE'),
                      nullable=False,
                      unique=True)
    email_confirmed_at = db.Column(db.DateTime())
    password = db.Column(db.String(255), nullable=False, server_default='')

    # User information
    first_name = db.Column(db.String(100, collation='NOCASE'),
                           nullable=False,
                           server_default='')
    last_name = db.Column(db.String(100, collation='NOCASE'),
                          nullable=False,
                          server_default='')

    # Define the relationship to Role via UserRoles
    roles = db.relationship('Role', secondary='user_roles')

    def __repr__(self):
        return f"User('{self.email}','{self.password}'"
Exemplo n.º 9
0
class AssociationServiceProviderProject(Base):
    __tablename__ = 'association-service_provider-project'
    service_provider_id = db.Column(db.Integer, db.ForeignKey('service_provider.id'), primary_key=True)
    project_id = db.Column(db.Integer, db.ForeignKey('project.id'), primary_key=True)
    service_provider = db.relationship('ServiceProvider', back_populates='projects')
    project = db.relationship('Project', back_populates='service_providers')

    def __init__(self, project, service_provider):
        self.project = project
        self.project_id = project.id
        self.service_provider = service_provider
        self.service_provider_id = service_provider.id

    def __repr__(self):
        return "Association: ServiceProvider-Project('{}', '{}')".format(
            self.service_provider_id, self.project_id)
Exemplo n.º 10
0
class Chat(db.Model):
    __tablename__ = 'chats'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), nullable=False)
    messages = db.relationship('Message', lazy=True, backref='chat')

    def __repr__(self):
        return f"<Chat {self.name}>"
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True, nullable=False)
    password = db.Column(db.String(120), unique=True, nullable=False)
    posts = db.relationship('Post', backref='author', lazy=True)
    def save_to_db(self):
        db.session.add(self)
        db.session.commit()
    def __repr__(self):
        return '<User %r>' % self.username
Exemplo n.º 12
0
class User(db.Model):
    ## you must declare a primary key
    ## otherwise no foreigh key
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(100), index=True, unique=True)
    email = db.Column(db.String(100), index=True, unique=True)
    password_hash = db.Column(db.String(200))
    ## add the foregin key
    ## part one here
    posts = db.relationship('Post', backref='author', lazy='dynamic')
Exemplo n.º 13
0
class UserPermission(db.Model):  # type: ignore
    """ Class to map available permissions to a user. """

    __tablename__ = "UserPermission"

    UserId = db.Column(db.Integer, db.ForeignKey('User.ID'), primary_key=True)

    PermissionId = db.Column(db.Integer,
                             db.ForeignKey('Permission.ID'),
                             primary_key=True)

    user_details = db.relationship('User', backref='permission', lazy="select")

    permission_details = db.relationship('Permission',
                                         backref='user',
                                         lazy="select")

    def __repr__(self):
        return f"User: {self.user_details.username}, Permission {self.permission_details.name}"
Exemplo n.º 14
0
class User(db.Model):
	id = db.Column(db.Integer, primary_key=True)
	username = db.Column(db.String(20), unique=True, nullable=False)
	email = db.Column(db.String(120), unique=True, nullable=False)
	image_file = db.Column(db.String(20), nullable=False, default='default.jpg')
	password = db.Column(db.String(60), nullable=False)
	posts = db.relationship('Post', backref='author', lazy=True)

	def __repr__(self):
		return f"User('{self.username}', '{self.email}', '{self.image_file}')"
Exemplo n.º 15
0
class User(db.Model):
	id = db.Column(db.Integer, primary_key=True)
	username = db.Column(db.String(20), unique=True, nullable=False)
	email = db.Column(db.String(120), unique=True, nullable=False)
	image_file = db.Column(db.String(20), nullable=False, default='default.jpg')
	password = db.Column(db.String(60), nullable=False)
	# The following posts column will be a backref which allows SQLAlchemy to link 
	# a specific user (author) back to a bunch of different posts they wrote
	posts = db.relationship('Post', backref='author', lazy=True)

	# Defines the default manner in which our object will be printed out
	def __repr__(self):
		return f"User('{self.username}', '{self.email}', '{self.image_file}')"
Exemplo n.º 16
0
class User(db.Model, UserMixin):
	id = db.Column(db.Integer, primary_key=True)
	username = db.Column(db.String(20), nullable=False)
	phone = db.Column(db.String(20), nullable=False)
	D_o_B = db.Column(db.String(20), nullable=False)
	email = db.Column(db.String(120), unique=True, nullable=False)
	image_file = db.Column(db.String(20), nullable=False, default='default.jpg')
	password = db.Column(db.String(60), nullable=False)
	affiliation = db.Column(db.String(60), nullable=False)
	posts = db.relationship('Post', backref='author', lazy=True)

	def __repr__(self):
		return str(self.username)
Exemplo n.º 17
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    password = db.Column(db.String(60), nullable=False)
    posts = db.relationship('Post', backref='author', lazy=True)

    # def __init__(self,email,password):
    #     self.email = email
    #     self.password = password

    def __repr__(self):
        return f"User('{self.username}', '{self.email}')"
Exemplo n.º 18
0
class Proposal(Base):
    __tablename__ = 'proposal'
    id = db.Column(db.Integer, primary_key=True, nullable=False)
    service_providers = db.relationship('AssociationServiceProviderProposal',
                                        back_populates='proposal')
    cost = db.Column(db.Float, nullable=False)
    final_date = db.Column(db.Date, nullable=False)
    client_approval = db.Column(db.Boolean, nullable=False)
    demand_id = db.Column(db.Integer, db.ForeignKey('demand.id'),
                          nullable=False)

    def __repr__(self):
        return "Proposal('{}', '{}', '{}', '{}', '{}', '{}')".format(
            self.id, self.cost, self.final_date, self.client_approval,
            self.demand_id, self.service_providers)
Exemplo n.º 19
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    image_file = db.Column(db.String(20),
                           nullable=False,
                           default='default.jpg')
    password = db.Column(db.String(60), nullable=False)
    posts = db.relationship(
        'Post', backref='author', lazy=True
    )  #defines when sqlachemy loads the data from the db. True means

    #sqlalchemy will load the data as necessary in one go. Will use the
    #post attribute to get the posts posted by an indivudual user

    #backref 'author' creates a column author in the posts table
    def __repr__(self):
        return f"User('{self.username}','{self.email}','{self.image_file}')"
Exemplo n.º 20
0
class user(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(
        db.String(20),
        nullable=False,
        unique=True,
    )
    email = db.Column(
        db.String(99),
        nullable=False,
        unique=True,
    )
    password = db.Column(db.String(50), nullable=False)
    profile_picture = db.Column(db.String(20),
                                nullable=False,
                                default="default.jpg")
    posts = db.relationship("post", backref="author", lazy=True)

    def __repr__(self):
        return f"user('{self.username}', '{self.email}', '{self.profile_picture}')"
Exemplo n.º 21
0
class Rank(db.Model):
	id = db.Column(db.Integer, primary_key=True)
	title = db.Column(db.String(25))
	level = db.Column(db.Integer)
	mb_limit = db.Column(db.Integer)
	users = db.relationship('User', backref = 'rank', lazy='dynamic')