This PR supports specifying metadata for each feature flag in both the SettingsFlagsSource and the DatabaseFlagsSource, as well as get_flags and custom flag sources.
Flags defined in Django settings files can now be specified like this:
FLAGS = {
'FLAG_WITH_METADATA': [
{'condition': 'boolean', 'value': 'true'},
{'help_text': 'a human-friendly flag description', 'category': 'a human-friendly category'},
],
}
There is a new model, FlagMetadata, added in this PR to add metadata in the admin.
To support that, this change will deprecate the previous behavior of flag sources' get_flags method, which was expected to return a dictionary, and instead expect a three-tuple of (flag, conditions, metadata).
Currently the metadata is not consumed anywhere — it does not change the way the Django admin for feature flags works, and isn't referenced there. It is intended for use in the admin of Wagtail Flags and in any other custom flag consumption/auditing/reporting. Metadata keys can be anything — there is not preference for particular keys in Django Flags. I anticipate that Wagtail Flags will make use of "category" and "help_text" which is why they're included in the examples here.
This PR supports specifying metadata for each feature flag in both the
SettingsFlagsSource
and theDatabaseFlagsSource
, as well asget_flags
and custom flag sources.Flags defined in Django settings files can now be specified like this:
There is a new model,
FlagMetadata
, added in this PR to add metadata in the admin.To support that, this change will deprecate the previous behavior of flag sources'
get_flags
method, which was expected to return a dictionary, and instead expect a three-tuple of (flag, conditions, metadata).Currently the metadata is not consumed anywhere — it does not change the way the Django admin for feature flags works, and isn't referenced there. It is intended for use in the admin of Wagtail Flags and in any other custom flag consumption/auditing/reporting. Metadata keys can be anything — there is not preference for particular keys in Django Flags. I anticipate that Wagtail Flags will make use of "category" and "help_text" which is why they're included in the examples here.