Browse Source

Cleaning and commenting

Yann Weber 9 years ago
parent
commit
d35fa8c56e

+ 2
- 5
EditorialModel/migrationhandler/django.py View File

@@ -1,7 +1,5 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3
-#from django.conf import settings
4
-#settings.configure(DEBUG=True)
5 3
 import os
6 4
 import sys
7 5
 
@@ -12,7 +10,6 @@ from django.core.exceptions import ValidationError
12 10
 
13 11
 from EditorialModel.exceptions import *
14 12
 
15
-#django.conf.settings.configure(DEBUG=True)
16 13
 
17 14
 
18 15
 ## @brief Create a django model
@@ -24,7 +21,7 @@ from EditorialModel.exceptions import *
24 21
 # @param admin_opts dict : Dict of options for admin part of this model
25 22
 # @param parent_class str : Parent class name
26 23
 # @return A dynamically created django model
27
-# @source https://code.djangoproject.com/wiki/DynamicModels
24
+# @note Source : https://code.djangoproject.com/wiki/DynamicModels
28 25
 #
29 26
 def create_model(name, fields=None, app_label='', module='', options=None, admin_opts=None, parent_class=None):
30 27
     class Meta:
@@ -337,7 +334,7 @@ class DjangoMigrationHandler(object):
337 334
                 kwargs['through'] = through_model_name
338 335
             
339 336
             return models.ManyToManyField(f.get_related_type().uniq_name, **kwargs)
340
-        else:
337
+        else: #Unknow data type
341 338
             raise NotImplemented("The conversion to django fields is not yet implemented for %s field type"%f.ftype)
342 339
 
343 340
 

+ 2
- 1
EditorialModel/model.py View File

@@ -73,9 +73,9 @@ class Model(object):
73 73
             del kwargs['component']
74 74
             
75 75
             if cls_name == 'EmField':
76
+                #Special EmField process because of fieldtypes
76 77
                 if not 'type' in kwargs:
77 78
                     raise AttributeError("Missing 'type' from EmField instanciation")
78
-
79 79
                 cls = EditorialModel.fields.EmField.get_field_class(kwargs['type'])
80 80
                 del(kwargs['type'])
81 81
             else:
@@ -147,6 +147,7 @@ class Model(object):
147 147
     def create_component(self, component_type, datas):
148 148
         
149 149
         if component_type == 'EmField':
150
+            #special process for EmField
150 151
             if not 'type' in datas:
151 152
                 raise AttributeError("Missing 'type' from EmField instanciation")
152 153
             em_obj = EditorialModel.fields.EmField.get_field_class(datas['type'])

+ 5
- 3
Lodel/management/commands/listfieldtypes.py View File

@@ -13,10 +13,12 @@ class Command(BaseCommand):
13 13
     help = 'List all the possible field types'
14 14
 
15 15
     def handle(self, *args, **options):
16
+        ftl = EmField.fieldtypes_list()
17
+        ftl.sort()
16 18
         if options['silent']:
17
-            for ftype in EmField.fieldtypes_list():
18
-                self.stdout.write("\t%s\n"%ftype)
19
+            for ftype in ftl:
20
+                self.stdout.write("%s\n"%ftype)
19 21
         else:
20 22
             self.stdout.write("Field types list : ")
21
-            for ftype in EmField.fieldtypes_list():
23
+            for ftype in ftl:
22 24
                 self.stdout.write("\t{0:15} {1}".format(ftype, EmField.get_field_class(ftype).help))

Loading…
Cancel
Save