cfpb / django-flags

Feature flags for Django projects
https://cfpb.github.io/django-flags/
Creative Commons Zero v1.0 Universal
260 stars 32 forks source link

Add a boolean AND condition and a "before date" condition #21

Closed willbarton closed 5 years ago

willbarton commented 5 years ago

This PR adds two new conditions:

The and condition, if given in Python code (i.e. with the Django settings flag source) takes a list of two-tuples containing ('condition name', expected_value). If given as a string (i.e. in the Django admin using the database flag source) it can contain a string with comma-separated pairs with one condition, value pair per line.

Per the documentation:

FLAGS = {'MY_FLAG': {
    'and': [
        ('path', '/flagged/path'), 
        ('after date', '2017-06-01T12:00Z')
    ]
}}

And:

path, /flagged/path
after date, 2017-06-01T12:00Z

To facilitate the multi-line strings (and any other possible custom conditions that users of Django-Flags might create, this PR also changes the database flag state form's widget to a text area instead of an input box. This makes and conditions possible to create in the UI, but it's still a bit clunky.

willbarton commented 5 years ago

I think I have a different approach to solving the all/any condition issue. Closing this PR.