def check_user_permission(user, permission_codename, directory, check_default=True):
 if user.is_superuser:
  return True
 permissions = get_matching_permissions(user, directory, check_default)
 return (('administrate' in permissions) or (permission_codename in permissions))

def check_user_permission ( user , permission_codename , directory , check_default = True ) : if user . is_superuser : return True permissions = get_matching_permissions ( user , directory , check_default ) return ( ( 'administrate' in permissions ) or ( permission_codename in permissions ) )
checks if the current user has the permission to perform permission_codename .