Don't blow away the role cache when updating.

Instead of refetching the role cache fresh every time we want to add a new role to a user, just manually add the role object.  We have it available to us, the model, not a distilled-down version.  Add that in and leave the existing cache.
This commit is contained in:
Toby Lawrence
2016-02-11 14:43:53 -05:00
parent 9ae0dada4c
commit 9fe2de8a1c

View File

@@ -54,6 +54,9 @@ class RoleCache(object):
for access_role in self._roles
)
def add_role(self, role):
self._roles.add(role)
class AccessRole(object):
"""
@@ -157,7 +160,8 @@ class RoleBase(AccessRole):
entry = CourseAccessRole(user=user, role=self._role_name, course_id=self.course_key, org=self.org)
entry.save()
if hasattr(user, '_roles'):
del user._roles
# del user._roles
user._roles.add_role(entry)
def remove_users(self, *users):
"""