Add model for SuperDepartment
This commit is contained in:
parent
472f43896b
commit
e2dc00b469
|
@ -74,6 +74,38 @@ class Parameter(Base):
|
|||
return "{}-{} {}".format(self.store_id, self.lane_id, self.param_key)
|
||||
|
||||
|
||||
class SuperDepartment(Base):
|
||||
"""
|
||||
Represents a "super" (parent/child) department mapping.
|
||||
"""
|
||||
__tablename__ = 'superdepts'
|
||||
__table_args__ = (
|
||||
sa.ForeignKeyConstraint(['superID'], ['departments.dept_no']),
|
||||
sa.ForeignKeyConstraint(['dept_ID'], ['departments.dept_no']),
|
||||
)
|
||||
|
||||
parent_id = sa.Column('superID', sa.Integer(), primary_key=True, autoincrement=False, nullable=False)
|
||||
parent = orm.relationship(
|
||||
'Department',
|
||||
foreign_keys=[parent_id],
|
||||
doc="""
|
||||
Reference to the parent department for this mapping.
|
||||
""",
|
||||
backref=orm.backref('_super_children'))
|
||||
|
||||
child_id = sa.Column('dept_ID', sa.Integer(), primary_key=True, autoincrement=False, nullable=False)
|
||||
child = orm.relationship(
|
||||
'Department',
|
||||
foreign_keys=[child_id],
|
||||
doc="""
|
||||
Reference to the child department for this mapping.
|
||||
""",
|
||||
backref=orm.backref('_super_parent', uselist=False))
|
||||
|
||||
def __str__(self):
|
||||
return "{} / {}".format(self.parent, self.child)
|
||||
|
||||
|
||||
class Department(Base):
|
||||
"""
|
||||
Represents a department within the organization.
|
||||
|
|
Loading…
Reference in a new issue