mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 12:20:45 -03:30
Merge pull request #9899 from seiwailai/issue-9898-invalid-type-field
metadata: Fixes invalid model classes field. Fixes #9441. SUMMARY Set type' field's filterable as True only if the model classes contain type field such as UnifiedJob, WorkflowApproval, UnifiedJobTemplate, Project and SystemJobTemplate ISSUE TYPE Bugfix Pull Request COMPONENT NAME API - metadata.py AWX VERSION awx: 19.0.0 ADDITIONAL INFORMATION Reviewed-by: Shane McDonald <me@shanemcd.com> Reviewed-by: Sei Wai Lai <None>
This commit is contained in:
commit
7223ab4d29
@ -26,6 +26,9 @@ from awx.main.fields import JSONField, ImplicitRoleField
|
||||
from awx.main.models import NotificationTemplate
|
||||
from awx.main.tasks import AWXReceptorJob
|
||||
|
||||
# Polymorphic
|
||||
from polymorphic.models import PolymorphicModel
|
||||
|
||||
|
||||
class Metadata(metadata.SimpleMetadata):
|
||||
def get_field_info(self, field):
|
||||
@ -78,7 +81,9 @@ class Metadata(metadata.SimpleMetadata):
|
||||
field_info['help_text'] = field_help_text[field.field_name].format(verbose_name)
|
||||
|
||||
if field.field_name == 'type':
|
||||
field_info['filterable'] = True
|
||||
# Only include model classes with `type` field.
|
||||
if issubclass(serializer.Meta.model, PolymorphicModel):
|
||||
field_info['filterable'] = True
|
||||
else:
|
||||
for model_field in serializer.Meta.model._meta.fields:
|
||||
if field.field_name == model_field.name:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user