mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02:30
Add support for hiding settings based on whether features are enabled in the license.
This commit is contained in:
@@ -14,7 +14,8 @@ from rest_framework.exceptions import APIException
|
||||
from awx.main.task_engine import TaskEnhancer
|
||||
from awx.main.utils import memoize
|
||||
|
||||
__all__ = ['LicenseForbids', 'get_license', 'feature_enabled', 'feature_exists']
|
||||
__all__ = ['LicenseForbids', 'get_license', 'get_licensed_features',
|
||||
'feature_enabled', 'feature_exists']
|
||||
|
||||
|
||||
class LicenseForbids(APIException):
|
||||
@@ -42,6 +43,15 @@ def get_license(show_key=False):
|
||||
return license_data
|
||||
|
||||
|
||||
def get_licensed_features():
|
||||
"""Return a set of all features enabled by the active license."""
|
||||
features = set()
|
||||
for feature, enabled in _get_validated_license_data().get('features', {}).items():
|
||||
if enabled:
|
||||
features.add(feature)
|
||||
return features
|
||||
|
||||
|
||||
def feature_enabled(name):
|
||||
"""Return True if the requested feature is enabled, False otherwise."""
|
||||
return _get_validated_license_data().get('features', {}).get(name, False)
|
||||
|
||||
Reference in New Issue
Block a user