Closed K900 closed 4 years ago
@K900 I think you could accomplish this by simply creating the negating condition and making it required. For example:
# myconditions.py
from flags import conditions
@conditions.register('user is not')
def not_user(path, request=None, **kwargs):
return request.user.get_username() != username
# settings.py
FLAGS = {
'FLAG': [
{'condition': 'user is not', 'value': ''qa.user, 'required': True},
{'condition': 'boolean', 'value': True},
]
}
(Note: I haven't tried this, but conceptually, I think something like this could work.)
Yeah, this is more or less what I ended up with. It's still somewhat inconvenient, but it'll work for now.
This may be a niche use case, but it would be nice to have an option to explicitly disable a flag based on a condition, e.g. for a specific QA user account, or for a predefined control group of users. Right now the only somewhat convenient way to achieve this behavior seems to be to introduce a second flag (e.g.
NEVER_FLAG
if the main flag isFLAG
) and then checkif FLAG and not NEVER_FLAG
.