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

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

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

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

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
 
9
 
10
 if not settings.LODEL_MIGRATION_HANDLER_TESTS:
10
 if not settings.LODEL_MIGRATION_HANDLER_TESTS:
11
     me = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler = DummyMigrationHandler(True))
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
 elif settings.DEBUG:
14
 elif settings.DEBUG:
15
     print("Making migrations tests, don't generate the models in the models.py file but within the migrations handler check process")
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