1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2026-03-17 08:42:01 +01:00

Cleaning and commenting

This commit is contained in:
Yann 2015-09-17 17:14:20 +02:00
commit d35fa8c56e
3 changed files with 9 additions and 9 deletions

View file

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

View file

@ -73,9 +73,9 @@ class Model(object):
del kwargs['component']
if cls_name == 'EmField':
#Special EmField process because of fieldtypes
if not 'type' in kwargs:
raise AttributeError("Missing 'type' from EmField instanciation")
cls = EditorialModel.fields.EmField.get_field_class(kwargs['type'])
del(kwargs['type'])
else:
@ -147,6 +147,7 @@ class Model(object):
def create_component(self, component_type, datas):
if component_type == 'EmField':
#special process for EmField
if not 'type' in datas:
raise AttributeError("Missing 'type' from EmField instanciation")
em_obj = EditorialModel.fields.EmField.get_field_class(datas['type'])

View file

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