Skip to content

Commit

Permalink
Remove event hosts relationship as well
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding committed Jan 16, 2020
1 parent 37714d5 commit 2a09fa0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
2 changes: 0 additions & 2 deletions awx/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3837,8 +3837,6 @@ def get_related(self, obj):
res['children'] = self.reverse('api:job_event_children_list', kwargs={'pk': obj.pk})
if obj.host_id:
res['host'] = self.reverse('api:host_detail', kwargs={'pk': obj.host_id})
if obj.hosts.exists():
res['hosts'] = self.reverse('api:job_event_hosts_list', kwargs={'pk': obj.pk})
return res

def get_summary_fields(self, obj):
Expand Down
7 changes: 6 additions & 1 deletion awx/api/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3814,6 +3814,12 @@ class JobEventHostsList(HostRelatedSearchMixin, SubListAPIView):
relationship = 'hosts'
name = _('Job Event Hosts List')

def get_queryset(self):
parent_event = self.get_parent_object()
self.check_parent_access(parent_event)
qs = self.request.user.get_queryset(self.model).filter(job_events_as_primary_host=parent_event)
return qs


class BaseJobEventsList(NoTruncateMixin, SubListAPIView):

Expand Down Expand Up @@ -3855,7 +3861,6 @@ def get_queryset(self):
self.check_parent_access(job)
qs = job.job_events
qs = qs.select_related('host')
qs = qs.prefetch_related('hosts')
return qs.all()


Expand Down
2 changes: 1 addition & 1 deletion awx/main/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -2238,7 +2238,7 @@ class JobEventAccess(BaseAccess):
'''

model = JobEvent
prefetch_related = ('hosts', 'job__job_template', 'host',)
prefetch_related = ('job__job_template', 'host',)

def filtered_queryset(self):
return self.model.objects.filter(
Expand Down
17 changes: 17 additions & 0 deletions awx/main/migrations/0104_v370_remove_jobevent_hosts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 2.2.8 on 2020-01-15 18:01

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('main', '0103_v370_remove_jobevent_parent'),
]

operations = [
migrations.RemoveField(
model_name='jobevent',
name='hosts',
),
]
5 changes: 0 additions & 5 deletions awx/main/models/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,6 @@ class Meta:
default='',
editable=False,
)
hosts = models.ManyToManyField(
'Host',
related_name='job_events',
editable=False,
)
parent_uuid = models.CharField(
max_length=1024,
default='',
Expand Down

0 comments on commit 2a09fa0

Please sign in to comment.