mirror of
https://github.com/ansible/awx.git
synced 2026-03-08 21:19:26 -02:30
Numerous model-related updates and supporing changes, including:
- Add variables field on Host/Group models and remove separate VariableData model. - Add data migrations for existing variable data. - Update views, serializers and tests to keep roughly the same API interface for variable data. - Add has_active_failures properties on Group/Host models to provide indication of last job status. - Add job_tags field on JobTemplate/Job models to specify tags to ansible-playbook. - Add host_config_key field to JobTemplate model for use by empheral hosts. - Add job_args, job_cwd and job_env fields to Job model to capture more info from running the job. - Add failed flag on JobHostSummary model. - Add play/task fields on JobEvent model to capture new context variables from callback. - Add parent field on JobEvent model to capture hierarchy of job events. - Add hosts field on JobEvent model to capture all hosts associated with the event (especially useful for parent events in the hierarchy). - Removed existing Tag model, replace with django-taggit instead. - Removed existing AuditLog model, replacement TBD.
This commit is contained in:
@@ -29,46 +29,6 @@ class PlaybookSelect(forms.Select):
|
||||
opt = opt.replace('">', '" class="project-%s">' % obj.project.pk)
|
||||
return opt
|
||||
|
||||
class HostAdminForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Host
|
||||
|
||||
vdata = JSONFormField(label=_('Variable data'), required=False, widget=forms.Textarea(attrs={'class': 'vLargeTextField'}))
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(HostAdminForm, self).__init__(*args, **kwargs)
|
||||
if self.instance.variable_data:
|
||||
print repr(self.instance.variable_data.data)
|
||||
self.initial['vdata'] = self.instance.variable_data.data
|
||||
|
||||
def save(self, commit=True):
|
||||
instance = super(HostAdminForm, self).save(commit=commit)
|
||||
save_m2m = getattr(self, 'save_m2m', lambda: None)
|
||||
vdata = self.cleaned_data.get('vdata', '')
|
||||
def new_save_m2m():
|
||||
save_m2m()
|
||||
if not instance.variable_data:
|
||||
instance.variable_data = VariableData.objects.create(data=vdata)
|
||||
instance.save()
|
||||
else:
|
||||
variable_data = instance.variable_data
|
||||
# FIXME!!!
|
||||
#variable_data.data = vdata
|
||||
#variable_data.save()
|
||||
if commit:
|
||||
new_save_m2m()
|
||||
else:
|
||||
self.save_m2m = new_save_m2m
|
||||
return instance
|
||||
|
||||
class GroupForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = Host
|
||||
|
||||
variable_data = JSONFormField(required=False, widget=forms.Textarea(attrs={'class': 'vLargeTextField'}))
|
||||
|
||||
class ProjectAdminForm(forms.ModelForm):
|
||||
'''Custom admin form for Projects.'''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user