Flesh out some of the organization methods and fix the models.
This commit is contained in:
parent
ecc4ad6e0f
commit
4c0f987af3
5 changed files with 181 additions and 64 deletions
|
@ -38,9 +38,16 @@ class User(BaseModel):
|
|||
|
||||
|
||||
class Team(BaseModel):
|
||||
name = CharField()
|
||||
name = CharField(index=True)
|
||||
organization = ForeignKeyField(User, index=True)
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
indexes = (
|
||||
# A team name must be unique within an organization
|
||||
(('name', 'organization'), True),
|
||||
)
|
||||
|
||||
|
||||
class TeamMember(BaseModel):
|
||||
user = ForeignKeyField(User, index=True)
|
||||
|
@ -97,13 +104,15 @@ class Role(BaseModel):
|
|||
|
||||
|
||||
class RepositoryPermission(BaseModel):
|
||||
user = ForeignKeyField(User, index=True)
|
||||
team = ForeignKeyField(Team, index=True, null=True)
|
||||
user = ForeignKeyField(User, index=True, null=True)
|
||||
repository = ForeignKeyField(Repository, index=True)
|
||||
role = ForeignKeyField(Role)
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
indexes = (
|
||||
(('team', 'repository'), True),
|
||||
(('user', 'repository'), True),
|
||||
)
|
||||
|
||||
|
@ -116,7 +125,6 @@ class TeamPermission(BaseModel):
|
|||
class Meta:
|
||||
database = db
|
||||
indexes = (
|
||||
# A team may only have one permission level in an org
|
||||
(('team', 'organization'), True),
|
||||
)
|
||||
|
||||
|
|
Reference in a new issue