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:
@@ -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):
|
|||||||
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):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user