Skip to content

Commit

Permalink
Cleaner logic
Browse files Browse the repository at this point in the history
  • Loading branch information
bctiemann committed Dec 18, 2024
1 parent bf82101 commit 6a4c944
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions netbox/dcim/models/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,13 @@ class Meta:
abstract = True

def clean(self):
if self.scope_type:
if self.scope_type and not self.scope:
scope_type = self.scope_type.model_class()
if not self.scope:
raise ValidationError({
'scope': _(
"Please select a {scope_type}."
).format(scope_type=scope_type._meta.model_name)
})
raise ValidationError({
'scope': _(
"Please select a {scope_type}."
).format(scope_type=scope_type._meta.model_name)
})

def save(self, *args, **kwargs):
# Cache objects associated with the terminating object (for filtering)
Expand Down

0 comments on commit 6a4c944

Please sign in to comment.