Update the permission error to include max_hosts and the current host count

This commit is contained in:
Jeff Bradberry 2019-02-20 13:15:51 -05:00
parent 97cc467ae1
commit 6ac51b7b13

View File

@ -345,12 +345,16 @@ class BaseAccess(object):
active_count = Host.objects.org_active_count(org.id)
if active_count > org.max_hosts:
raise PermissionDenied(_("The organization host limit has been exceeded."))
raise PermissionDenied(
_("Organization host limit of %s has been exceeded, %s hosts active.") %
(org.max_hosts, active_count))
if add_host_name:
host_exists = Host.objects.filter(inventory__organization=org.id, name=add_host_name).exists()
if not host_exists and active_count == org.max_hosts:
raise PermissionDenied(_("The organization host limit has been exceeded."))
raise PermissionDenied(
_("Organization host limit of %s has been exceeded, %s hosts active.") %
(org.max_hosts, active_count))
def get_user_capabilities(self, obj, method_list=[], parent_obj=None, capabilities_cache={}):
if obj is None: