|
@@ -8,6 +8,7 @@ import hashlib
|
8
|
8
|
from lodel.utils.mlstring import MlString
|
9
|
9
|
|
10
|
10
|
from lodel.editorial_model.exceptions import *
|
|
11
|
+from lodel.leapi.leobject import CLASS_ID_FIELDNAME
|
11
|
12
|
|
12
|
13
|
##@brief Abstract class to represent editorial model components
|
13
|
14
|
# @see EmClass EmField
|
|
@@ -82,6 +83,19 @@ class EmClass(EmComponent):
|
82
|
83
|
self.parents = parents
|
83
|
84
|
##@brief Stores EmFields instances indexed by field uid
|
84
|
85
|
self.__fields = dict()
|
|
86
|
+
|
|
87
|
+ #Adding common field
|
|
88
|
+ if not self.abstract:
|
|
89
|
+ self.new_field(
|
|
90
|
+ CLASS_ID_FIELDNAME,
|
|
91
|
+ display_name = {
|
|
92
|
+ 'eng': "LeObject subclass identifier",
|
|
93
|
+ 'fre': "Identifiant de la class fille de LeObject"},
|
|
94
|
+ help_text = {
|
|
95
|
+ 'eng': "Allow to create instance of the good class when\
|
|
96
|
+ fetching arbitrary datas from DB"},
|
|
97
|
+ data_handler = 'LeobjectSubclassIdentifier',
|
|
98
|
+ internal = True)
|
85
|
99
|
|
86
|
100
|
##@brief Property that represent a dict of all fields (the EmField defined in this class and all its parents)
|
87
|
101
|
# @todo use Settings.editorialmodel.groups to determine wich fields should be returned
|
|
@@ -118,6 +132,8 @@ class EmClass(EmComponent):
|
118
|
132
|
# @todo use Settings.editorialmodel.groups to determine wich fields should be returned
|
119
|
133
|
def fields(self, uid = None, no_parents = False):
|
120
|
134
|
fields = self.__fields if no_parents else self.__all_fields
|
|
135
|
+ if CLASS_ID_FIELDNAME in fields:
|
|
136
|
+ del(fields[CLASS_ID_FIELDNAME])
|
121
|
137
|
try:
|
122
|
138
|
return list(fields.values()) if uid is None else fields[uid]
|
123
|
139
|
except KeyError:
|