Skip to content

Commit

Permalink
Merge pull request #44 from rdegges/develop-paul
Browse files Browse the repository at this point in the history
version 0.5 final updates
  • Loading branch information
phalt committed Mar 17, 2014
2 parents 214d658 + 50e8987 commit ec8d5dd
Show file tree
Hide file tree
Showing 20 changed files with 172 additions and 82 deletions.
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ contributers:

Twilio maintainer
=================

(Twilio <3's Django-twilio)

- Paul Hallett (http://twilio.com) phallett@twilio.com
- Paul Hallett (http://twilio.com) paul@twilio.com


Patches and Suggestions
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ lint:
flake8 django_twilio

test:
python runtests.py
python run_tests.py

coverage:
coverage run --source django_twilio run_tests.py
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=============
Django-twilio
Django-Twilio
=============


Expand All @@ -21,7 +21,7 @@ Meta
* Author: Randall Degges
* Email: [email protected]
* Maintainer: Paul Hallett
* Email: phallett@twilio.com
* Email: paul@twilio.com
* Status: active development, stable, maintained


Expand Down
2 changes: 1 addition & 1 deletion django_twilio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""A simple library for building twilio-powered Django webapps."""

__version__ = '0.4.1'
__version__ = '0.5'
77 changes: 67 additions & 10 deletions django_twilio/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,80 @@ class Migration(SchemaMigration):

def forwards(self, orm):
# Adding model 'Caller'
db.create_table('django_twilio_caller', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('blacklisted', self.gf('django.db.models.fields.BooleanField')(default=False)),
('phone_number', self.gf('django.db.models.fields.CharField')(unique=True, max_length=20)),
db.create_table(u'django_twilio_caller', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('blacklisted', self.gf('django.db.models.fields.BooleanField')()),
('phone_number', self.gf('phonenumber_field.modelfields.PhoneNumberField')(unique=True, max_length=128)),
))
db.send_create_signal('django_twilio', ['Caller'])
db.send_create_signal(u'django_twilio', ['Caller'])

# Adding model 'Credential'
db.create_table(u'django_twilio_credential', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(max_length=30)),
('user', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['auth.User'], unique=True)),
('account_sid', self.gf('django.db.models.fields.CharField')(max_length=34)),
('auth_token', self.gf('django.db.models.fields.CharField')(max_length=32)),
))
db.send_create_signal(u'django_twilio', ['Credential'])

def backwards(self, orm):
# Deleting model 'Caller'
db.delete_table('django_twilio_caller')
db.delete_table(u'django_twilio_caller')

# Deleting model 'Credential'
db.delete_table(u'django_twilio_credential')

models = {
'django_twilio.caller': {
u'auth.group': {
'Meta': {'object_name': 'Group'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
},
u'auth.permission': {
'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
u'auth.user': {
'Meta': {'object_name': 'User'},
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
u'contenttypes.contenttype': {
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
},
u'django_twilio.caller': {
'Meta': {'object_name': 'Caller'},
'blacklisted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'phone_number': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '20'})
'blacklisted': ('django.db.models.fields.BooleanField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'phone_number': ('phonenumber_field.modelfields.PhoneNumberField', [], {'unique': 'True', 'max_length': '128'})
},
u'django_twilio.credential': {
'Meta': {'object_name': 'Credential'},
'account_sid': ('django.db.models.fields.CharField', [], {'max_length': '34'}),
'auth_token': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '30'}),
'user': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['auth.User']", 'unique': 'True'})
}
}

Expand Down
10 changes: 5 additions & 5 deletions django_twilio/tests/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def setUp(self):
self.str_signature = encodestring(
new(django_twilio_settings.TWILIO_AUTH_TOKEN,
'%s/str_view/' % self.uri, sha1).digest()).strip()
self.str_signature_with_from_field_normal_caller = encodestring(
self.sig_with_from_field_normal_caller = encodestring(
new(django_twilio_settings.TWILIO_AUTH_TOKEN,
'%s/str_view/From+12222222222' % self.uri,
sha1).digest()).strip()
self.str_signature_with_from_field_blacklisted_caller = encodestring(
self.sig_with_from_field_blacklisted_caller = encodestring(
new(django_twilio_settings.TWILIO_AUTH_TOKEN,
'%s/str_view/From+13333333333' % self.uri,
sha1).digest()).strip()
Expand Down Expand Up @@ -111,23 +111,23 @@ def test_no_from_field(self):
def test_from_field_no_caller(self):
request = self.factory.post(
self.str_uri, {'From': '+12222222222'},
HTTP_X_TWILIO_SIGNATURE=self.str_signature_with_from_field_normal_caller)
HTTP_X_TWILIO_SIGNATURE=self.sig_with_from_field_normal_caller)
self.assertEquals(str_view(request).status_code, 200)

def test_blacklist_works(self):
debug_orig = settings.DEBUG
settings.DEBUG = False
request = self.factory.post(
self.str_uri, {'From': '+13333333333'},
HTTP_X_TWILIO_SIGNATURE=self.str_signature_with_from_field_blacklisted_caller)
HTTP_X_TWILIO_SIGNATURE=self.sig_with_from_field_blacklisted_caller)
response = str_view(request)
r = Response()
r.reject()
self.assertEquals(response.content, str(r))
settings.DEBUG = True
request = self.factory.post(
self.str_uri, {'From': '+13333333333'},
HTTP_X_TWILIO_SIGNATURE=self.str_signature_with_from_field_blacklisted_caller)
HTTP_X_TWILIO_SIGNATURE=self.sig_with_from_field_blacklisted_caller)
response = str_view(request)
r = Response()
r.reject()
Expand Down
3 changes: 2 additions & 1 deletion django_twilio/tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@


# Test URLs for our ``django_twilio.decorators`` module.
urlpatterns = patterns('django_twilio.tests.views',
urlpatterns = patterns(
'django_twilio.tests.views',
url(r'^tests/decorators/response_view/$', 'response_view'),
url(r'^tests/decorators/str_view/$', 'str_view'),
url(r'^tests/decorators/verb_view/$', 'verb_view'),
Expand Down
7 changes: 4 additions & 3 deletions django_twilio/tests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
@twilio_view
def response_view(request):
"""A simple test view that returns a HttpResponse object."""
return HttpResponse('<Response><Sms>Hi!</Sms></Response>',
content_type='text/xml')
return HttpResponse(
'<Response><Message>Hello from Django</Message></Response>',
content_type='text/xml')


@twilio_view
def str_view(request):
"""A simple test view that returns a string."""
return '<Response><Sms>Hi!</Sms></Response>'
return '<Response><Message>Hi!</Message></Response>'


@twilio_view
Expand Down
5 changes: 3 additions & 2 deletions django_twilio/utils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
"""Useful utility functions."""

import os

from django.http import HttpResponse
from django.conf import settings

from twilio.twiml import Response

from django_twilio.models import Caller, Credential

import os


def discover_twilio_creds(user=None):
""" Due to the multiple ways of providing SID / AUTH tokens through
Expand Down
2 changes: 1 addition & 1 deletion django_twilio/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def sms(request, message, to=None, sender=None, action=None, method='POST',
"""
r = Response()
r.message(msg=message, to=to, sender=sender, method='POST', action=action,
statusCallback=status_callback)
statusCallback=status_callback)
return r


Expand Down
5 changes: 0 additions & 5 deletions docs/source/admin_module.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/source/client_module.rst

This file was deleted.

4 changes: 1 addition & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
sys.path.insert(1, os.path.abspath('../../test_project'))

from test_project import settings
from django.core.management import setup_environ
setup_environ(settings)

# -- General configuration -----------------------------------------------------

Expand All @@ -48,7 +46,7 @@

# General information about the project.
project = u'django-twilio'
copyright = u'2012, Randall Degges'
copyright = u'2012-2014, Randall Degges'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
6 changes: 3 additions & 3 deletions docs/source/decorators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Let's take a look at a few examples::
@twilio_view
def reply_to_sms_messages(request):
r = Response()
r.sms('Thanks for the SMS message!')
r.message('Thanks for the SMS message!')
return r

In the example above, we built a view that twilio can POST data to, and that
Expand All @@ -61,8 +61,8 @@ Now let's take a look at the same view written *without*
@require_POST
def reply_to_sms_messages(request):
r = Response()
r.sms('Thanks for the SMS message!')
return HttpResponse(r.__repr__(), mimetype='application/xml')
r.message('Thanks for the SMS message!')
return HttpResponse(r.toxml(), content_type='application/xml')

And that doesn't even include forgery protection or blacklist management! As
you can see, using the :func:`django_twilio.decorators.twilio_view` decorator
Expand Down
5 changes: 0 additions & 5 deletions docs/source/decorators_module.rst

This file was deleted.

25 changes: 22 additions & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
django-twilio
=============
Django-Twilio
=============

Integrate Twilio into your Django apps with ease.


.. image:: https://badge.fury.io/py/django-twilio.png
:target: http://badge.fury.io/py/django-twilio

.. image:: https://travis-ci.org/rdegges/django-twilio.png?branch=master
:target: https://travis-ci.org/rdegges/django-twilio

.. image:: https://pypip.in/d/django-twilio/badge.png
:target: https://crate.io/packages/django-twilio?version=latest

Meta
----

django-twilio is a simple library for building twilio-powered `Django
<https://www.djangoproject.com/>`_ webapps.
* Author: Randall Degges
* Email: [email protected]
* Maintainer: Paul Hallett
* Email: [email protected]
* Status: active development, stable, maintained

`Twilio <http://www.twilio.com/>`_ is a powerful HTTP API that allows you to
build powerful voice & SMS apps. The goal of this library is to help make
Expand Down
Loading

0 comments on commit ec8d5dd

Please sign in to comment.