diff --git a/docs/release-notes/version-2.7.md b/docs/release-notes/version-2.7.md index bdc1d6f41..fd34742ef 100644 --- a/docs/release-notes/version-2.7.md +++ b/docs/release-notes/version-2.7.md @@ -1,3 +1,11 @@ +# v2.7.2 (FUTURE) + +## Bug Fixes + +* [#3951](https://github.com/netbox-community/netbox/issues/3951) - Fix exception in webhook worker due to missing constant + +--- + # v2.7.1 (2020-01-16) ## Bug Fixes diff --git a/netbox/extras/webhooks_worker.py b/netbox/extras/webhooks_worker.py index e8fcc5f0f..6f7ede4e4 100644 --- a/netbox/extras/webhooks_worker.py +++ b/netbox/extras/webhooks_worker.py @@ -6,8 +6,7 @@ import requests from django_rq import job from rest_framework.utils.encoders import JSONEncoder -from .choices import ObjectChangeActionChoices -from .constants import * +from .choices import ObjectChangeActionChoices, WebhookContentTypeChoices @job('default') @@ -35,9 +34,9 @@ def process_webhook(webhook, data, model_name, event, timestamp, username, reque 'headers': headers } - if webhook.http_content_type == WEBHOOK_CT_JSON: + if webhook.http_content_type == WebhookContentTypeChoices.CONTENTTYPE_JSON: params.update({'data': json.dumps(payload, cls=JSONEncoder)}) - elif webhook.http_content_type == WEBHOOK_CT_X_WWW_FORM_ENCODED: + elif webhook.http_content_type == WebhookContentTypeChoices.CONTENTTYPE_FORMDATA: params.update({'data': payload}) prepared_request = requests.Request(**params).prepare() @@ -61,5 +60,7 @@ def process_webhook(webhook, data, model_name, event, timestamp, username, reque return 'Status {} returned, webhook successfully processed.'.format(response.status_code) else: raise requests.exceptions.RequestException( - "Status {} returned with content '{}', webhook FAILED to process.".format(response.status_code, response.content) + "Status {} returned with content '{}', webhook FAILED to process.".format( + response.status_code, response.content + ) )