|
@@ -9,33 +9,38 @@ import sqlalchemy as sql
|
9
|
9
|
|
10
|
10
|
import EditorialModel
|
11
|
11
|
|
|
12
|
+## Represents groups of EmField associated with an EmClass
|
|
13
|
+#
|
|
14
|
+# EmClass fields representation is organised with EmFieldGroup
|
|
15
|
+# @see EditorialModel::fields::EmField EditorialModel::classes::EmClass
|
12
|
16
|
class EmFieldGroup(EmComponent):
|
13
|
|
- """ Represents groups of EmField
|
14
|
|
-
|
15
|
|
- EmClass fields representation is organised with EmFieldGroup
|
16
|
|
- @see EmField
|
17
|
|
- """
|
18
|
17
|
|
|
18
|
+ ## The database table name
|
19
|
19
|
table = 'em_fieldgroup'
|
|
20
|
+ ## List of fields
|
|
21
|
+ # @todo Bad storage, here we want an ordereddict not a tuple list
|
20
|
22
|
_fields = [('class_id', ftypes.EmField_integer())]
|
21
|
|
-
|
|
23
|
+
|
|
24
|
+ ## Instanciate an EmFieldGroup with data fetched from db
|
|
25
|
+ # @param id_or_name str|int: Identify the EmFieldGroup by name or by global_id
|
|
26
|
+ # @throw TypeError
|
|
27
|
+ # @see EditorialModel::components::EmComponent::__init__()
|
|
28
|
+ # @throw EditorialModel::components::EmComponentNotExistError
|
22
|
29
|
def __init__(self, id_or_name):
|
23
|
|
- """ Instanciate an EmFieldGroup with data fetched from db
|
24
|
|
- @param id_or_name str|int: Identify the EmFieldGroup by name or by global_id
|
25
|
|
- @throw TypeError
|
26
|
|
- @see component::EmComponent::__init__()
|
27
|
|
- """
|
28
|
30
|
self.table = EmFieldGroup.table
|
29
|
31
|
self._fields = self.__class__._fields
|
30
|
32
|
super(EmFieldGroup, self).__init__(id_or_name)
|
31
|
33
|
|
32
|
34
|
@classmethod
|
|
35
|
+ ## Create a new EmFieldGroup
|
|
36
|
+ #
|
|
37
|
+ # Save it in database and return an instance*
|
|
38
|
+ # @param name str: The name of the new EmFieldGroup
|
|
39
|
+ # @param em_class EmClass|str|int : Can be an EditorialModel::classes::EmClass uid, name or instance
|
|
40
|
+ # @throw ValueError If an EmFieldGroup with this name allready exists
|
|
41
|
+ # @throw ValueError If the specified EmClass don't exists
|
|
42
|
+ # @throw TypeError If an argument is of an unexepted type
|
33
|
43
|
def create(c, name, em_class):
|
34
|
|
- """ Create a new EmFieldGroup, save it and instanciate it
|
35
|
|
-
|
36
|
|
- @param name str: The name of the new fielgroup
|
37
|
|
- @param em_class EmClass|str|int: The new EmFieldGroup will belong to this class
|
38
|
|
- """
|
39
|
44
|
if not isinstance(em_class, EmClass):
|
40
|
45
|
if isinstance(em_class, int) or isinstance(em_class, str):
|
41
|
46
|
try:
|
|
@@ -57,8 +62,8 @@ class EmFieldGroup(EmComponent):
|
57
|
62
|
|
58
|
63
|
return exists
|
59
|
64
|
|
|
65
|
+ ## Get the list of associated fields
|
|
66
|
+ # @return A list of EditorialModel::fields::EmField
|
|
67
|
+ # @todo Implement this method
|
60
|
68
|
def fields(self):
|
61
|
|
- """ Get the list of associated fields
|
62
|
|
- @return A list of EmField
|
63
|
|
- """
|
64
|
69
|
pass
|