[FIX] Make sure the generated view is always the same and the order of the button does not change randomly

This commit is contained in:
Florian da Costa 2019-10-04 20:34:06 +02:00 committed by Sébastien BEAU
parent d7426b969a
commit e0949fb9d2
1 changed files with 6 additions and 2 deletions

View File

@ -118,13 +118,17 @@ class ServerEnvMixin(models.AbstractModel):
current_env = self.env.context.get("environment") or config.get(
"running_env"
)
other_environments = [
# Important to keep this list sorted. It makes sure the button to
# switch environment will always be in the same order. (more user
# friendly) and the test would fail without it as the order could
# change randomly and the view would then also change randomly
other_environments = sorted([
key[15:]
for key, val in config.options.items()
if key.startswith("encryption_key_")
and val
and key[15:] != current_env
]
])
if not current_env:
raise ValidationError(