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

Feature/adding template filter for switch flag sample usable for if statements #531

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2dfc644
adding is_active to django.html
MatthewEthanTam Nov 2, 2024
dd3b5d8
adding is_active template filter for switch, flag, and sample
MatthewEthanTam Nov 2, 2024
1492f63
adding tests for is_active template tags
MatthewEthanTam Nov 2, 2024
0a67973
running ./run.sh makemessages and compliemessages
MatthewEthanTam Nov 2, 2024
2e92fcd
waffle_tags: fixing linting
MatthewEthanTam Nov 17, 2024
213270a
test_templates: removing `with` for context manager compatibility
MatthewEthanTam Nov 17, 2024
fded0ae
adding template style spaces and small document changes
MatthewEthanTam Nov 17, 2024
2d137d5
Merge branch 'master' into feature/adding-template-filter-for-switch-…
MatthewEthanTam Nov 17, 2024
3f3adb5
Revert "Merge branch 'master' into feature/adding-template-filter-for…
MatthewEthanTam Nov 18, 2024
9fd2ba4
Revert "running ./run.sh makemessages and compliemessages"
MatthewEthanTam Nov 18, 2024
60c3dc1
Use ruff to lint Python code (#518)
cclauss Nov 9, 2024
cda0f97
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 18, 2024
87bed70
Revert "Use ruff to lint Python code (#518)"
MatthewEthanTam Nov 18, 2024
dfae8be
Use ruff to lint Python code (#518)
cclauss Nov 9, 2024
97db292
Revert "Use ruff to lint Python code (#518)"
MatthewEthanTam Nov 18, 2024
70a5751
Use ruff to lint Python code (#518)
cclauss Nov 9, 2024
62a20f8
Revert "Use ruff to lint Python code (#518)"
MatthewEthanTam Nov 18, 2024
80b1d5d
running ./run.sh makemessages and compliemessages
MatthewEthanTam Nov 2, 2024
bacf2a1
Use ruff to lint Python code (#518)
cclauss Nov 9, 2024
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
9 changes: 0 additions & 9 deletions .github/dependabot.yml

This file was deleted.

30 changes: 15 additions & 15 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ 3.8, 3.9, '3.10', 3.11, 3.12, 3.13 ]
python-version: [ 3.8, 3.9, '3.10', 3.11, 3.12 ]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v4
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
Expand All @@ -44,9 +44,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/cache@v4
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
Expand All @@ -64,9 +64,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/cache@v4
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
Expand All @@ -85,9 +85,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/cache@v4
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
Expand All @@ -114,8 +114,8 @@ jobs:
needs: [test, lint, i18n]

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: casperdcl/deploy-pypi@v2
with:
password: ${{ secrets.PYPI_API_TOKEN }}
Expand Down
27 changes: 0 additions & 27 deletions .readthedocs.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
Waffle Changelog
================

v4.2.0
======
- Joined Jazzband (https://jazzband.co/)
- Linting improvements and cleanups
- Added support for Django 5.0 and 5.1
- Added support for Python 3.13

v4.1.0
======
- Updated `is_active_for_user` method to account for `everyone` option
Expand Down
15 changes: 13 additions & 2 deletions docs/about/why-waffle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,31 @@ Waffle :ref:`aims to <about-goals>`
Waffle has an `active community`_ and gets `fairly steady updates`_.


vs Gargoyle
===========

The other major, active feature flag tool for Django is Disqus's
Gargoyle_. Both support similar features, though Gargoyle offers more
options for building custom segments in exchange for some more
complexity and requirements.


Waffle in Production
====================

Waffle has been used in production for years at places like Mozilla, Yipit and TodaysMeet.
Despite its pre-1.0 version number, Waffle has been used in production
for years at places like Mozilla, Yipit and TodaysMeet.

- Mozilla (Support, MDN, Addons, etc)
- TodaysMeet
- Yipit

(If you're using Waffle in production and don't mind being included
here, let us know or add yourself in a pull request!)
here, let me know or add yourself in a pull request!)


.. _Feature flags: http://code.flickr.net/2009/12/02/flipping-out/
.. _several options: https://www.djangopackages.com/grids/g/feature-flip/
.. _active community: https://github.com/jazzband/django-waffle/graphs/contributors
.. _fairly steady updates: https://github.com/jazzband/django-waffle/pulse/monthly
.. _Gargoyle: https://github.com/disqus/gargoyle
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
# built documents.
#
# The short X.Y version.
version = '4.2'
version = '4.1'
# The full version, including alpha/beta/rc tags.
release = '4.2.0'
release = '4.1.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
23 changes: 20 additions & 3 deletions docs/starting/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ met, installing Waffle is a simple process.
Getting Waffle
==============

Waffle is `hosted on PyPI`_ and can be installed with ``pip``
Waffle is `hosted on PyPI`_ and can be installed with ``pip`` or
``easy_install``:

.. code-block:: shell

$ pip install django-waffle
$ easy_install django-waffle

Waffle is also available `on GitHub`_. In general, ``master`` should be
stable, but use caution depending on unreleased versions.
Expand Down Expand Up @@ -78,18 +80,33 @@ With django-jinja_, add the extension to the ``extensions`` list::
# ...
]

With jingo_, add it to the ``JINJA_CONFIG['extensions']`` list::

JINJA_CONFIG = {
'extensions': [
# ...
'waffle.jinja.WaffleExtension',
],
# ...
}


.. _installation-settings-migrations:

Database Schema
===============

Waffle includes `Django migrations`_ for creating the correct database
schema. Simply run the ``migrate`` management command after adding Waffle to
``INSTALLED_APPS``:
schema. If using Django >= 1.7, simply run the ``migrate`` management
command after adding Waffle to ``INSTALLED_APPS``:

.. code-block:: shell

$ django-admin.py migrate

If you're using a version of Django without migrations, you can run
``syncdb`` to create the Waffle tables.

.. _Django migrations: https://docs.djangoproject.com/en/dev/topics/migrations/
.. _django-jinja: https://pypi.python.org/pypi/django-jinja/
.. _jingo: http://jingo.readthedocs.org/
6 changes: 4 additions & 2 deletions docs/testing/automated.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ Tests that run in a separate process, such as Selenium tests, may not
have access to the test database or the ability to mock Waffle values.

For tests that make HTTP requests to the system-under-test (e.g. with
Selenium_) the ``WAFFLE_OVERRIDE`` :ref:`setting <starting-configuring>`
makes it possible to control the value of any *Flag* via the querystring.
Selenium_ or PhantomJS_) the ``WAFFLE_OVERRIDE`` :ref:`setting
<starting-configuring>` makes it possible to control the value of any
*Flag* via the querystring.

.. highlight:: http

Expand All @@ -71,3 +72,4 @@ or that it is "off"::
.. _mock: http://pypi.python.org/pypi/mock/
.. _fudge: http://farmdev.com/projects/fudge/
.. _Selenium: http://www.seleniumhq.org/
.. _PhantomJS: http://phantomjs.org/
2 changes: 1 addition & 1 deletion docs/testing/user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ Wow, good work!
You can use similar methods to derive the impact on other factors.


.. _session variables: https://support.google.com/analytics/answer/9191807?hl=en
.. _session variables: https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs#custom-vars
.. _#80: https://github.com/jazzband/django-waffle/issues/80
.. _StatsD: https://github.com/etsy/statsd
7 changes: 0 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,17 @@ classifiers = [
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Django :: 5.1",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries :: Python Modules",
]
requires-python = ">=3.8"
dependencies = ["django>=3.2"]
[project.optional-dependencies]
docs = ["sphinx"]

[project.urls]
Homepage = "http://github.com/django-waffle/django-waffle"
Expand Down
19 changes: 19 additions & 0 deletions test_app/templates/django/django.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,23 @@
sample_var off
{% endsample %}

{% flag_is_active "flag" request True as is_flag_active %}
{% if is_flag_active %}
flag_is_active on
{% else %}
flag_is_active off
{% endif %}

{% if "switch"|switch_is_active %}
switch_is_active on
{% else %}
switch_is_active off
{% endif %}

{% if "sample"|sample_is_active %}
sample_is_active on
{% else %}
sample_is_active off
{% endif %}

{% wafflejs %}
16 changes: 5 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
[tox]
envlist =
py{38,39}-django{32,40,41,42}
py{310}-django{32,40,41,42,50,51}
py{311}-django{41,42,50,51}
py{312}-django{42,50,51}
py{313}-django{51}
py{38,39,310}-django{32}
py{38,39,310}-django{40,41,42}
py{311}-django{41,42}
isolated_build = True

[gh-actions]
Expand All @@ -13,8 +11,6 @@ python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312
3.13: py313

[testenv]
allowlist_externals = ./run.sh
Expand All @@ -23,16 +19,14 @@ deps =
django40: Django>=4.0,<4.1
django41: Django>=4.1,<4.2
django42: Django>=4.2,<4.3
django50: Django>=5.0,<5.1
django51: Django>=5.1,<5.2
djangomain: https://github.com/django/django/archive/main.tar.gz
-r{toxinidir}/requirements.txt
commands =
./run.sh test

[testenv:i18n]
deps =
Django>=3.2,<5.2
Django>=3.2,<4.2
-r{toxinidir}/requirements.txt
commands =
./run.sh makemessages
Expand All @@ -41,7 +35,7 @@ commands =

[testenv:typecheck]
deps =
Django>=3.2,<5.2
Django>=3.2,<4.3
-r{toxinidir}/requirements.txt
commands =
./run.sh typecheck
2 changes: 1 addition & 1 deletion waffle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
if TYPE_CHECKING:
from waffle.models import AbstractBaseFlag, AbstractBaseSample, AbstractBaseSwitch

__version__ = '4.2.0'
__version__ = '4.1.0'


def flag_is_active(request: HttpRequest, flag_name: str, read_only: bool = False) -> bool | None:
Expand Down
Loading
Loading