[#2534] Version 0.6: corrigé des problèmes de packaging
[auf_django_references.git] / auf / django / references / management / __init__.py
CommitLineData
652c5d02
EMS
1# encoding: utf-8
2
3from django.db import connection
4from django.db.models import get_models, signals
67c788a8 5from django.conf import settings
652c5d02
EMS
6
7import auf.django.references.models
8
9def post_syncdb(sender, **kwargs):
67c788a8 10 if 'auf.django.references.managedref' not in settings.INSTALLED_APPS:
652c5d02
EMS
11 print u'Création des vues pour les données de référence...'
12 cursor = connection.cursor()
13 for model in get_models():
14 if model.__module__ == 'auf.django.references.models':
15 table_name = model._meta.db_table
16 cursor.execute(
17 'CREATE OR REPLACE VIEW `%s` AS SELECT * FROM datamaster.`%s`' %
18 (table_name, table_name)
19 )
20
21signals.post_syncdb.connect(post_syncdb, sender=auf.django.references.models)