Просмотр исходного кода

Fixes #2678: Fix error when viewing webhook in admin UI without write permission

Jeremy Stretch 7 лет назад
Родитель
Сommit
6460c95e00
2 измененных файлов с 3 добавлено и 1 удалено
  1. 1 0
      CHANGELOG.md
  2. 2 1
      netbox/extras/admin.py

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@ v2.5.1 (FUTURE)
 
 * [#2666](https://github.com/digitalocean/netbox/issues/2666) - Correct display of length unit in cables list
 * [#2676](https://github.com/digitalocean/netbox/issues/2676) - Fix exception when passing dictionary value to a ChoiceField
+* [#2678](https://github.com/digitalocean/netbox/issues/2678) - Fix error when viewing webhook in admin UI without write permission
 * [#2680](https://github.com/digitalocean/netbox/issues/2680) - Disallow POST requests to `/dcim/interface-connections/` API endpoint
 
 ---

+ 2 - 1
netbox/extras/admin.py

@@ -30,7 +30,8 @@ class WebhookForm(forms.ModelForm):
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
 
-        order_content_types(self.fields['obj_type'])
+        if 'obj_type' in self.fields:
+            order_content_types(self.fields['obj_type'])
 
 
 @admin.register(Webhook, site=admin_site)