示例#1
0
文件: models.py 项目: dr-hemam/colp1
class ConstraintAnalysis(db.Model):
	__tablename__ ="constraintanalysis"
	id = db.Column(db.Integer, primary_key=True)
	project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
	project= db.relationship('Project', backref='constraintsanalysis')
	reportingdate_id = db.Column(db.Integer, db.ForeignKey('reportingdates.id'))
	reportingdate= db.relationship('ReportingDate', backref='constraintsanalysis')
	section_id = db.Column(db.Integer, db.ForeignKey('sections.id'))
	section= db.relationship('Section', backref='constraintsanalysis')	
	is_active = db.Column(db.Boolean)
	status = db.Column(db.Boolean)
	__table_args__ = (
        db.UniqueConstraint('project_id', 'reportingdate_id', 'section_id', name='uix_constraintanalysis_projid_reportid_section'),
    )

	def __init__(self, project, reportingdate, section, is_active=True):
		self.is_active = is_active
		self.project_id = project.id
		self.section = section
		self.reportingdate = reportingdate
		self.section_id = section.id
		self.section = section
		self.reportingdate_id= reportingdate.id
		
	def __repr__(self):
		dd = datetime.strptime(str(self.reportingdate.rdate), '%Y-%m-%d %H:%M:%S').strftime("%d-%b-%Y")
		return str(dd)
示例#2
0
文件: models.py 项目: dr-hemam/colp1
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')
    org_id = db.Column(db.Integer, db.ForeignKey('organisations.id'))
    organisation = db.relationship('Organisation', backref='project')
    status = db.Column(db.Boolean, default=True)
    users = db.relationship("UserProject")

    __table_args__ = (db.UniqueConstraint('code', 'org_id', name='uix_prj1'), )

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

    def __repr__(self):
        return self.name
示例#3
0
文件: models.py 项目: dr-hemam/colp1
class ConstraintAnalysisDetail(db.Model):
	__tablename__ ="constraintanalysis_details"
	id = db.Column(db.Integer, unique=True, autoincrement=True)
	constraintanalysis_id = db.Column(db.Integer, db.ForeignKey('constraintanalysis.id'), primary_key=True)
	constraintanalysis = db.relationship('ConstraintAnalysis', backref='detail')
	task_id = db.Column(db.Integer, db.ForeignKey('lookaheads_details.id'), primary_key=True)
	task = db.relationship('LookAheadDetail', backref='detail')
	constraint_id = db.Column(db.Integer, db.ForeignKey('constraints.id'), primary_key=True)
	constraint = db.relationship('Constraint', backref='detail')
	status = db.Column(db.Boolean)
	is_active = db.Column(db.Boolean)
	can_do = db.Column(db.Boolean)
	__table_args__ = (
		db.UniqueConstraint('constraintanalysis_id', 'task_id', 'constraint_id', name='uix_cad'),
	)
	
	def __init__(self, constraintanalysis, task, constraint, status, can_do, is_active=True):
		self.constraintanalysis_id = constraintanalysis.id
		self.task_id= task.id
		self.task = task
		self.constraint_id = constraint.id
		self.constraint = constraint
		self.status = status
		self.can_do = can_do
		self.is_active = is_active
		
	def __repr__(self):
		return str(self.task_id)
示例#4
0
文件: models.py 项目: dr-hemam/colp1
class Section(db.Model):
    __tablename__ = "sections"
    id = db.Column(db.Integer, primary_key=True)
    code = db.Column(db.String(80), unique=True)
    name = db.Column(db.String(80))
    project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
    project = db.relationship('Project', backref='section')
    parent_id = db.Column(db.Integer, db.ForeignKey('sections.id'))
    parent = db.relationship(lambda: Section, remote_side=id, backref='subs')

    active = db.Column(db.Boolean)
    __table_args__ = (db.UniqueConstraint('code',
                                          'project_id',
                                          name='uix_sec1'), )

    def __init__(self, code, name, project, parent, active=True):
        self.code = code
        self.name = name
        self.active = active
        self.project_id = project.id
        self.parent = parent
        if parent:
            self.parent_id = parent.id

    def json(self):
        return ({
            "name": self.name,
            "id": str(self.id),
            "parent_id": str(self.parent_id),
            "level": 0,
            "childs": []
        })

    def __repr__(self):
        return self.name
