瀏覽代碼

added validation error for script and report constraint #15174

Abhimanyu Saharan 2 年之前
父節點
當前提交
50e5bb9717
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      netbox/users/forms/model_forms.py

+ 6 - 0
netbox/users/forms/model_forms.py

@@ -380,6 +380,12 @@ class ObjectPermissionForm(BootstrapMixin, forms.ModelForm):
                 constraints = [constraints]
             for ct in object_types:
                 model = ct.model_class()
+
+                if model._meta.model_name in ['script', 'report']:
+                    raise forms.ValidationError({
+                        'constraints': _('Constraints are not supported for this object type.')
+                    })
+
                 try:
                     tokens = {
                         CONSTRAINT_TOKEN_USER: 0,  # Replace token with a null user ID