diff --git a/README.md b/README.md index b68a7de..4e87cf0 100644 --- a/README.md +++ b/README.md @@ -192,3 +192,4 @@ The service is configured by Environment Variable: | WSGI_TIMEOUT | `5` | WSGI timeout. | | GUNICORN_TMPFS_DIR | `None` |The working directory for the gunicorn workers. | | WSGI_WORKERS | `2` | The number of workers per CPU. | +| UNLISTED_ICON_SETS | `'babs'`| Comma separated list of icon set to un-list. Those sets won't be listed in the /sets endpoint. | diff --git a/app/icon_set.py b/app/icon_set.py index d95a5c0..f08350a 100644 --- a/app/icon_set.py +++ b/app/icon_set.py @@ -9,7 +9,7 @@ from app.settings import COLORABLE_ICON_SETS from app.settings import ICON_SET_LANGUAGE from app.settings import IMAGE_FOLDER -from app.settings import LEGACY_ICON_SETS +from app.settings import UNLISTED_ICON_SETS def get_icon_set(icon_set_name): @@ -32,7 +32,7 @@ def get_all_icon_sets(): for root, dirs, files in os.walk(IMAGE_FOLDER): for icon_set_name in dirs: # icons of legacy icon sets are still available, but the icon set will not be listed - if icon_set_name not in LEGACY_ICON_SETS: + if icon_set_name not in UNLISTED_ICON_SETS: icon_sets.append(get_icon_set(icon_set_name)) return icon_sets diff --git a/app/settings.py b/app/settings.py index a4929ca..41a3d2a 100644 --- a/app/settings.py +++ b/app/settings.py @@ -15,7 +15,7 @@ ) COLORABLE_ICON_SETS = ['default'] -LEGACY_ICON_SETS = ['babs'] +UNLISTED_ICON_SETS = os.environ.get('UNLISTED_ICON_SETS', 'babs').split(',') ICON_SET_LANGUAGE = {'babs-de': 'de', 'babs-fr': 'fr', 'babs-it': 'it'} DEFAULT_COLOR = {"r": '255', "g": '0', "b": '0'} DEFAULT_ICON_SIZE = 48 diff --git a/tests/unit_tests/test_all_icons.py b/tests/unit_tests/test_all_icons.py index e3a8704..d61b606 100644 --- a/tests/unit_tests/test_all_icons.py +++ b/tests/unit_tests/test_all_icons.py @@ -13,7 +13,7 @@ from app.settings import COLORABLE_ICON_SETS from app.settings import DEFAULT_ICON_SIZE from app.settings import IMAGE_FOLDER -from app.settings import LEGACY_ICON_SETS +from app.settings import UNLISTED_ICON_SETS from tests.unit_tests.base_test import ServiceIconsUnitTests @@ -159,11 +159,11 @@ def test_all_icon_sets_endpoint(self): self.assertTrue(response.json['items']) icon_sets_from_endpoint = response.json['items'] self.assertEqual( - len(icon_sets_from_endpoint), len(self.all_icon_sets) - len(LEGACY_ICON_SETS) + len(icon_sets_from_endpoint), len(self.all_icon_sets) - len(UNLISTED_ICON_SETS) ) - for legacy_icon_set in LEGACY_ICON_SETS: + for unlisted_icon_set in UNLISTED_ICON_SETS: self.assertNotIn( - legacy_icon_set, icon_sets_from_endpoint, msg="Icon set should not be listed" + unlisted_icon_set, icon_sets_from_endpoint, msg="Icon set should not be listed" ) for icon_set in icon_sets_from_endpoint: self.assertIn('name', icon_set)