1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2026-01-30 00:20:12 +01:00

Solved some bugs about conditionnal models instanciation in LodelTestInstance.models

Added Lodel/settings/migrations.py that I forget
Disabled the --merge option that was given to the makemigrations command by the MH
This commit is contained in:
Yann 2015-09-16 11:03:45 +02:00
commit 1137205c99
4 changed files with 16 additions and 4 deletions

View file

@ -77,6 +77,9 @@ class DjangoMigrationHandler(object):
## @brief Record a change in the EditorialModel and indicate wether or not it is possible to make it
# @note The states ( initial_state and new_state ) contains only fields that changes
#
# @note Migration is not applied by this method. This method only checks if the new em is valid
#
# @param em model : The EditorialModel.model object to provide the global context
# @param uid int : The uid of the change EmComponent
# @param initial_state dict | None : dict with field name as key and field value as value. Representing the original state. None mean creation of a new component.
@ -98,7 +101,8 @@ class DjangoMigrationHandler(object):
self.em_to_models(em)
try:
#Calling makemigrations to see if the migration is valid
django_cmd('makemigrations', self.app_name, dry_run=True, intercative=True, merge=True, noinput=True)
#django_cmd('makemigrations', self.app_name, dry_run=True, intercative=True, merge=True, noinput=True)
django_cmd('makemigrations', self.app_name, dry_run=True, intercative=True, noinput=True)
except django.core.management.base.CommandError as e:
raise MigrationHandlerChangeError(str(e))
@ -131,6 +135,7 @@ class DjangoMigrationHandler(object):
pass
## @brief Not usefull ?
# @note Maybe we can (have to?) use it to actually do migrations
def register_model_state(self, em, state_hash):
print('OHOHOH !!! i\'ve been called')
pass

View file

@ -118,4 +118,4 @@ USE_TZ = True
STATIC_URL = '/static/'
# Lodel configurations
LODEL_MIGRATION_HANDLER_TESTS = True
LODEL_MIGRATION_HANDLER_TESTS = False

View file

@ -0,0 +1,7 @@
"""
Django setting for migration handler processes
"""
LODEL_MIGRATION_HANDLER_TESTS=True

View file

@ -9,8 +9,8 @@ from EditorialModel.backend.json_backend import EmBackendJson
if not settings.LODEL_MIGRATION_HANDLER_TESTS:
me = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler = DummyMigrationHandler(True))
dmh = DjangoMigrationHandler()
models = dmh.me_to_models(me,'LodelTestInstance', 'LodelTestInstance.models')
dmh = DjangoMigrationHandler('LodelTestInstance', settings.DEBUG)
models = dmh.em_to_models(me)
elif settings.DEBUG:
print("Making migrations tests, don't generate the models in the models.py file but within the migrations handler check process")