def has_permission(user, permission, course_id=None): assert isinstance(course_id, (type(None), CourseKey)) request_cache_dict = DEFAULT_REQUEST_CACHE.data cache_key = "django_comment_client.permissions.has_permission.all_permissions.{}.{}".format( user.id, course_id) if cache_key in request_cache_dict: all_permissions = request_cache_dict[cache_key] else: all_permissions = all_permissions_for_user_in_course(user, course_id) request_cache_dict[cache_key] = all_permissions return permission in all_permissions
def has_permission(user, permission, course_id=None): assert isinstance(course_id, (NoneType, CourseKey)) request_cache_dict = DEFAULT_REQUEST_CACHE.data cache_key = "django_comment_client.permissions.has_permission.all_permissions.{}.{}".format( user.id, course_id ) if cache_key in request_cache_dict: all_permissions = request_cache_dict[cache_key] else: all_permissions = all_permissions_for_user_in_course(user, course_id) request_cache_dict[cache_key] = all_permissions return permission in all_permissions