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

added validation error for script and report constraint #15174

Abhimanyu Saharan 2 лет назад
Родитель
Сommit
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]
                 constraints = [constraints]
             for ct in object_types:
             for ct in object_types:
                 model = ct.model_class()
                 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:
                 try:
                     tokens = {
                     tokens = {
                         CONSTRAINT_TOKEN_USER: 0,  # Replace token with a null user ID
                         CONSTRAINT_TOKEN_USER: 0,  # Replace token with a null user ID