mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 23:46:05 -03:30
Expand dbconfig support
* Support updating settings values * Support activity stream endpoint * Support clearing value * Improve type conversion system for displaying values
This commit is contained in:
@@ -53,6 +53,7 @@ class ActivityStream(models.Model):
|
||||
ad_hoc_command = models.ManyToManyField("AdHocCommand", blank=True)
|
||||
schedule = models.ManyToManyField("Schedule", blank=True)
|
||||
custom_inventory_script = models.ManyToManyField("CustomInventoryScript", blank=True)
|
||||
tower_settings = models.ManyToManyField("TowerSettings", blank=True)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('api:activity_stream_detail', args=(self.pk,))
|
||||
|
||||
@@ -20,6 +20,7 @@ class TowerSettings(CreatedModifiedModel):
|
||||
('int', _('Integer')),
|
||||
('float', _('Decimal')),
|
||||
('json', _('JSON')),
|
||||
('bool', _('Boolean')),
|
||||
('password', _('Password')),
|
||||
('list', _('List'))
|
||||
]
|
||||
@@ -43,3 +44,15 @@ class TowerSettings(CreatedModifiedModel):
|
||||
editable=False,
|
||||
)
|
||||
|
||||
@property
|
||||
def value_converted(self):
|
||||
if self.value_type == 'json':
|
||||
converted_type = json.loads(self.value)
|
||||
elif self.value_type == 'password':
|
||||
converted_type = self.value
|
||||
elif self.value_type == 'list':
|
||||
converted_type = [x.strip() for x in self.value.split(',')]
|
||||
else:
|
||||
t = __builtins__[self.value_type]
|
||||
converted_type = t(self.value)
|
||||
return converted_type
|
||||
|
||||
Reference in New Issue
Block a user