Check for member in application function, not user function
This commit is contained in:
@@ -7,7 +7,7 @@ from atst.models import EnvironmentRole
|
||||
class EnvironmentRoles(object):
|
||||
@classmethod
|
||||
def create(cls, user, environment, role):
|
||||
if user.is_app_member(environment.application):
|
||||
if environment.application.has_member(user):
|
||||
env_role = EnvironmentRole(user=user, environment=environment, role=role)
|
||||
if not user.cloud_id:
|
||||
user.cloud_id = app.csp.cloud.create_user(user)
|
||||
|
@@ -68,7 +68,7 @@ class Environments(object):
|
||||
def update_env_role(cls, environment, user, new_role):
|
||||
updated = False
|
||||
|
||||
if user.is_app_member(environment.application):
|
||||
if environment.application.has_member(user):
|
||||
if new_role is None:
|
||||
updated = EnvironmentRoles.delete(user.id, environment.id)
|
||||
else:
|
||||
|
@@ -52,6 +52,9 @@ class Application(
|
||||
def displayname(self):
|
||||
return self.name
|
||||
|
||||
def has_member(self, user):
|
||||
return user in self.users
|
||||
|
||||
def __repr__(self): # pragma: no cover
|
||||
return "<Application(name='{}', description='{}', portfolio='{}', id='{}')>".format(
|
||||
self.name, self.description, self.portfolio.name, self.id
|
||||
|
@@ -80,9 +80,6 @@ class User(
|
||||
def displayname(self):
|
||||
return self.full_name
|
||||
|
||||
def is_app_member(self, application):
|
||||
return self in application.users
|
||||
|
||||
def __repr__(self):
|
||||
return "<User(name='{}', dod_id='{}', email='{}', has_portfolios='{}', id='{}')>".format(
|
||||
self.full_name, self.dod_id, self.email, self.has_portfolios, self.id
|
||||
|
Reference in New Issue
Block a user