|
@@ -7,14 +7,13 @@ import sqlalchemy as sql
|
7
|
7
|
import EditorialModel.fieldtypes as ftypes
|
8
|
8
|
import EditorialModel.classes
|
9
|
9
|
|
|
10
|
+## Represents type of documents
|
|
11
|
+# A type is a specialisation of a class, it can select optional field,
|
|
12
|
+# they have hooks, are organized in hierarchy and linked to other
|
|
13
|
+# EmType with special fields called relation_to_type fields
|
|
14
|
+#
|
|
15
|
+# @see EditorialModel::components::EmComponent
|
10
|
16
|
class EmType(EmComponent):
|
11
|
|
- """ Represents type of documents
|
12
|
|
-
|
13
|
|
- A type is a specialisation of a class, it can select optional field,
|
14
|
|
- they have hooks, are organized in hierarchy and linked to other
|
15
|
|
- EmType with special fields called relation_to_type fields
|
16
|
|
- @see EmComponent
|
17
|
|
- """
|
18
|
17
|
table = 'em_type'
|
19
|
18
|
|
20
|
19
|
## @brief Specific EmClass fields
|
|
@@ -26,107 +25,96 @@ class EmType(EmComponent):
|
26
|
25
|
]
|
27
|
26
|
|
28
|
27
|
@classmethod
|
|
28
|
+ ## Create a new EmType and instanciate it
|
|
29
|
+ # @param name str: The name of the new type
|
|
30
|
+ # @param em_class EmClass: The class that the new type will specialize
|
|
31
|
+ # @return An EmType instance
|
|
32
|
+ #
|
|
33
|
+ # @see EmComponent::__init__()
|
|
34
|
+ #
|
|
35
|
+ # @todo Remove hardcoded default value for icon
|
|
36
|
+ # @todo check that em_class is an EmClass object
|
29
|
37
|
def create(c, name, em_class):
|
30
|
|
- """ Create a new EmType and instanciate it
|
31
|
|
-
|
32
|
|
- @param name str: The name of the new type
|
33
|
|
- @param em_class EmClass: The class that the new type will specialize
|
34
|
|
-
|
35
|
|
- @see EmComponent::__init__()
|
36
|
|
-
|
37
|
|
- @todo Remove hardcoded default value for icon
|
38
|
|
- @todo check that em_class is an EmClass object
|
39
|
|
- """
|
40
|
38
|
try:
|
41
|
39
|
exists = EmType(name)
|
42
|
40
|
except EmComponentNotExistError:
|
43
|
41
|
return super(EmType, c).create(name=name, class_id=em_class.uid, icon=0)
|
44
|
42
|
|
45
|
43
|
return exists
|
46
|
|
-
|
|
44
|
+
|
|
45
|
+ ## Get the list of associated fieldgroups
|
|
46
|
+ # @return A list of EditorialModel::fieldgroups::EmFieldGroup
|
47
|
47
|
def field_groups(self):
|
48
|
|
- """ Get the list of associated fieldgroups
|
49
|
|
- @return A list of EmFieldGroup
|
50
|
|
- """
|
51
|
48
|
pass
|
52
|
49
|
|
53
|
|
-
|
|
50
|
+ ## Get the list of associated fields
|
|
51
|
+ # @return A list of EditorialModel::fields::EmField
|
54
|
52
|
def fields(self):
|
55
|
|
- """ Get the list of associated fields
|
56
|
|
- @return A list of EmField
|
57
|
|
- """
|
58
|
53
|
pass
|
59
|
54
|
|
|
55
|
+ ## Indicate that an optionnal field is used
|
|
56
|
+ # @param field EmField: The optional field to select
|
|
57
|
+ # @throw TypeError if field is not an EmField
|
|
58
|
+ # @throw ValueError if field is not an optionnal field
|
60
|
59
|
def select_field(self, field):
|
61
|
|
- """ Indicate that an optionnal field is used
|
62
|
|
-
|
63
|
|
- @param field EmField: The optional field to select
|
64
|
|
- @throw ValueError, TypeError
|
65
|
|
- @todo change exception type and define return value and raise condition
|
66
|
|
- """
|
67
|
60
|
pass
|
68
|
61
|
|
|
62
|
+ ## Indicate that an optionnal field will not be used (anymore)
|
|
63
|
+ # @param field EmField: The optionnal field to unselect
|
|
64
|
+ # @throw TypeError if field is not an EmField
|
|
65
|
+ # @throw ValueError if field is not an optionnal field
|
69
|
66
|
def unselect_field(self, field):
|
70
|
|
- """ Indicate that an optionnal field will not be used
|
71
|
|
- @param field EmField: The optional field to unselect
|
72
|
|
- @throw ValueError, TypeError
|
73
|
|
- @todo change exception type and define return value and raise condition
|
74
|
|
- """
|
75
|
67
|
pass
|
76
|
68
|
|
77
|
|
-
|
|
69
|
+ ## Get the list of associated hooks
|
|
70
|
+ # @note Not conceptualized yet
|
|
71
|
+ # @todo Conception
|
78
|
72
|
def hooks(self):
|
79
|
|
- """Get the list of associated hooks"""
|
80
|
73
|
pass
|
81
|
74
|
|
|
75
|
+ ## Add a new hook
|
|
76
|
+ # @param hook EmHook: An EmHook instance
|
|
77
|
+ # @throw TypeError
|
|
78
|
+ # @note Not conceptualized yet
|
|
79
|
+ # @todo Conception
|
82
|
80
|
def add_hook(self, hook):
|
83
|
|
- """ Add a new hook
|
84
|
|
- @param hook EmHook: A EmHook instance
|
85
|
|
- @throw TypeError
|
86
|
|
- """
|
87
|
81
|
pass
|
88
|
82
|
|
89
|
|
- def del_hook(hook):
|
90
|
|
- """ Delete a hook
|
91
|
|
- @param hook EmHook: A EmHook instance
|
92
|
|
- @throw TypeError
|
93
|
|
- @todo Maybe we don't need a EmHook instance but just a hook identifier
|
94
|
|
- """
|
|
83
|
+ ## Delete a hook
|
|
84
|
+ # @param hook EmHook: An EmHook instance
|
|
85
|
+ # @throw TypeError
|
|
86
|
+ # @note Not conceptualized yet
|
|
87
|
+ # @todo Conception
|
|
88
|
+ # @todo Maybe we don't need a EmHook instance but just a hook identifier
|
|
89
|
+ def del_hook(self,hook):
|
95
|
90
|
pass
|
96
|
91
|
|
97
|
92
|
|
|
93
|
+ ## Get the list of superiors EmType in the type hierarchy
|
|
94
|
+ # @return A list of EmType
|
98
|
95
|
def superiors(self):
|
99
|
|
- """ Get the list of superiors EmType in the type hierarchy
|
100
|
|
- @return A list of EmType
|
101
|
|
- """
|
102
|
96
|
pass
|
103
|
97
|
|
104
|
98
|
|
|
99
|
+ ## Add a superior in the type hierarchy
|
|
100
|
+ # @param em_type EmType: An EmType instance
|
|
101
|
+ # @param relation_nature str: The name of the relation's nature
|
|
102
|
+ # @throw TypeError when em_type not an EmType instance
|
|
103
|
+ # @throw ValueError when relation_nature isn't reconized or not allowed for this type
|
|
104
|
+ # @todo define return value and raise condition
|
105
|
105
|
def add_superior(self, em_type, relation_nature):
|
106
|
|
- """ Add a superior in the type hierarchy
|
107
|
|
-
|
108
|
|
- @param em_type EmType: An EmType instance
|
109
|
|
- @param relation_nature str: The name of the relation's nature
|
110
|
|
- @throw TypeError
|
111
|
|
- @todo define return value and raise condition
|
112
|
|
- """
|
113
|
106
|
pass
|
114
|
107
|
|
|
108
|
+ ## Delete a superior in the type hierarchy
|
|
109
|
+ # @param em_type EmType: An EmType instance
|
|
110
|
+ # @throw TypeError when em_type isn't an EmType instance
|
|
111
|
+ # @todo define return value and raise condition
|
115
|
112
|
def del_superior(self, em_type):
|
116
|
|
- """ Delete a superior in the type hierarchy
|
117
|
|
-
|
118
|
|
- @param em_type EmType: An EmType instance
|
119
|
|
- @throw TypeError
|
120
|
|
- @todo define return value and raise condition
|
121
|
|
- """
|
122
|
113
|
pass
|
123
|
114
|
|
|
115
|
+ ## @brief Get the list of linked type
|
|
116
|
+ # Types are linked with special fields called relation_to_type fields
|
|
117
|
+ # @return a list of EmType
|
|
118
|
+ # @see EmFields
|
124
|
119
|
def linked_types(self):
|
125
|
|
- """ Get the list of linked type
|
126
|
|
-
|
127
|
|
- Types are linked with special fields called relation_to_type fields
|
128
|
|
-
|
129
|
|
- @return a list of EmType
|
130
|
|
- @see EmFields
|
131
|
|
- """
|
132
|
120
|
pass
|