Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for south migrations #51

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[run]
include = invitations*
omit = *migrations*
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@ language: python

env:
matrix:
- TOX_ENV=py27-django16-backendBasic
- TOX_ENV=py27-django17-backendBasic
- TOX_ENV=py27-django18-backendBasic
- TOX_ENV=py27-django19-backendBasic
- TOX_ENV=py33-django16-backendBasic
- TOX_ENV=py33-django17-backendBasic
- TOX_ENV=py33-django18-backendBasic
- TOX_ENV=py34-django16-backendBasic
- TOX_ENV=py34-django17-backendBasic
- TOX_ENV=py34-django18-backendBasic
- TOX_ENV=py34-django19-backendBasic
- TOX_ENV=py27-django16-backendAllauth
- TOX_ENV=py27-django17-backendAllauth
- TOX_ENV=py27-django18-backendAllauth
- TOX_ENV=py27-django19-backendAllauth
- TOX_ENV=py33-django16-backendAllauth
- TOX_ENV=py33-django17-backendAllauth
- TOX_ENV=py33-django18-backendAllauth
- TOX_ENV=py34-django16-backendAllauth
- TOX_ENV=py34-django17-backendAllauth
- TOX_ENV=py34-django18-backendAllauth
- TOX_ENV=py34-django19-backendAllauth
Expand Down
23 changes: 23 additions & 0 deletions invitations/migrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Django migrations for django-registration-redux

This package does not contain South migrations.

These are Django native migrations. They require Django > 1.7.

"""

SOUTH_ERROR_MESSAGE = """\n
For South support, customize the SOUTH_MIGRATION_MODULES setting like so:

SOUTH_MIGRATION_MODULES = {
'invitations': 'invitations.south_migrations',
}
"""

# Ensure the user is not using Django 1.6 or below with South
try:
from django.db import migrations # noqa
except ImportError:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured(SOUTH_ERROR_MESSAGE)
78 changes: 78 additions & 0 deletions invitations/south_migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

def forwards(self, orm):
# Adding model 'Invitation'
db.create_table(u'invitations_invitation', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('email', self.gf('django.db.models.fields.EmailField')(unique=True, max_length=75)),
('accepted', self.gf('django.db.models.fields.BooleanField')(default=False)),
('created', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)),
('key', self.gf('django.db.models.fields.CharField')(unique=True, max_length=64)),
('sent', self.gf('django.db.models.fields.DateTimeField')(null=True)),
('inviter', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, blank=True)),
))
db.send_create_signal(u'invitations', ['Invitation'])


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


models = {
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'invitations.invitation': {
'Meta': {'object_name': 'Invitation'},
'accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '75'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'inviter': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']", 'null': 'True', 'blank': 'True'}),
'key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '64'}),
'sent': ('django.db.models.fields.DateTimeField', [], {'null': 'True'})
}
}

complete_apps = ['invitations']
Empty file.
15 changes: 8 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
tox>=2.1.1
mock>=1.3.0
coverage>=3.7.1
django-nose>=1.4
django-braces>=1.8.0
freezegun>=0.3.5
nose-parameterized>=0.5.0
tox>=2.1.1
mock>=1.3.0
coverage>=3.7.1
nose-exclude==0.5.0
django-nose>=1.4
django-braces>=1.8.0
freezegun>=0.3.5
nose-parameterized>=0.5.0
7 changes: 5 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[metadata]
description-file = README.md
[metadata]
description-file = README.md

[nosetests]
exclude-dir = ['migrations/*', 'south_migrations/*']
5 changes: 5 additions & 0 deletions test_allauth_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@
)

ACCOUNT_ADAPTER = 'invitations.models.InvitationsAdapter'


SOUTH_MIGRATION_MODULES = {
'invitations': 'invitations.south_migrations',
}
144 changes: 76 additions & 68 deletions test_settings.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,76 @@
# -*- coding: utf-8 -*-
import django

SECRET_KEY = 'not_empty'
SITE_ID = 1
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
}

ROOT_URLCONF = 'test_urls'

if django.VERSION >= (1, 8):
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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'
],
},
},
]
else:
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.request",
"django.contrib.messages.context_processors.messages",
)

MIDDLEWARE_CLASSES = (
'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',
)

EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django_nose',
'invitations',
)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)
# -*- coding: utf-8 -*-
import django

SECRET_KEY = 'not_empty'
SITE_ID = 1
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
}

ROOT_URLCONF = 'test_urls'

if django.VERSION >= (1, 8):
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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'
],
},
},
]
else:
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.request",
"django.contrib.messages.context_processors.messages",
)

MIDDLEWARE_CLASSES = (
'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',
)

EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
# 'south',
'django_nose',
'invitations',

)

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)


# SOUTH_MIGRATION_MODULES = {
# 'invitations': 'invitations.south_migrations',
# }
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ envlist = py{27,33,34,35}-django{16,17,18,19}-backend{Basic,Allauth}
[testenv]
deps =
-rrequirements.txt
django16: Django<1.7
django17: Django<1.8
django18: Django<1.9
django19: Django<1.10
Expand Down