@@ -250,22 +250,20 @@ def _validate_acl_type_change(self, acl_type, error_message):
250
250
"""
251
251
Check if Access List has no existing rules before change the Access List's type.
252
252
"""
253
- if self .instance .pk and (
254
- (
253
+ if self .instance .pk :
254
+ error_message ["type" ] = [
255
+ "This ACL has ACL rules associated, CANNOT change ACL type." ,
256
+ ]
257
+ if (
255
258
acl_type == ACLTypeChoices .TYPE_EXTENDED
256
259
and self .instance .aclstandardrules .exists ()
257
- )
258
- or (
260
+ ):
261
+ raise forms .ValidationError (error_message )
262
+ if (
259
263
acl_type == ACLTypeChoices .TYPE_STANDARD
260
264
and self .instance .aclextendedrules .exists ()
261
- )
262
- ):
263
- error_message ["type" ] = [
264
- "This ACL has ACL rules associated, CANNOT change ACL type." ,
265
- ]
266
-
267
- if error_message :
268
- raise forms .ValidationError (error_message )
265
+ ):
266
+ raise forms .ValidationError (error_message )
269
267
270
268
def save (self , * args , ** kwargs ):
271
269
"""
@@ -406,12 +404,12 @@ def clean(self):
406
404
assigned_object_type_id = ContentType .objects .get_for_model (assigned_object ).pk
407
405
408
406
# Check if the parent host is assigned to the Access List
409
- self ._check_if_interface_parent_is_assigned_to_access_list (
407
+ self ._validate_if_interface_parent_is_assigned_to_access_list (
410
408
cleaned_data .get ("access_list" ), assigned_object_type , assigned_object
411
409
)
412
410
413
411
# Check for duplicate entries in the Access List
414
- self ._check_if_interface_already_has_acl_in_direction (
412
+ self ._validate_if_interface_already_has_acl_in_direction (
415
413
cleaned_data .get ("access_list" ),
416
414
assigned_object_id ,
417
415
assigned_object_type ,
@@ -446,7 +444,7 @@ def _validate_interface_types(self, interface_types):
446
444
elif not interface_types :
447
445
raise forms .ValidationError ("No interface or vminterface selected." )
448
446
449
- def _check_if_interface_parent_is_assigned_to_access_list (
447
+ def _validate_if_interface_parent_is_assigned_to_access_list (
450
448
self , access_list , assigned_object_type , assigned_object
451
449
):
452
450
"""
@@ -471,7 +469,7 @@ def _check_if_interface_parent_is_assigned_to_access_list(
471
469
}
472
470
)
473
471
474
- def _check_if_interface_already_has_acl_in_direction (
472
+ def _validate_if_interface_already_has_acl_in_direction (
475
473
self ,
476
474
access_list ,
477
475
assigned_object_id ,
@@ -573,7 +571,7 @@ def clean(self):
573
571
# No need to check for unique_together since there is no usage of GFK
574
572
575
573
if cleaned_data .get ("action" ) == "remark" :
576
- self ._extracted_from_clean_20 (cleaned_data , error_message , "extended" )
574
+ self ._validate_acl_rules (cleaned_data , error_message , "extended" )
577
575
# Check remark set, but action not set to remark.
578
576
elif cleaned_data .get ("remark" ):
579
577
error_message ["remark" ] = [ERROR_MESSAGE_REMARK_WITHOUT_ACTION_REMARK ]
@@ -582,7 +580,7 @@ def clean(self):
582
580
raise forms .ValidationError (error_message )
583
581
return cleaned_data
584
582
585
- def _extracted_from_clean_20 (self , cleaned_data , error_message , rule_type ):
583
+ def _validate_acl_rules (self , cleaned_data , error_message , rule_type ):
586
584
"""
587
585
Validates form inputs before submitting:
588
586
- Check if action set to remark, but no remark set.
0 commit comments