def _check_conditions_permissions(user, permissions, course_id, content):
 def test(user, per, operator='or'):
  if isinstance(per, basestring):
   if (per in CONDITIONS):
    return _check_condition(user, per, content)
   return has_permission(user, per, course_id=course_id)
  elif (isinstance(per, list) and (operator in ['and', 'or'])):
   results = [test(user, x, operator='and') for x in per]
   if (operator == 'or'):
    return (True in results)
   elif (operator == 'and'):
    return (False not in results)
 return test(user, permissions, operator='or')

def _check_conditions_permissions ( user , permissions , course_id , content ) : def test ( user , per , operator = 'or' ) : if isinstance ( per , basestring ) : if ( per in CONDITIONS ) : return _check_condition ( user , per , content ) return has_permission ( user , per , course_id = course_id ) elif ( isinstance ( per , list ) and ( operator in [ 'and' , 'or' ] ) ) : results = [ test ( user , x , operator = 'and' ) for x in per ] if ( operator == 'or' ) : return ( True in results ) elif ( operator == 'and' ) : return ( False not in results ) return test ( user , permissions , operator = 'or' )
accepts a list of permissions and proceed if any of the permission is valid .