Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PB-1083: Removed default icon set 'babs' from UNLISTED_ICON_SET #93

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.local
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ALLOWED_DOMAINS=.*
ALLOWED_DOMAINS=.*

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +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. |
| UNLISTED_ICON_SETS | | Comma separated list of icon set to un-list. Those sets won't be listed in the /sets endpoint. |
9 changes: 9 additions & 0 deletions app/helpers/icons.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import os


def get_icon_set_template_url(base_url=''):
"""
Generate and return a template URL to access icon_sets' metadata
Expand All @@ -14,3 +17,9 @@ def get_icon_template_url(base_url='', with_color=True):
color_part = "-{r},{g},{b}"
return f"{get_icon_set_template_url(base_url)}/icons/{{icon_name}}" \
f"@{{icon_scale}}{color_part}.png"


def fetch_and_clean_unlisted_sets():
unlisted_icon_sets = os.environ.get('UNLISTED_ICON_SETS', '').split(',')
cleaned_unlisted_icon_sets = [icon_set for icon_set in unlisted_icon_sets if icon_set]
return cleaned_unlisted_icon_sets
5 changes: 4 additions & 1 deletion app/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from pathlib import Path
from app.helpers.icons import fetch_and_clean_unlisted_sets

BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
ENV_FILE = os.getenv('ENV_FILE', f'{BASE_DIR}/.env.local')
Expand All @@ -15,7 +16,9 @@
)

COLORABLE_ICON_SETS = ['default']
UNLISTED_ICON_SETS = os.environ.get('UNLISTED_ICON_SETS', 'babs').split(',')

UNLISTED_ICON_SETS = fetch_and_clean_unlisted_sets()

ICON_SET_LANGUAGE = {'babs-v2-de': 'de', 'babs-v2-fr': 'fr', 'babs-v2-it': 'it'}
DEFAULT_COLOR = {"r": '255', "g": '0', "b": '0'}
DEFAULT_ICON_SIZE = 48
Expand Down