Merge pull request #6451 from jbradberry/related-webhook-credential-link

Optionally add the webhook_credential link to related

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-03-27 14:38:25 +00:00 committed by GitHub
commit c4ed9a14ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -2900,6 +2900,8 @@ class JobTemplateSerializer(JobTemplateMixin, UnifiedJobTemplateSerializer, JobO
res['callback'] = self.reverse('api:job_template_callback', kwargs={'pk': obj.pk})
if obj.organization_id:
res['organization'] = self.reverse('api:organization_detail', kwargs={'pk': obj.organization_id})
if obj.webhook_credential_id:
res['webhook_credential'] = self.reverse('api:credential_detail', kwargs={'pk': obj.webhook_credential_id})
return res
def validate(self, attrs):
@ -3390,6 +3392,8 @@ class WorkflowJobTemplateSerializer(JobTemplateMixin, LabelsListMixin, UnifiedJo
)
if obj.organization:
res['organization'] = self.reverse('api:organization_detail', kwargs={'pk': obj.organization.pk})
if obj.webhook_credential_id:
res['webhook_credential'] = self.reverse('api:credential_detail', kwargs={'pk': obj.webhook_credential_id})
return res
def validate_extra_vars(self, value):

View File

@ -31,6 +31,7 @@ def job_template(mocker):
mock_jt.validation_errors = mock_JT_resource_data
mock_jt.webhook_service = ''
mock_jt.organization_id = None
mock_jt.webhook_credential_id = None
return mock_jt