mirror of
https://github.com/ansible/awx.git
synced 2026-04-05 01:59:25 -02:30
Move RelatedJob mixin to Project
This commit is contained in:
@@ -234,7 +234,7 @@ class ProjectOptions(models.Model):
|
|||||||
return proj_path + '.lock'
|
return proj_path + '.lock'
|
||||||
|
|
||||||
|
|
||||||
class Project(UnifiedJobTemplate, ProjectOptions, ResourceMixin, CustomVirtualEnvMixin):
|
class Project(UnifiedJobTemplate, ProjectOptions, ResourceMixin, CustomVirtualEnvMixin, RelatedJobsMixin):
|
||||||
'''
|
'''
|
||||||
A project represents a playbook git repo that can access a set of inventories
|
A project represents a playbook git repo that can access a set of inventories
|
||||||
'''
|
'''
|
||||||
@@ -451,16 +451,21 @@ class Project(UnifiedJobTemplate, ProjectOptions, ResourceMixin, CustomVirtualEn
|
|||||||
def get_absolute_url(self, request=None):
|
def get_absolute_url(self, request=None):
|
||||||
return reverse('api:project_detail', kwargs={'pk': self.pk}, request=request)
|
return reverse('api:project_detail', kwargs={'pk': self.pk}, request=request)
|
||||||
|
|
||||||
def get_active_jobs(self):
|
'''
|
||||||
for project_update in self.project_updates.all():
|
RelatedJobsMixin
|
||||||
active_jobs = project_update.get_active_jobs()
|
'''
|
||||||
if active_jobs is None:
|
def _get_active_jobs(self):
|
||||||
continue
|
return UnifiedJob.objects.non_polymorphic().filter(
|
||||||
return active_jobs
|
models.Q(status__in=ACTIVE_STATES) &
|
||||||
return []
|
(
|
||||||
|
models.Q(Job___project=self) |
|
||||||
|
models.Q(ProjectUpdate___project=self)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ProjectUpdate(UnifiedJob, ProjectOptions, JobNotificationMixin, TaskManagerProjectUpdateMixin, RelatedJobsMixin):
|
|
||||||
|
class ProjectUpdate(UnifiedJob, ProjectOptions, JobNotificationMixin, TaskManagerProjectUpdateMixin):
|
||||||
'''
|
'''
|
||||||
Internal job for tracking project updates from SCM.
|
Internal job for tracking project updates from SCM.
|
||||||
'''
|
'''
|
||||||
@@ -575,15 +580,4 @@ class ProjectUpdate(UnifiedJob, ProjectOptions, JobNotificationMixin, TaskManage
|
|||||||
return self.global_instance_groups
|
return self.global_instance_groups
|
||||||
return selected_groups
|
return selected_groups
|
||||||
|
|
||||||
'''
|
|
||||||
RelatedJobsMixin
|
|
||||||
'''
|
|
||||||
def _get_active_jobs(self):
|
|
||||||
return UnifiedJob.objects.non_polymorphic().filter(
|
|
||||||
models.Q(status__in=ACTIVE_STATES) &
|
|
||||||
(
|
|
||||||
models.Q(Job___project=self.project) |
|
|
||||||
models.Q(ProjectUpdate___project=self.project)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ def test_project_unique_together_with_org(organization):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_project_delete(delete, organization, admin):
|
def test_project_delete(delete, organization, admin_user):
|
||||||
proj = Project(name='foo', organization=organization)
|
proj = Project(name='foo', organization=organization)
|
||||||
proj.save()
|
proj.save()
|
||||||
delete(reverse('api:project_detail', kwargs={'pk':proj.id,}), admin)
|
delete(reverse('api:project_detail', kwargs={'pk':proj.id,}), admin_user)
|
||||||
|
|||||||
Reference in New Issue
Block a user