diff --git a/awx/conf/registry.py b/awx/conf/registry.py index 92e58200aa..00a2cd4057 100644 --- a/awx/conf/registry.py +++ b/awx/conf/registry.py @@ -116,6 +116,9 @@ class SettingsRegistry(object): def is_setting_encrypted(self, setting): return bool(self._registry.get(setting, {}).get('encrypted', False)) + def is_setting_read_only(self, setting): + return bool(self._registry.get(setting, {}).get('read_only', False)) + def get_setting_field(self, setting, mixin_class=None, for_user=False, **kwargs): from rest_framework.fields import empty field_kwargs = {} diff --git a/awx/conf/views.py b/awx/conf/views.py index 4fb4cd60c7..e476f5b0cf 100644 --- a/awx/conf/views.py +++ b/awx/conf/views.py @@ -122,16 +122,18 @@ class SettingSingletonDetail(RetrieveUpdateDestroyAPIView): user = self.request.user if self.category_slug == 'user' else None settings_change_list = [] for key, value in serializer.validated_data.items(): - if key == 'LICENSE': + if key == 'LICENSE' or settings_registry.is_setting_read_only(key): continue - if settings_registry.is_setting_encrypted(key) and isinstance(value, basestring) and value.startswith('$encrypted$'): + if settings_registry.is_setting_encrypted(key) and \ + isinstance(value, basestring) and \ + value.startswith('$encrypted$'): continue setattr(serializer.instance, key, value) setting = settings_qs.filter(key=key).order_by('pk').first() if not setting: setting = Setting.objects.create(key=key, user=user, value=value) settings_change_list.append(key) - elif setting.value != value or type(setting.value) != type(value): + elif setting.value != value: setting.value = value setting.save(update_fields=['value']) settings_change_list.append(key)