Skip to content

Commit

Permalink
Merge pull request #9899 from seiwailai/issue-9898-invalid-type-field
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
softwarefactory-project-zuul[bot] authored Apr 19, 2021
2 parents 16bd9b4 + a4de7ff commit 7223ab4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion awx/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
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):
Expand Down Expand Up @@ -78,7 +81,9 @@ def get_field_info(self, field):
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:
Expand Down

0 comments on commit 7223ab4

Please sign in to comment.