示例#5
0
class WWPDetail(db.Model):
	__tablename__ ="wwp_details"
	id= db.Column(db.Integer, primary_key=True)
	wwp_id = db.Column(db.Integer, db.ForeignKey('wwps.id'), primary_key=True)
	wwp = db.relationship('WWP', backref='detail')
	task_id = db.Column(db.Integer, db.ForeignKey('lookaheads_details.id'), primary_key=True)
	task = db.relationship('LookAheadDetail', backref='wwptask')
	user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=True)
	user = db.relationship("User", backref="wwp_details")
	mon= db.Column(db.Boolean)
	tue = db.Column(db.Boolean)
	wed = db.Column(db.Boolean)
	thu = db.Column(db.Boolean)
	fri = db.Column(db.Boolean)
	sat = db.Column(db.Boolean)
	sun = db.Column(db.Boolean)
	status = db.Column(db.Boolean)
	updated = db.Column(db.Boolean)
	is_active = db.Column(db.Boolean)
	delayreason = db.relationship('DelayReason', backref='wwptask')
	delayreason_id = db.Column(db.Integer, db.ForeignKey('delay_reasons.id'))
	__table_args__ = (
		db.UniqueConstraint('wwp_id', 'task_id', name='uix_wwpd'),
	)
	
	
	def __init__(self, wwp, task, user, mon, tue, wed, thu, fri, sat, sun, updated= False, status= False, is_active=True):
		self.wwp_id = wwp.id
		if task:
			self.task_id= task.id
		self.task = task
		if user:
			self.user_id = user.id
		#self.user = user
		self.mon = mon
		self.tue = tue
		self.wed = wed
		self.thu = thu
		self.fri = fri
		self.sat = sat
		self.sun = sun
		self.status = status
		self.updated = updated
		self.is_active = is_active
		
	def __repr__(self):
		return str(self.task_id)
		
	def to_json(self):
		return ({'task_name':str(self.task),
			'responsible':str(self.user),
			'updated': str(self.updated),
			'completed': str(self.status),
			'Reason':str(self.delayreason)
		})
示例#6
0
文件: models.py 项目: dr-hemam/colp1
class UserProject(db.Model):
    __tablename__ = 'user_project'
    project_id = db.Column(db.Integer,
                           db.ForeignKey('projects.id'),
                           primary_key=True)
    user_id = db.Column(db.Integer,
                        db.ForeignKey('users.id'),
                        primary_key=True)
    role_id = db.Column(db.Integer)
    user = db.relationship("User", backref="parent_assocs")
    project = db.relationship("Project", backref="assoc")
    is_active = db.Column(db.Boolean)

    __table_args__ = (db.UniqueConstraint('project_id',
                                          'user_id',
                                          name='uix_1'), )

    def __init__(self, project, user, role, is_active=True):
        self.project_id = project.id
        self.user_id = user.id
        self.role_id = role.id
        self.is_active = is_active
示例#7
0
class WWP(db.Model):
	__tablename__ ="wwps"
	id = db.Column(db.Integer, primary_key=True)
	project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
	project= db.relationship('Project', backref='weeklyworkplan')
	reportingdate_id = db.Column(db.Integer, db.ForeignKey('reportingdates.id'))
	reportingdate= db.relationship('ReportingDate', backref='weeklyworkplan')
	section_id = db.Column(db.Integer, db.ForeignKey('sections.id'))
	section= db.relationship('Section', backref='weeklyworkplan')
	ppc = db.Column(db.Float)
	is_active = db.Column(db.Boolean)
	status = db.Column(db.Boolean)
	__table_args__ = (
        db.UniqueConstraint('project_id', 'reportingdate_id', 'section_id', name='uix_wwp_projid_reportid_section'),
    )
	def __init__(self, project, reportingdate, section, ppc=None, status=False, is_active=True):
		self.is_active = is_active
		self.project_id = project.id
		self.project = project
		self.reportingdate = reportingdate
		self.section_id = section.id
		self.section = section
		self.ppc = ppc
		self.reportingdate_id= reportingdate.id
		self.status =status
	
	def __repr__(self):
		dd = datetime.strptime(str(self.reportingdate.rdate), '%Y-%m-%d %H:%M:%S').strftime("%d-%b-%Y")
		return str(dd)
		
	def to_json(self):
		return ({'id': str(self.id),
						'date': str(self.reportingdate.rdate),
						'project': str(self.project),
						'section': str(self.section),
						'PPC': str(self.ppc)
		})
