|
@@ -19,16 +19,31 @@ class EmField(EmComponent):
|
19
|
19
|
ranked_in = 'fieldgroup_id'
|
20
|
20
|
|
21
|
21
|
## Instanciate a new EmField
|
22
|
|
- # @todo define and test type for icon and fieldtype
|
|
22
|
+ # @todo define and test type for icon
|
23
|
23
|
# @warning nullable == True by default
|
|
24
|
+ # @param model Model : Editorial model
|
|
25
|
+ # @param uid int : Uniq id
|
|
26
|
+ # @param fieldtype str : Fieldtype name ( see Editorialmodel::fieldtypes )
|
|
27
|
+ # @param optional bool : Indicate if a field is optional or not
|
|
28
|
+ # @param internal str|bool : If False the field is not internal, else it can takes value in "object" or "automatic"
|
|
29
|
+ # @param rel_field_id int|None : If not None indicates that the field is a relation attribute (and the value is the UID of the rel2type field)
|
|
30
|
+ # @param nullable bool : If True None values are allowed
|
|
31
|
+ # @param default * : Default field value
|
|
32
|
+ # @param uniq bool : if True the value should be uniq in the db table
|
|
33
|
+ # @param **kwargs : more keywords arguments for the fieldtype
|
24
|
34
|
def __init__(self, model, uid, name, fieldgroup_id, fieldtype, optional=False, internal=False, rel_field_id=None, icon='0', string=None, help_text=None, date_update=None, date_create=None, rank=None, nullable=True, default=None, uniq=False, **kwargs):
|
25
|
35
|
|
26
|
36
|
self.fieldgroup_id = fieldgroup_id
|
27
|
37
|
self.check_type('fieldgroup_id', int)
|
28
|
|
- self.optional = optional
|
29
|
|
- self.check_type('optional', bool)
|
30
|
|
- self.internal = internal
|
31
|
|
- self.check_type('internal', bool)
|
|
38
|
+ self.optional = bool(optional)
|
|
39
|
+
|
|
40
|
+ if not internal:
|
|
41
|
+ self.internal = False
|
|
42
|
+ else:
|
|
43
|
+ if internal.lower() not in ['object', 'automatic']:
|
|
44
|
+ raise ValueError("The internal arguments possible values are : [False, 'object', 'automatic']")
|
|
45
|
+ self.internal = internal.lower()
|
|
46
|
+
|
32
|
47
|
self.rel_field_id = rel_field_id
|
33
|
48
|
self.check_type('rel_field_id', (int, type(None)))
|
34
|
49
|
self.icon = icon
|
|
@@ -59,7 +74,7 @@ class EmField(EmComponent):
|
59
|
74
|
@staticmethod
|
60
|
75
|
## @brief Return the list of allowed field type
|
61
|
76
|
def fieldtypes_list():
|
62
|
|
- return [f for f in EditorialModel.fieldtypes.__all__ if f != '__init__']
|
|
77
|
+ return [f for f in EditorialModel.fieldtypes.__all__ if f != '__init__' and f != 'generic' ]
|
63
|
78
|
|
64
|
79
|
## @brief Get the fieldtype instance
|
65
|
80
|
# @return a fieldtype instance
|