Browse Source

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
Yann Weber 9 years ago
parent
commit
1137205c99

+ 6
- 1
EditorialModel/migrationhandler/django.py View File

@@ -77,6 +77,9 @@ class DjangoMigrationHandler(object):
77 77
 
78 78
     ## @brief Record a change in the EditorialModel and indicate wether or not it is possible to make it
79 79
     # @note The states ( initial_state and new_state ) contains only fields that changes
80
+    #
81
+    # @note Migration is not applied by this method. This method only checks if the new em is valid
82
+    #
80 83
     # @param em model : The EditorialModel.model object to provide the global context
81 84
     # @param uid int : The uid of the change EmComponent
82 85
     # @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):
98 101
         self.em_to_models(em)
99 102
         try:
100 103
             #Calling makemigrations to see if the migration is valid
101
-            django_cmd('makemigrations', self.app_name, dry_run=True, intercative=True, merge=True, noinput=True)
104
+            #django_cmd('makemigrations', self.app_name, dry_run=True, intercative=True, merge=True, noinput=True)
105
+            django_cmd('makemigrations', self.app_name, dry_run=True, intercative=True, noinput=True)
102 106
         except django.core.management.base.CommandError as e:
103 107
             raise MigrationHandlerChangeError(str(e))
104 108
     
@@ -131,6 +135,7 @@ class DjangoMigrationHandler(object):
131 135
         pass
132 136
     
133 137
     ## @brief Not usefull ?
138
+    # @note Maybe we can (have to?) use it to actually do migrations
134 139
     def register_model_state(self, em, state_hash):
135 140
         print('OHOHOH !!! i\'ve been called')
136 141
         pass

+ 1
- 1
Lodel/settings/defaults.py View File

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

+ 7
- 0
Lodel/settings/migrations.py View File

@@ -0,0 +1,7 @@
1
+"""
2
+Django setting for migration handler processes
3
+
4
+"""
5
+
6
+LODEL_MIGRATION_HANDLER_TESTS=True
7
+

+ 2
- 2
LodelTestInstance/models.py View File

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

Loading…
Cancel
Save