def available_perm_names(user):
roles = get_user_roles(user)<EOL>perm_names = set(p for role in roles for p in role.permission_names_list())<EOL>return [p.codename for p in user.user_permissions.all() if p.codename in perm_names]if roles else []<EOL>
Return a list of permissions codenames available to a user, based on that user's roles.
  i.e., keys for all "True" permissions from available_perm_status(user):
   Assert: set(available_perm_names(user)) == set(perm for perm,has_perm in available_perm_status(user) if has_perm)
   Query efficient; especially when prefetch_related('group', 'user_permissions') on user object.
   No side-effects; permissions are not created in DB as side-effect.