mirror of
https://github.com/ansible/awx.git
synced 2026-03-03 09:48:51 -03:30
Move RelatedJob mixin to Project
This commit is contained in:
@@ -234,7 +234,7 @@ class ProjectOptions(models.Model):
|
||||
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
|
||||
'''
|
||||
@@ -451,16 +451,21 @@ 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 []
|
||||
'''
|
||||
RelatedJobsMixin
|
||||
'''
|
||||
def _get_active_jobs(self):
|
||||
return UnifiedJob.objects.non_polymorphic().filter(
|
||||
models.Q(status__in=ACTIVE_STATES) &
|
||||
(
|
||||
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.
|
||||
'''
|
||||
@@ -575,15 +580,4 @@ class ProjectUpdate(UnifiedJob, ProjectOptions, JobNotificationMixin, TaskManage
|
||||
return self.global_instance_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)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user