From ea6a2c14a460efd566701c3fde3ce94155e47138 Mon Sep 17 00:00:00 2001 From: Jason Held Date: Thu, 1 Mar 2018 20:38:34 -0500 Subject: [PATCH 1/2] adds django and django-twilio as setup.py keywords --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 513d087..127d745 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ author_email='rdegges@gmail.com', license='UNLICENSE', url='https://github.com/rdegges/django-twilio', - keywords='twilio telephony call phone voip sms', + keywords='twilio telephony call phone voip sms django django-twilio', description='Build Twilio functionality into your Django apps.', long_description=open( normpath(join(dirname(abspath(__file__)), 'README.rst')) From db7f31d8819ec9f6755990bade1de9c3342afc27 Mon Sep 17 00:00:00 2001 From: Jason Held Date: Sun, 22 Apr 2018 11:01:50 -0400 Subject: [PATCH 2/2] Fix: uses urlpatterns urls in test project urls. allows admin. (#135) updates the test project settings so we can the project again locally. --- test_project/settings.py | 74 ++++++++++++++++++++--------- test_project/test_app/decorators.py | 2 - test_project/test_app/urls.py | 16 +++---- test_project/urls.py | 11 +++-- 4 files changed, 66 insertions(+), 37 deletions(-) diff --git a/test_project/settings.py b/test_project/settings.py index 208fc3f..10c275a 100644 --- a/test_project/settings.py +++ b/test_project/settings.py @@ -6,8 +6,17 @@ # Django settings for test_project project. +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +from distutils.version import StrictVersion + +import django + +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + DEBUG = True -TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), @@ -18,6 +27,7 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': 'db.sqlite3', } } @@ -85,23 +95,47 @@ # Make this unique, and don't share it with anybody. SECRET_KEY = 'j1wd@qqodn-r9h&o@0jj!uw^#pm5wcdu2^cdsax=hm+-mk705p' -# List of callables that know how to import templates from various sources. -TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', -) - -MIDDLEWARE_CLASSES = ( - 'django.middleware.common.CommonMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', -) - -ROOT_URLCONF = 'test_project.test_app.urls' - -TEMPLATE_DIRS = () +# This is a temporary shim to allow the old style MIDDLEWARE_CLASSES to work +# We will forge a plan to remove at least the unsupported versions soon. +# Django 2.0 is the future, but 1.11 is still supported. +# This test_project though is simple enough that the restrictions are small. +if StrictVersion(django.__version__) < StrictVersion('2.0'): + MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + ) +else: + MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + ] + +ROOT_URLCONF = 'test_project.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'templates')] + , + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] INSTALLED_APPS = ( 'django.contrib.auth', @@ -136,10 +170,6 @@ NOSE_ARGS = ['--with-coverage', '--cover-package=django_twilio'] -# Until South is once again Python 3 compatible, -# skip testing migrations in Python 3 -if sys.version_info[0] == 3: - SOUTH_TESTS_MIGRATE = False # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to diff --git a/test_project/test_app/decorators.py b/test_project/test_app/decorators.py index 21bf7c7..185863f 100644 --- a/test_project/test_app/decorators.py +++ b/test_project/test_app/decorators.py @@ -20,8 +20,6 @@ class TwilioViewTestCase(TestCase): - urls = 'test_project.test_app.urls' - def setUp(self): self.regular_caller = G(Caller, phone_number='+12222222222', blacklisted=False) diff --git a/test_project/test_app/urls.py b/test_project/test_app/urls.py index 52c182a..545604c 100644 --- a/test_project/test_app/urls.py +++ b/test_project/test_app/urls.py @@ -7,12 +7,12 @@ # Test URLs for our ``django_twilio.decorators`` module. urlpatterns = [ - url(r'^test_app/decorators/response_view/$', views.response_view), - url(r'^test_app/decorators/response_class_view/$', views.ResponseView.as_view()), - url(r'^test_app/decorators/str_view/$', views.str_view), - url(r'^test_app/decorators/str_class_view/$', views.StrView.as_view()), - url(r'^test_app/decorators/bytes_view/$', views.bytes_view), - url(r'^test_app/decorators/bytes_class_view/$', views.BytesView.as_view()), - url(r'^test_app/decorators/verb_view/$', views.verb_view), - url(r'^test_app/decorators/verb_class_view/$', views.VerbView.as_view()) + url(r'^decorators/response_view/$', views.response_view), + url(r'^decorators/response_class_view/$', views.ResponseView.as_view()), + url(r'^decorators/str_view/$', views.str_view), + url(r'^decorators/str_class_view/$', views.StrView.as_view()), + url(r'^decorators/bytes_view/$', views.bytes_view), + url(r'^decorators/bytes_class_view/$', views.BytesView.as_view()), + url(r'^decorators/verb_view/$', views.verb_view), + url(r'^decorators/verb_class_view/$', views.VerbView.as_view()) ] \ No newline at end of file diff --git a/test_project/urls.py b/test_project/urls.py index db8ab33..9ce72cc 100644 --- a/test_project/urls.py +++ b/test_project/urls.py @@ -1,13 +1,14 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals, absolute_import -from django.conf.urls import patterns, include, url +from django.conf.urls import include, url # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() -urlpatterns = patterns( - '', - url(r'^admin/', include(admin.site.urls)), -) +urlpatterns = [ + url(r'^admin/', admin.site.urls), + url(r'^test_app/', include('test_project.test_app.urls')), +] +