From 2b39c6cd93145758e82e278f5f8fc720ce67874b Mon Sep 17 00:00:00 2001 From: Marlon Trapp Date: Fri, 30 Jul 2021 16:17:31 -0300 Subject: [PATCH 1/2] Write README on how to use --- README.rst | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 631be3d..99ac04c 100644 --- a/README.rst +++ b/README.rst @@ -4,4 +4,60 @@ Frontend Settings Abstract -------- -Dynamic settings and feature flags for the frontend. +This project provides an API that expose settings and feature flags for the frontend. + +It uses `django-drf` to create an endpoint to expose flags and settings configured in `django-waffle` and `django-constance` + + + +Usage +----- + +Requirements +Python (3.6, 3.7, 3.8, 3.9) +Django (2.2, 3.0, 3.1, 3.2) + +Installation +~~~~~~~~~~~~ +Install using pip: + +.. code:: + + pip install django-frontend-settings + +Add 'frontend-settings' to your INSTALLED_APPS setting. + +.. code:: python + + INSTALLED_APPS = [ + ... + 'frontend-settings', + ] + +Expose the view in your urls: + +.. code:: python + + from frontend_settings.views import settings as frontend_settings_view + + url(r"^frontend-settings/", frontend_settings_view, name="frontend-settings"), + + +Then your flags from waffle and setting from constance should be returned on a get in this route: + + +.. code:: + + $ curl 'http://localhost:8000/frontend-settings/' + {"data":{"flags":{"MY_FEATURE_FLAG":true},"settings":{}}} + + +In that case I had `FRONTEND_MY_FEATURE_FLAG` flag in waffle. +The default prefix for flags is `FRONTEND_`, if you like to change it you can do by changing the following config on settings.py: + +.. code:: python + + FRONTEND_SETTINGS = { + "WAFFLE_FLAG_PREFIX": "FRONTEND_", # Prefix used to filter out the flag that should be exposed in the endpoint + "CONSTANCE_KEY": "FRONTEND_SETTINGS", # Name of the settings in constance + } From b106b04cf2206d610bd1b86db518429e502f0792 Mon Sep 17 00:00:00 2001 From: Marlon Trapp Date: Fri, 30 Jul 2021 16:30:29 -0300 Subject: [PATCH 2/2] Change description --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 78e8235..1d38bbc 100755 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ setup_requires=["setuptools_scm"], url='https://github.com/loadsmart/django-frontend-settings', license='MIT', - description='Dynamic settings & feature flags for the fronted.', + description='Expose feature flags and settings from django waffle and django constance in an endpoint.', long_description=open('README.rst', 'r', encoding='utf-8').read(), author='Loadsmart', author_email='developer@loadsmart.com',