-
Notifications
You must be signed in to change notification settings - Fork 42
Description
I'm assessing django-flags for use in a project where we want to be able to switch on or off specific site behaviour without requiring a redeploy. Ideally, we want to be able to deploy with a feature turned off in order to allow for integration setup to happen first.
I'm hitting an unexpected issue with assigning a boolean condition to a flag and I'm concerned it shows I haven't understood a basic principle of this library.
I've created a flag with an existing boolean condition, which I assumed was setting the default of the flag:
FLAGS = {
'TEST_FLAG': [
{'condition': 'boolean', 'value': True, 'required': True},
]
}
This appears to work as I'd expect:
>> flag_state('TEST_FLAG')
True
>> disable_flag('TEST_FLAG')
>> flag_state('TEST_FLAG')
False
But when I tried to set a flag's default to False, it didn't work the same way:
# settings.py
FLAGS = {
'TEST_FLAG': [
{'condition': 'boolean', 'value': False, 'required': True},
]
}
# shell
>> flag_state('TEST_FLAG')
False
>> enable_flag('TEST_FLAG')
>> flag_state('TEST_FLAG')
False
I've tried it with and without the required param and it makes no difference.
I've noticed that the conditions I've defined in settings don't appear in the admin panel, but that enabling/disabling a flag will add a boolean condition, so my best guess is they're separately evaluated and the second example ends up with two conditions that together will never be true?
Is the behaviour demonstrated above expected? And if so, is it possible to set a flag's initial state to False?
Thanks.