Skip to content

Commit 71a3fdf

Browse files
authored
Merge pull request #4 from tpict/master
Handle case where context has no user identifier
2 parents cd84e68 + 0302588 commit 71a3fdf

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

feature_flipper/templatetags/feature_flipper.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ def render(self, context):
4343
"""
4444
user = self._get_value(self.user_key, context)
4545
feature = self._get_value(self.feature, context)
46-
allowed = show_feature(user, feature)
4746

47+
if feature is None:
48+
return ''
49+
50+
allowed = show_feature(user, feature)
4851
return self.nodelist.render(context) if allowed else ''
4952

5053
def _get_value(self, key, context):
@@ -57,4 +60,4 @@ def _get_value(self, key, context):
5760
return key[1:-1]
5861
if key in string.digits:
5962
return int(key)
60-
return context[key]
63+
return context.get(key, None)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
author_email='[email protected]',
1313
description='A simple, customisable, feature flipper',
1414
url='https://github.com/mypebble/django-feature-flipper.git',
15-
version='0.0.7',
15+
version='0.0.8',
1616
packages=find_packages(),
1717
license='MIT',
1818
long_description=LONG_DESCRIPTION,

0 commit comments

Comments
 (0)