def has_forum_access(uname, course_id, rolename):
 try:
  role = Role.objects.get(name=rolename, course_id=course_id)
 except Role.DoesNotExist:
  return False
 return role.users.filter(username=uname).exists()

def has_forum_access ( uname , course_id , rolename ) : try : role = Role . objects . get ( name = rolename , course_id = course_id ) except Role . DoesNotExist : return False return role . users . filter ( username = uname ) . exists ( )
boolean operation which tests a users role-based permissions .