From 6c35b6a944dd952c33c83efeedd3b5ebd6c0157a Mon Sep 17 00:00:00 2001 From: Paul Hallett Date: Mon, 4 Aug 2014 13:42:22 -0700 Subject: [PATCH 1/2] Fix to decorators to remove methods and blacklist --- django_twilio/decorators.py | 9 ++++----- test_project/test_app/decorators.py | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/django_twilio/decorators.py b/django_twilio/decorators.py index dc5a4d8..b48e250 100644 --- a/django_twilio/decorators.py +++ b/django_twilio/decorators.py @@ -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: @@ -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 @@ -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) diff --git a/test_project/test_app/decorators.py b/test_project/test_app/decorators.py index 46e3615..d8f3b74 100644 --- a/test_project/test_app/decorators.py +++ b/test_project/test_app/decorators.py @@ -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) From afc3e94713d0d0741ab8700e2ff177348e1d92a3 Mon Sep 17 00:00:00 2001 From: Paul Hallett Date: Mon, 4 Aug 2014 13:44:43 -0700 Subject: [PATCH 2/2] Version bump 0.7.1 --- django_twilio/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/django_twilio/__init__.py b/django_twilio/__init__.py index 09b95d0..c4524ad 100644 --- a/django_twilio/__init__.py +++ b/django_twilio/__init__.py @@ -5,4 +5,4 @@ A simple library for building twilio-powered Django webapps. """ -__version__ = '0.7' +__version__ = '0.7.1' diff --git a/setup.py b/setup.py index f001d50..655be80 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ # Basic package information: name='django-twilio', - version='0.7', + version='0.7.1', packages=find_packages(), # Packaging options: