Browse Source

Reverse legacy models

pull/6/head
Marcio Mazza 10 years ago
committed by Marcio Mazza
parent
commit
f284fd4cd4
  1. 0
      legacy/__init__.py
  2. 3
      legacy/admin.py
  3. 0
      legacy/migrations/__init__.py
  4. 1519
      legacy/models.py
  5. 3
      legacy/tests.py
  6. 3
      legacy/views.py
  7. 5
      requirements.txt
  8. 21
      sapl/legacyrouter.py
  9. 19
      sapl/settings.py

0
legacy/__init__.py

3
legacy/admin.py

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

0
legacy/migrations/__init__.py

1519
legacy/models.py

File diff suppressed because it is too large

3
legacy/tests.py

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
legacy/views.py

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

5
requirements.txt

@ -0,0 +1,5 @@
Django
MySQL-python
psycopg2
ipdb

21
sapl/legacyrouter.py

@ -0,0 +1,21 @@
class LegacyRouter(object):
def db_for_read(self, model, **hints):
if model._meta.app_label == 'legacy':
return 'legacy'
return None
def db_for_write(self, model, **hints):
if model._meta.app_label == 'legacy':
return 'legacy'
return None
def allow_relation(self, obj1, obj2, **hints):
if obj1._meta.app_label == 'legacy' and obj2._meta.app_label == 'legacy':
return True
return None
def allow_migrate(self, db, model):
if model._meta.app_label == 'legacy':
return False
return None

19
sapl/settings.py

@ -37,6 +37,8 @@ INSTALLED_APPS = (
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'legacy',
'base',
) )
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = (
@ -76,11 +78,24 @@ WSGI_APPLICATION = 'sapl.wsgi.application'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 'NAME': 'sapl',
'USER': 'sapl',
'PASSWORD': 'sapl',
'HOST': 'localhost',
'PORT': '5432',
},
'legacy': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'sapl3',
'USER': 'root',
'PASSWORD': 'admin',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
} }
} }
DATABASE_ROUTERS = ['sapl.legacyrouter.LegacyRouter', ]
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/ # https://docs.djangoproject.com/en/1.8/topics/i18n/

Loading…
Cancel
Save