Skip to content

Commit

Permalink
storage_backend: fix bug when server_env
Browse files Browse the repository at this point in the history
has_validation is in the view; so it's computed
at creation, before the backend_type is set

The default value is not set in some circonstances
  • Loading branch information
hparfr committed Nov 17, 2023
1 parent 0cd0fa2 commit 79fd30d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions storage_backend/models/storage_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ class StorageBackend(models.Model):

def _compute_has_validation(self):
for rec in self:
if not rec.backend_type:
# with server_env
# this code can be triggered
# before a backend_type has been set
# get_adapter() can't work without backend_type
rec.has_validation = False
continue
adapter = rec._get_adapter()
rec.has_validation = hasattr(adapter, "validate_config")

Expand Down

0 comments on commit 79fd30d

Please sign in to comment.