mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 18:37:36 -02:30
Merge pull request #1586 from wwitzel3/devel
Moved RelatedJobMixin impl to Project instead of ProjectUpdate
This commit is contained in:
@@ -456,7 +456,7 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, SurveyJobTemplateMixin, Resour
|
|||||||
RelatedJobsMixin
|
RelatedJobsMixin
|
||||||
'''
|
'''
|
||||||
def _get_active_jobs(self):
|
def _get_active_jobs(self):
|
||||||
return Job.objects.filter(status__in=ACTIVE_STATES)
|
return Job.objects.filter(status__in=ACTIVE_STATES, job_template=self)
|
||||||
|
|
||||||
|
|
||||||
class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin, TaskManagerJobMixin):
|
class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin, TaskManagerJobMixin):
|
||||||
|
|||||||
@@ -25,7 +25,11 @@ from awx.main.models.notifications import (
|
|||||||
NotificationTemplate,
|
NotificationTemplate,
|
||||||
JobNotificationMixin,
|
JobNotificationMixin,
|
||||||
)
|
)
|
||||||
from awx.main.models.unified_jobs import * # noqa
|
from awx.main.models.unified_jobs import (
|
||||||
|
UnifiedJob,
|
||||||
|
UnifiedJobTemplate,
|
||||||
|
ACTIVE_STATES,
|
||||||
|
)
|
||||||
from awx.main.models.mixins import (
|
from awx.main.models.mixins import (
|
||||||
ResourceMixin,
|
ResourceMixin,
|
||||||
TaskManagerProjectUpdateMixin,
|
TaskManagerProjectUpdateMixin,
|
||||||
@@ -230,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
|
||||||
'''
|
'''
|
||||||
@@ -447,8 +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)
|
||||||
|
|
||||||
|
'''
|
||||||
|
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.
|
Internal job for tracking project updates from SCM.
|
||||||
'''
|
'''
|
||||||
@@ -563,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(
|
|
||||||
Q(status__in=ACTIVE_STATES) &
|
|
||||||
(
|
|
||||||
Q(Job___project=self) |
|
|
||||||
Q(ProjectUpdate___project=self)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ class WorkflowJobTemplate(UnifiedJobTemplate, WorkflowJobOptions, SurveyJobTempl
|
|||||||
RelatedJobsMixin
|
RelatedJobsMixin
|
||||||
'''
|
'''
|
||||||
def _get_active_jobs(self):
|
def _get_active_jobs(self):
|
||||||
return WorkflowJob.objects.filter(status__in=ACTIVE_STATES)
|
return WorkflowJob.objects.filter(status__in=ACTIVE_STATES, workflow_job_template=self)
|
||||||
|
|
||||||
|
|
||||||
class WorkflowJob(UnifiedJob, WorkflowJobOptions, SurveyJobMixin, JobNotificationMixin):
|
class WorkflowJob(UnifiedJob, WorkflowJobOptions, SurveyJobMixin, JobNotificationMixin):
|
||||||
|
|||||||
@@ -251,3 +251,10 @@ def test_project_unique_together_with_org(organization):
|
|||||||
proj2.validate_unique()
|
proj2.validate_unique()
|
||||||
proj2 = Project(name='foo', organization=None)
|
proj2 = Project(name='foo', organization=None)
|
||||||
proj2.validate_unique()
|
proj2.validate_unique()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_project_delete(delete, organization, admin_user):
|
||||||
|
proj = Project(name='foo', organization=organization)
|
||||||
|
proj.save()
|
||||||
|
delete(reverse('api:project_detail', kwargs={'pk':proj.id,}), admin_user)
|
||||||
|
|||||||
Reference in New Issue
Block a user