Exemple #1
0
class Role(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    description = db.Column(db.String(80))
    is_read = db.Column(db.Boolean)
    is_create = db.Column(db.Boolean)
    is_edit = db.Column(db.Boolean)
    is_delete = db.Column(db.Boolean)
    is_active = db.Column(db.Boolean)

    def __init__(self,
                 description,
                 is_read,
                 is_create,
                 is_edit,
                 is_delete,
                 is_active=True):
        self.description = description
        self.is_create = is_create
        self.is_delete = is_delete
        self.is_edit = is_edit
        self.is_read = is_read
        self.is_active = is_active

    def _repr__(self):
        return self.description
Exemple #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
Exemple #3
0
class Organisation(db.Model):
    __tablename__ = "organisations"
    id = db.Column(db.Integer, primary_key=True)
    code = db.Column(db.String(80), unique=True)
    name = db.Column(db.String(80))
    description = db.Column(db.Text)
    #admin_id = db.Column(db.Integer, db.ForeignKey('users.id'))
    #admin = db.relationship('User', backref='organisations')
    is_active = db.Column(db.Boolean)

    def __init__(self, code, name, description, admin, is_active=True):
        self.code = code
        self.name = name
        self.description = description
        self.admin_id = admin.id
        self.is_active = is_active

    def __repr__(self):
        return self.name
Exemple #4
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
Exemple #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
Exemple #6
0
class ReportingCycle(db.Model):
    __tablename__ = 'reportingcycles'
    id = db.Column(db.Integer, primary_key=True)
    code = db.Column(db.String(80), unique=True)
    name = db.Column(db.String(80))
    cycle_type = db.Column(db.Text)
    cycle_value = db.Column(db.Integer)
    #project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
    #project = db.relationship('Project', backref='ReportingCalendar')
    is_active = db.Column(db.Boolean)

    def __init__(self, code, name, cycle_type, cycle_value, is_active=True):
        self.code = code
        self.name = name
        self.cycle_type = cycle_type
        self.cycle_value = cycle_value
        #self.project_id = project.id
        self.is_active = is_active

    def __repr__(self):
        return self.name
Exemple #7
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))
    type = db.Column(db.String(35), unique=True)
    budget = db.Column(db.Double(80), unique=True)
    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, db.ForeignKey('controlaccounts.id'))

    def __init__(self,
                 code,
                 name,
                 type,
                 budget,
                 PMB_start,
                 PMB_finish,
                 PMU_start,
                 PMU_finish,
                 parent_id,
                 curve,
                 project_id,
                 _id=None):

        self.name = name
        self.parent_id = parent_id
        self.project_id = project_id
        self.type = type
        self.budget = budget
        self.PMB_start = PMB_start
        self.PMB_finish = PMB_finish
        self.PMU_start = PMU_start
        self.PMU_finish = PMU_finish
        self.curve = curve
        self._id = uuid.uuid4().hex if _id is None else _id
        self.code = code

    def json(self):

        return {
            '_id': self._id,
            'code': self.code,
            'name': self.name,
            'type': self.type,
            'budget': self.budget,
            'PMB_start': self.PMB_start,
            'PMB_finish': self.PMB_finish,
            'PMU_finish': self.PMU_finish,
            'PMU_start': self.PMU_start,
            'curve': self.curve,
            'project_id': self.project_id,
            'parent_id': self.parent_id
        }

    def save_to_database(self):
        pass
        #Database.insert(table= 'controlaccounts', data= self.json())

    @classmethod
    def find_by_id(cls, id):
        pass
        #account = Database.find_one(table= 'controlaccounts', data= {'_id': id})
        #return cls(**account)

    @staticmethod
    def exist(name, code):
        pass
Exemple #8
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
Exemple #9
0
class SpreadProfile(db.Model):
	__tablename__='spread_profile'
	id = db.Column(db.Integer, primary_key =True)
	code = db.Column(db.String(80), unique =True)
	name = db.Column(db.String(80), unique =True)
	period1 = db.Column(db.String(3))
	period2 = db.Column(db.String(3))
	period3 = db.Column(db.String(3))
	period4 = db.Column(db.String(3))
	period5 = db.Column(db.String(3))
	period6 = db.Column(db.String(3))
	period7 = db.Column(db.String(3))
	period8 = db.Column(db.String(3))
	period9 = db.Column(db.String(3))
	period10 = db.Column(db.String(3))
	period11 = db.Column(db.String(3))
	period12 = db.Column(db.String(3))
	period13 = db.Column(db.String(3))
	period14 = db.Column(db.String(3))
	period15 = db.Column(db.String(3))
	period16 = db.Column(db.String(3))
	period17 = db.Column(db.String(3))
	period18 = db.Column(db.String(3))
	period19 = db.Column(db.String(3))
	period20 = db.Column(db.String(3))
	
	def __init__(self, code, name, period1, period2, period3, period4, period5, period6, period7,
				period8, period9, period10, period11, period12, period13, period14, period15,
				period16, period17, period18, period19, period20):
		
		self.name = name
		self.code = code
		self.name = name
		self.period1 = period1
		self.period2 = period2
		self.period3 = period3
		self.period4 = period4
		self.period5 = period5
		self.period6 = period6
		self.period7 = period7
		self.period8 = period8
		self.period9 = period9
		self.period10 = period10
		self.period11 = period11
		self.period12 = period12
		self.period13 = period13
		self.period14 = period14
		self.period15 = period15
		self.period16 = period16
		self.period17 = period17
		self.period18 = period18
		self.period19 = period19
		self.period20 = period20
		
	def __repr__(self):
		return self.name