示例#8
0
文件: models.py 项目: dr-hemam/colp1
class Role(db.Model):
    __tablename__ = 'roles'
    __table_args__ = {'extend_existing': True}
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80))
    organisation_id = db.Column(db.Integer, db.ForeignKey('organisations.id'))
    organisation = db.relationship('Organisation', backref='roles')
    manager_id = db.Column(db.Integer, db.ForeignKey('roles.id'))
    manager = db.relationship(lambda: Role, remote_side=id, backref='subs')
    is_active = db.Column(db.Boolean, default=True)
    __table_args__ = (db.UniqueConstraint('name',
                                          'organisation_id',
                                          name='uix_rol1'), )

    def __init__(self, name, organisation, manager, is_active=True):
        self.name = name
        if organisation is not None:
            self.organisation_id = organisation.id
        if manager is not None:
            self.manager_id = manager.id
        self.is_active = is_active

    def __repr__(self):
        return self.name
示例#9
0
文件: models.py 项目: dr-hemam/colp1
class DelayReason(db.Model):
	__tablename__ ="delay_reasons"
	id = db.Column(db.Integer, primary_key=True)
	name = db.Column(db.String(80))
	project_id = db.Column(db.Integer, db.ForeignKey('projects.id'))
	project= db.relationship('Project', backref='delayreasons')
	is_active = db.Column(db.Boolean)
	__table_args__ = (
		db.UniqueConstraint('name', 'project_id', name='uix_dr1'),
	)
	def __init__(self, name, project, is_active=True):
		self.name = name
		self.project_id= project.id
		self.is_active= is_active
		
	def __repr__(self):
		return self.name
示例#10
0
文件: models.py 项目: dr-hemam/colp1
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(db.Integer, db.ForeignKey('organisations.id'))
    organisation = db.relationship('Organisation', backref='users')
    confirmed = db.Column(db.Boolean, nullable=False, default=False)
    confirmed_on = db.Column(db.DateTime, nullable=True)
    is_admin = db.Column(db.Boolean, default=False)
    is_active = db.Column(db.Boolean, default=True)

    def __init__(self,
                 firstname,
                 lastname,
                 email,
                 username,
                 password,
                 organisation,
                 is_admin=False,
                 is_active=True,
                 confirmed=False,
                 confirmed_on=None):
        self.firstname = firstname
        self.email = email
        self.lastname = lastname
        self.password = password
        self.is_admin = is_admin
        self.username = username
        if organisation:
            self.organisation_id = organisation.id
        self.is_active = is_active
        self.confirmed = confirmed
        self.confirmed_on = confirmed_on

    def __repr__(self):
        return self.username
示例#11
0
文件: models.py 项目: dr-hemam/colp1
class LookAheadDetail(db.Model):
	__tablename__ ="lookaheads_details"
	id = db.Column(db.Integer, primary_key=True)
	lookahead_id = db.Column(db.Integer, db.ForeignKey('lookaheads.id'))
	lookahead= db.relationship('LookAhead', backref='detail')
	task_code = db.Column(db.String(80))
	task_name = db.Column(db.String(80))
	start = db.Column(db.DateTime)
	finish = db.Column(db.DateTime)
	#responsible person assignment
	is_active = db.Column(db.Boolean)
	__table_args__ = (
		db.UniqueConstraint('lookahead_id', 'task_code', name='uix_1_lookahead_details_lookahead_id_task_code'),
	)
	def __init__(self, lookahead, code, name, start, finish, is_active=True):
		self.lookahead_id = lookahead.id
		self.task_code= code
		self.task_name = name
		self.start = start
		self.finish = finish
		self.is_active = is_active
		
	def __repr__(self):
		return self.task_name
示例#12
0
class UseProj(db.Model):
    __tablename__ = 'use_proj'
    left_id = db.Column(db.Integer, db.ForeignKey('project.id'), primary_key=True)
    right_id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True)
    role_id = db.Column(db.Integer)
    user = db.relationship("Use", backref="parent_assocs")