Commit 6f4e845e by Natalia Bidart Committed by Ricardo Kirkner

- Run migration with autocommit so tests run with sqlite.

parents 6466fb77 623baed9
...@@ -2,19 +2,28 @@ ...@@ -2,19 +2,28 @@
from south.utils import datetime_utils as datetime from south.utils import datetime_utils as datetime
from south.db import db from south.db import db
from south.v2 import DataMigration from south.v2 import DataMigration
from django.db import models from django.db import connection, models, transaction
class Migration(DataMigration): class Migration(DataMigration):
def forwards(self, orm): def add_account_verified_permission(self, orm):
"Write your forwards methods here." ct, _ = orm['contenttypes.ContentType'].objects.get_or_create(
ct, created = orm['contenttypes.ContentType'].objects.get_or_create(
model='useropenid', app_label='django_openid_auth', model='useropenid', app_label='django_openid_auth',
defaults=dict(name='user open id')) defaults=dict(name='user open id'))
perm, created = orm['auth.permission'].objects.get_or_create( perm, _ = orm['auth.permission'].objects.get_or_create(
content_type=ct, codename='account_verified', content_type=ct, codename='account_verified',
defaults=dict(name=u'The OpenID account has been verified')) defaults=dict(name=u'The OpenID account has been verified'))
def forwards(self, orm):
"Write your forwards methods here."
if getattr(connection.features,
'autocommits_when_autocommit_is_off', False):
# likely sqlite3 with django 1.6 and above
with transaction.autocommit():
self.add_account_verified_permission(orm)
else:
self.add_account_verified_permission(orm)
def backwards(self, orm): def backwards(self, orm):
"Write your backwards methods here." "Write your backwards methods here."
......
...@@ -42,11 +42,11 @@ MANAGERS = ADMINS ...@@ -42,11 +42,11 @@ MANAGERS = ADMINS
if django_version >= "1.2": if django_version >= "1.2":
csrf_middleware = 'django.middleware.csrf.CsrfViewMiddleware' csrf_middleware = 'django.middleware.csrf.CsrfViewMiddleware'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'sqlite.db' 'NAME': 'sqlite.db',
} }
} }
TEMPLATE_LOADERS = ( TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader', 'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader', 'django.template.loaders.app_directories.Loader',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment