Commit 9fe2de8a by Toby Lawrence

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.
parent 9ae0dada
...@@ -54,6 +54,9 @@ class RoleCache(object): ...@@ -54,6 +54,9 @@ class RoleCache(object):
for access_role in self._roles for access_role in self._roles
) )
def add_role(self, role):
self._roles.add(role)
class AccessRole(object): class AccessRole(object):
""" """
...@@ -157,7 +160,8 @@ class RoleBase(AccessRole): ...@@ -157,7 +160,8 @@ class RoleBase(AccessRole):
entry = CourseAccessRole(user=user, role=self._role_name, course_id=self.course_key, org=self.org) entry = CourseAccessRole(user=user, role=self._role_name, course_id=self.course_key, org=self.org)
entry.save() entry.save()
if hasattr(user, '_roles'): if hasattr(user, '_roles'):
del user._roles # del user._roles
user._roles.add_role(entry)
def remove_users(self, *users): def remove_users(self, *users):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment