mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 04:10:44 -03:30
Project needs to expose all of its ProjectUpdate jobs in an active state
This commit is contained in:
parent
0689cea806
commit
f594f62dfc
@ -447,6 +447,14 @@ class Project(UnifiedJobTemplate, ProjectOptions, ResourceMixin, CustomVirtualEn
|
||||
def get_absolute_url(self, request=None):
|
||||
return reverse('api:project_detail', kwargs={'pk': self.pk}, request=request)
|
||||
|
||||
def get_active_jobs(self):
|
||||
for project_update in self.project_updates.all():
|
||||
active_jobs = project_update.get_active_jobs()
|
||||
if active_jobs is None:
|
||||
continue
|
||||
return active_jobs
|
||||
return []
|
||||
|
||||
|
||||
class ProjectUpdate(UnifiedJob, ProjectOptions, JobNotificationMixin, TaskManagerProjectUpdateMixin, RelatedJobsMixin):
|
||||
'''
|
||||
@ -568,10 +576,10 @@ class ProjectUpdate(UnifiedJob, ProjectOptions, JobNotificationMixin, TaskManage
|
||||
'''
|
||||
def _get_active_jobs(self):
|
||||
return UnifiedJob.objects.non_polymorphic().filter(
|
||||
Q(status__in=ACTIVE_STATES) &
|
||||
models.Q(status__in=ACTIVE_STATES) &
|
||||
(
|
||||
Q(Job___project=self) |
|
||||
Q(ProjectUpdate___project=self)
|
||||
models.Q(Job___project=self) |
|
||||
models.Q(ProjectUpdate___project=self)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@ -251,3 +251,10 @@ def test_project_unique_together_with_org(organization):
|
||||
proj2.validate_unique()
|
||||
proj2 = Project(name='foo', organization=None)
|
||||
proj2.validate_unique()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_project_delete(delete, organization, admin):
|
||||
proj = Project(name='foo', organization=organization)
|
||||
proj.save()
|
||||
delete(reverse('api:project_detail', kwargs={'pk':proj.id,}), admin)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user