Skip to content

Commit

Permalink
Merge pull request #60 from rdegges/fix-decorators
Browse files Browse the repository at this point in the history
Fix decorators
  • Loading branch information
phalt committed Aug 4, 2014
2 parents d25c604 + afc3e94 commit 361173c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion django_twilio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
A simple library for building twilio-powered Django webapps.
"""

__version__ = '0.7'
__version__ = '0.7.1'
9 changes: 4 additions & 5 deletions django_twilio/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def my_view(request):
"""
@csrf_exempt
@wraps(f)
def decorator(request_or_self, methods=('POST',),
blacklist=True, *args, **kwargs):
def decorator(request_or_self, *args, **kwargs):

class_based_view = not isinstance(request_or_self, HttpRequest)
if not class_based_view:
Expand All @@ -84,7 +83,7 @@ def decorator(request_or_self, methods=('POST',),
)
if use_forgery_protection:

if request.method not in methods:
if request.method not in ['GET', 'POST']:
return HttpResponseNotAllowed(request.method)

# Forgery check
Expand All @@ -102,11 +101,11 @@ def decorator(request_or_self, methods=('POST',),
if not validator.validate(url, request.GET, signature):
return HttpResponseForbidden()

# Blacklist check
# Blacklist check, by default is true
check_blacklist = getattr(
settings,
'DJANGO_TWILIO_BLACKLIST_CHECK',
blacklist
True
)
if check_blacklist:
blacklisted_resp = get_blacklisted_response(request)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# Basic package information:
name='django-twilio',
version='0.7',
version='0.7.1',
packages=find_packages(),

# Packaging options:
Expand Down
3 changes: 2 additions & 1 deletion test_project/test_app/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def setUp(self):
def test_requires_post(self):
client = Client(enforce_csrf_checks=True)
with override_settings(DEBUG=False):
self.assertEquals(client.get(self.str_uri).status_code, 405)
self.assertEquals(client.get(self.str_uri).status_code, 403)
self.assertEquals(client.post(self.str_uri).status_code, 403)
self.assertEquals(client.head(self.str_uri).status_code, 405)
self.assertEquals(client.options(self.str_uri).status_code, 405)
self.assertEquals(client.put(self.str_uri).status_code, 405)
Expand Down

0 comments on commit 361173c

Please sign in to comment.