From 5bce9ee215cfa3555c115bad5499f9f6d94efe31 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Thu, 21 Jul 2016 17:22:11 -0400 Subject: [PATCH 1/2] If you have use_role on an inventory, make it so you can use it in scan jobs #3077 --- awx/main/access.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/awx/main/access.py b/awx/main/access.py index 5b2ee91851..19b4e34f70 100644 --- a/awx/main/access.py +++ b/awx/main/access.py @@ -906,8 +906,7 @@ class JobTemplateAccess(BaseAccess): project = get_value(Project, 'project') if 'job_type' in data and data['job_type'] == PERM_INVENTORY_SCAN: if inventory: - org = inventory.organization - accessible = self.user in org.admin_role + accessible = self.user in inventory.use_role else: accessible = False if not project and accessible: From 64d653bc618fd53d038f3ffdc3b3707f3b94c961 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Fri, 22 Jul 2016 09:42:00 -0400 Subject: [PATCH 2/2] Equate '' to None for foreign key references when PUTing to a job template The UI will sometimes send an empty string instead of null, we already handle this in our serializer and treat it as null, so this change brings our access system in line with the expectation that those two things should be equal. Possibly related to #3077 --- awx/main/access.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/awx/main/access.py b/awx/main/access.py index 19b4e34f70..592359a031 100644 --- a/awx/main/access.py +++ b/awx/main/access.py @@ -978,7 +978,8 @@ class JobTemplateAccess(BaseAccess): for k, v in data.items(): if hasattr(obj, k) and getattr(obj, k) != v: - if k not in field_whitelist and v != getattr(obj, '%s_id' % k, None): + if k not in field_whitelist and v != getattr(obj, '%s_id' % k, None) \ + and not (hasattr(obj, '%s_id' % k) and getattr(obj, '%s_id' % k) is None and v == ''): # Equate '' to None in the case of foreign keys return False return True