1 | from .model import * |
||
2 | from . import account |
||
3 | from . import user |
||
4 | from . import pool |
||
5 | |||
6 | View Code Duplication | class PoolUser(Base): |
|
0 ignored issues
–
show
Duplication
introduced
by
![]() |
|||
7 | __tablename__ = 'pool_users' |
||
8 | |||
9 | id = Column(Integer, primary_key=True, nullable=False) |
||
10 | pool_id = Column(Integer, ForeignKey("accounts.id"), nullable=False) |
||
11 | user_id = Column(Integer, ForeignKey("users.id"), nullable=False) |
||
12 | |||
13 | enabled = Column(Boolean, default=True, nullable=False) |
||
14 | deleted = Column(Boolean, default=False, nullable=False) |
||
15 | |||
16 | pool = relationship( |
||
17 | account.Account, |
||
18 | primaryjoin="and_(PoolUser.pool_id==Account.id, PoolUser.deleted==False)", |
||
19 | backref="users" |
||
20 | ) |
||
21 | user = relationship( |
||
22 | user.User, |
||
23 | primaryjoin="and_(PoolUser.user_id==User.id, PoolUser.deleted==False)", |
||
24 | backref="pools" |
||
25 | ) |
||
26 | |||
27 | def __init__(self, pool, user): |
||
28 | self.pool_id = pool.id |
||
29 | self.user_id = user.id |
||
30 | |||
31 | @classmethod |
||
32 | def from_id(cls, id): |
||
33 | return DBSession.query(cls).filter(cls.id == id).one() |
||
34 |