Ejemplo n.º 1
0
class Project(db.Model):
    __tablename__ = "projects"
    id = db.Column(db.Integer, primary_key=True)
    code = db.Column(db.String(80), unique=True)
    name = db.Column(db.String(80))
    owner = db.Column(db.Integer, db.ForeignKey('users.id'))
    description = db.Column(db.Text)
    start = db.Column(db.DateTime)
    finish = db.Column(db.DateTime)
    cycle_id = db.Column(db.Integer, db.ForeignKey('reportingcycles.id'))
    cycle = db.relationship('ReportingCycle', backref='project')
    status = db.Column(db.Boolean)

    def __init__(self, code, name, description, owner, start, finish, cycle,
                 status):
        self.code = code
        self.name = name
        self.owner = owner
        self.description = description
        self.start = start
        self.finish = finish
        self.status = status
        self.cycle_id = cycle.id

    def __repr__(self):
        return self.name
Ejemplo n.º 2
0
class WBS(db.Model):
    __tablename__ = 'wbs'
    id = db.Column(db.Integer, primary_key=True)
    code = db.Column(db.String(80))
    name = db.Column(db.String(80))

    parent_id = db.Column(db.Integer)
    parent = db.relationship("WBS", backref="parent")
    project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
    project = db.relationship("Project", backref="control_account")

    def __init__(self, code, name, parent, project):
        self.code = code
        self.name = name
        self.parent_id = parent.id if parent is not None else None
        self.project_id = project.id

    def __repr__(self):
        return self.name
Ejemplo n.º 3
0
class CostAccount(db.Model):
	__tablename__ ="cost_accounts"
	id = db.Column(db.Integer, primary_key=True)
	code = db.Column(db.String(80), unique=True)
	name = db.Column(db.String(80))

	controlaccount_id = db.Column('ControlAccount', db.Integer, db.ForeignKey('controlaccounts.id'))
	controlaccount = db.relationship('ControlAccount', backref='control_account')
	
	parent_id = db.Column('parent_id', db.Integer, db.ForeignKey('cost_accounts.id'))
	parent = db.relationship('CostAccount', uselist=False)
	#parent_id = db.Column(db.Integer)
	
	def __init__(self, code, name, controlaccount, parent):
		self.code = code
		self.name = name
		self.parent_id = parent.id if parent is not None else None
		self.controlaccount_id = controlaccount.id
		
	def __repr__(self):
		return self.name
Ejemplo n.º 4
0
class ControlAccount(db.Model):
    __tablename__ = 'controlaccounts'
    id = db.Column(db.Integer, primary_key=True)
    code = db.Column(db.String(80))
    name = db.Column(db.String(80))
    budget = db.Column(db.Float)
    PMB_start = db.Column(db.Date)
    PMB_finish = db.Column(db.Date)
    PMU_start = db.Column(db.Date)
    PMU_finish = db.Column(db.Date)
    parent_id = db.Column(db.Integer, nullable=True)

    accounttype_id = db.Column('AccountType', db.Integer,
                               db.ForeignKey('control_account_types.id'))
    accounttype = db.relationship('AccountType', backref='control_account')
    curve_id = db.Column(db.Integer, db.ForeignKey('spread_profile.id'))
    curve = db.relationship("SpreadProfile", backref="control_account")
    project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
    project = db.relationship("Project", backref="control_account")

    def __init__(self, code, name, accounttype, budget, PMB_start, PMB_finish,
                 PMU_start, PMU_finish, parent, curve, project):
        self.code = code
        self.name = name
        self.parent_id = parent.id if parent is not None else None
        self.accounttype_id = accounttype.id
        self.budget = budget
        self.PMB_start = PMB_start
        self.PMB_finish = PMB_finish
        self.PMU_start = PMU_start
        self.PMU_finish = PMU_finish
        if curve:
            self.curve_id = curve.id
        else:
            self.curve_id = None
        self.project = project
        self.project_id = project.id

    def __repr__(self):
        return self.name
Ejemplo n.º 5
0
class User(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    firstname = db.Column(db.String(80))
    lastname = db.Column(db.String(80))
    email = db.Column(db.String(35), unique=True)
    username = db.Column(db.String(80), unique=True)
    password = db.Column(db.String(80))
    organisation_id = db.Column('Organisation',
                                db.Integer,
                                db.ForeignKey('organisations.id'),
                                nullable=True)
    organisation = db.relationship('Organisation', backref='users')
    is_admin = db.Column(db.Boolean)

    def __init__(self,
                 firstname,
                 lastname,
                 email,
                 username,
                 password,
                 organisation,
                 is_admin=False):
        self.firstname = firstname
        self.email = email
        self.lastname = lastname
        self.password = password
        self.is_admin = is_admin
        self.username = username
        if organisation is not None:
            organisation_id = organisation.id
        else:
            organisation_id = None

    def __repr__(self):
        return self.username