mirror of
https://github.com/yweber/lodel2.git
synced 2026-07-30 01:23:26 +02:00
Cleaning and commenting
This commit is contained in:
parent
2b6615775c
commit
d35fa8c56e
3 changed files with 9 additions and 9 deletions
|
|
@ -1,7 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
#from django.conf import settings
|
|
||||||
#settings.configure(DEBUG=True)
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
@ -12,7 +10,6 @@ from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
from EditorialModel.exceptions import *
|
from EditorialModel.exceptions import *
|
||||||
|
|
||||||
#django.conf.settings.configure(DEBUG=True)
|
|
||||||
|
|
||||||
|
|
||||||
## @brief Create a django model
|
## @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 admin_opts dict : Dict of options for admin part of this model
|
||||||
# @param parent_class str : Parent class name
|
# @param parent_class str : Parent class name
|
||||||
# @return A dynamically created django model
|
# @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):
|
def create_model(name, fields=None, app_label='', module='', options=None, admin_opts=None, parent_class=None):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
@ -337,7 +334,7 @@ class DjangoMigrationHandler(object):
|
||||||
kwargs['through'] = through_model_name
|
kwargs['through'] = through_model_name
|
||||||
|
|
||||||
return models.ManyToManyField(f.get_related_type().uniq_name, **kwargs)
|
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)
|
raise NotImplemented("The conversion to django fields is not yet implemented for %s field type"%f.ftype)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,9 +73,9 @@ class Model(object):
|
||||||
del kwargs['component']
|
del kwargs['component']
|
||||||
|
|
||||||
if cls_name == 'EmField':
|
if cls_name == 'EmField':
|
||||||
|
#Special EmField process because of fieldtypes
|
||||||
if not 'type' in kwargs:
|
if not 'type' in kwargs:
|
||||||
raise AttributeError("Missing 'type' from EmField instanciation")
|
raise AttributeError("Missing 'type' from EmField instanciation")
|
||||||
|
|
||||||
cls = EditorialModel.fields.EmField.get_field_class(kwargs['type'])
|
cls = EditorialModel.fields.EmField.get_field_class(kwargs['type'])
|
||||||
del(kwargs['type'])
|
del(kwargs['type'])
|
||||||
else:
|
else:
|
||||||
|
|
@ -147,6 +147,7 @@ class Model(object):
|
||||||
def create_component(self, component_type, datas):
|
def create_component(self, component_type, datas):
|
||||||
|
|
||||||
if component_type == 'EmField':
|
if component_type == 'EmField':
|
||||||
|
#special process for EmField
|
||||||
if not 'type' in datas:
|
if not 'type' in datas:
|
||||||
raise AttributeError("Missing 'type' from EmField instanciation")
|
raise AttributeError("Missing 'type' from EmField instanciation")
|
||||||
em_obj = EditorialModel.fields.EmField.get_field_class(datas['type'])
|
em_obj = EditorialModel.fields.EmField.get_field_class(datas['type'])
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,12 @@ class Command(BaseCommand):
|
||||||
help = 'List all the possible field types'
|
help = 'List all the possible field types'
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
|
ftl = EmField.fieldtypes_list()
|
||||||
|
ftl.sort()
|
||||||
if options['silent']:
|
if options['silent']:
|
||||||
for ftype in EmField.fieldtypes_list():
|
for ftype in ftl:
|
||||||
self.stdout.write("\t%s\n"%ftype)
|
self.stdout.write("%s\n"%ftype)
|
||||||
else:
|
else:
|
||||||
self.stdout.write("Field types list : ")
|
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))
|
self.stdout.write("\t{0:15} {1}".format(ftype, EmField.get_field_class(ftype).help))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue