mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 02:19:58 -03:30
Update status choices for projects, inventory sources and job templates to only return options applicable to the specific object type.
This commit is contained in:
parent
b61eae4bac
commit
b3aac6bb9e
@ -615,6 +615,7 @@ class ProjectSerializer(UnifiedJobTemplateSerializer, ProjectOptionsSerializer):
|
||||
|
||||
playbooks = serializers.Field(source='playbooks', help_text='Array of playbooks available within this project.')
|
||||
scm_delete_on_next_update = serializers.Field(source='scm_delete_on_next_update')
|
||||
status = ChoiceField(source='status', choices=Project.PROJECT_STATUS_CHOICES, read_only=True, required=False)
|
||||
last_update_failed = serializers.Field(source='last_update_failed')
|
||||
last_updated = serializers.Field(source='last_updated')
|
||||
|
||||
@ -984,7 +985,8 @@ class InventorySourceOptionsSerializer(BaseSerializer):
|
||||
|
||||
|
||||
class InventorySourceSerializer(UnifiedJobTemplateSerializer, InventorySourceOptionsSerializer):
|
||||
|
||||
|
||||
status = ChoiceField(source='status', choices=InventorySource.INVENTORY_SOURCE_STATUS_CHOICES, read_only=True, required=False)
|
||||
last_update_failed = serializers.Field(source='last_update_failed')
|
||||
last_updated = serializers.Field(source='last_updated')
|
||||
|
||||
@ -1218,6 +1220,8 @@ class JobOptionsSerializer(BaseSerializer):
|
||||
|
||||
class JobTemplateSerializer(UnifiedJobTemplateSerializer, JobOptionsSerializer):
|
||||
|
||||
status = ChoiceField(source='status', choices=JobTemplate.JOB_TEMPLATE_STATUS_CHOICES, read_only=True, required=False)
|
||||
|
||||
class Meta:
|
||||
model = JobTemplate
|
||||
fields = ('*', 'host_config_key', 'ask_variables_on_launch')
|
||||
|
||||
@ -20,6 +20,7 @@ from django.db import models
|
||||
from django.db import transaction
|
||||
from django.core.exceptions import ValidationError, NON_FIELD_ERRORS
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.timezone import now
|
||||
|
||||
@ -47,21 +48,31 @@ class UnifiedJobTemplate(PolymorphicModel, CommonModelNameNotUnique):
|
||||
Concrete base class for unified job templates.
|
||||
'''
|
||||
|
||||
STATUS_CHOICES = [
|
||||
# Common to all:
|
||||
COMMON_STATUS_CHOICES = [
|
||||
('never updated', 'Never Updated'), # A job has never been run using this template.
|
||||
('running', 'Running'), # A job is currently running (or pending/waiting) using this template.
|
||||
('failed', 'Failed'), # The last completed job using this template failed (failed, error, canceled).
|
||||
('successful', 'Successful'), # The last completed job using this template succeeded.
|
||||
# For Project only:
|
||||
]
|
||||
|
||||
PROJECT_STATUS_CHOICES = COMMON_STATUS_CHOICES + [
|
||||
('ok', 'OK'), # Project is not configured for SCM and path exists.
|
||||
('missing', 'Missing'), # Project path does not exist.
|
||||
# For Inventory Source only:
|
||||
]
|
||||
|
||||
INVENTORY_SOURCE_STATUS_CHOICES = COMMON_STATUS_CHOICES + [
|
||||
('none', _('No External Source')), # Inventory source is not configured to update from an external source.
|
||||
]
|
||||
|
||||
JOB_TEMPLATE_STATUS_CHOICES = COMMON_STATUS_CHOICES
|
||||
|
||||
DEPRECATED_STATUS_CHOICES = [
|
||||
# No longer used for Project / Inventory Source:
|
||||
('updating', _('Updating')), # Same as running.
|
||||
]
|
||||
|
||||
ALL_STATUS_CHOICES = SortedDict(PROJECT_STATUS_CHOICES + INVENTORY_SOURCE_STATUS_CHOICES + JOB_TEMPLATE_STATUS_CHOICES + DEPRECATED_STATUS_CHOICES).items()
|
||||
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
unique_together = [('polymorphic_ctype', 'name')]
|
||||
@ -119,7 +130,7 @@ class UnifiedJobTemplate(PolymorphicModel, CommonModelNameNotUnique):
|
||||
)
|
||||
status = models.CharField(
|
||||
max_length=32,
|
||||
choices=STATUS_CHOICES,
|
||||
choices=ALL_STATUS_CHOICES,
|
||||
default='ok',
|
||||
editable=False,
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user