Skip to content

Commit

Permalink
Pass args and kwargs to fallback view
Browse files Browse the repository at this point in the history
  • Loading branch information
willbarton committed Feb 22, 2017
1 parent 9f29844 commit 102f0a3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions flags/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

def flag_check(flag_name, condition, fallback=None):
""" Check that a given flag has the given condition (True/False).
If the condition is not met, perform the fallback. """
If the condition is not met, perform the fallback.
"""
def decorator(func):
def inner(request, *args, **kwargs):
enabled = flag_enabled(request, flag_name)

if (condition and enabled) or (not condition and not enabled):
return func(request, *args, **kwargs)
elif fallback is not None:
return fallback(request)
return fallback(request, *args, **kwargs)
else:
raise Http404

Expand Down

0 comments on commit 102f0a3

Please sign in to comment.