Merge pull request #1352 from wwitzel3/rbac

RBAC PR Fixes
This commit is contained in:
Akita Noek
2016-03-31 10:06:20 -04:00
2 changed files with 3 additions and 6 deletions

View File

@@ -238,7 +238,7 @@ def migrate_projects(apps, schema_editor):
original_project_name = project.name original_project_name = project.name
project_orgs = project.deprecated_organizations.distinct().all() project_orgs = project.deprecated_organizations.distinct().all()
if project_orgs.count() > 1: if len(project_orgs) > 1:
first_org = None first_org = None
for org in project_orgs: for org in project_orgs:
if first_org is None: if first_org is None:

View File

@@ -136,11 +136,8 @@ class Role(CommonModelNameNotUnique):
@staticmethod @staticmethod
def singleton(name): def singleton(name):
try: role, _ = Role.objects.get_or_create(singleton_name=name, name=name)
return Role.objects.get(singleton_name=name) return role
except Role.DoesNotExist:
ret = Role.objects.create(singleton_name=name, name=name)
return ret
def is_ancestor_of(self, role): def is_ancestor_of(self, role):
return role.ancestors.filter(id=self.id).exists() return role.ancestors.filter(id=self.id).exists()