소스 검색

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 8 년 전
부모
커밋
1137205c99
4개의 변경된 파일16개의 추가작업 그리고 4개의 파일을 삭제
  1. 6
    1
      EditorialModel/migrationhandler/django.py
  2. 1
    1
      Lodel/settings/defaults.py
  3. 7
    0
      Lodel/settings/migrations.py
  4. 2
    2
      LodelTestInstance/models.py

+ 6
- 1
EditorialModel/migrationhandler/django.py 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기

@@ -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…
취소
저장