128 class modification_date(MetaAttributeRelationType): |
128 class modification_date(MetaAttributeRelationType): |
129 """latest modification time of an entity""" |
129 """latest modification time of an entity""" |
130 cardinality = '11' |
130 cardinality = '11' |
131 subject = '**' |
131 subject = '**' |
132 object = 'Datetime' |
132 object = 'Datetime' |
133 |
133 |
134 |
|
135 class State(MetaEntityType): |
|
136 """used to associate simple states to an entity type and/or to define |
|
137 workflows |
|
138 """ |
|
139 name = String(required=True, indexed=True, internationalizable=True, |
|
140 maxsize=256) |
|
141 description = RichString(fulltextindexed=True, default='text/rest', |
|
142 description=_('semantic description of this state')) |
|
143 |
|
144 state_of = SubjectRelation('EEType', cardinality='+*', |
|
145 description=_('entity types which may use this state'), |
|
146 constraints=[RQLConstraint('O final FALSE')]) |
|
147 allowed_transition = SubjectRelation('Transition', cardinality='**', |
|
148 constraints=[RQLConstraint('S state_of ET, O transition_of ET')], |
|
149 description=_('allowed transitions from this state')) |
|
150 |
|
151 initial_state = ObjectRelation('EEType', cardinality='?*', |
|
152 # S initial_state O, O state_of S |
|
153 constraints=[RQLConstraint('O state_of S')], |
|
154 description=_('initial state for entities of this type')) |
|
155 |
|
156 |
|
157 class Transition(MetaEntityType): |
|
158 """use to define a transition from one or multiple states to a destination |
|
159 states in workflow's definitions. |
|
160 """ |
|
161 name = String(required=True, indexed=True, internationalizable=True, |
|
162 maxsize=256) |
|
163 description_format = String(meta=True, internationalizable=True, maxsize=50, |
|
164 default='text/rest', constraints=[format_constraint]) |
|
165 description = String(fulltextindexed=True, |
|
166 description=_('semantic description of this transition')) |
|
167 condition = SubjectRelation('RQLExpression', cardinality='*?', composite='subject', |
|
168 description=_('a RQL expression which should return some results, ' |
|
169 'else the transition won\'t be available. ' |
|
170 'This query may use X and U variables ' |
|
171 'that will respectivly represents ' |
|
172 'the current entity and the current user')) |
|
173 |
|
174 require_group = SubjectRelation('EGroup', cardinality='**', |
|
175 description=_('group in which a user should be to be ' |
|
176 'allowed to pass this transition')) |
|
177 transition_of = SubjectRelation('EEType', cardinality='+*', |
|
178 description=_('entity types which may use this transition'), |
|
179 constraints=[RQLConstraint('O final FALSE')]) |
|
180 destination_state = SubjectRelation('State', cardinality='?*', |
|
181 constraints=[RQLConstraint('S transition_of ET, O state_of ET')], |
|
182 description=_('destination state for this transition')) |
|
183 |
|
184 |
|
185 class TrInfo(MetaEntityType): |
|
186 from_state = SubjectRelation('State', cardinality='?*') |
|
187 to_state = SubjectRelation('State', cardinality='1*') |
|
188 comment_format = String(meta=True, internationalizable=True, maxsize=50, |
|
189 default='text/rest', constraints=[format_constraint]) |
|
190 comment = String(fulltextindexed=True) |
|
191 # get actor and date time using owned_by and creation_date |
|
192 |
|
193 |
|
194 class from_state(MetaRelationType): |
|
195 inlined = True |
|
196 class to_state(MetaRelationType): |
|
197 inlined = True |
|
198 class wf_info_for(MetaRelationType): |
|
199 """link a transition information to its object""" |
|
200 permissions = { |
|
201 'read': ('managers', 'users', 'guests',),# RRQLExpression('U has_read_permission O')), |
|
202 'add': (), # handled automatically, no one should add one explicitly |
|
203 'delete': ('managers',), # RRQLExpression('U has_delete_permission O') |
|
204 } |
|
205 inlined = True |
|
206 composite = 'object' |
|
207 fulltext_container = composite |
|
208 |
|
209 class state_of(MetaRelationType): |
|
210 """link a state to one or more entity type""" |
|
211 class transition_of(MetaRelationType): |
|
212 """link a transition to one or more entity type""" |
|
213 |
|
214 class initial_state(MetaRelationType): |
|
215 """indicate which state should be used by default when an entity using |
|
216 states is created |
|
217 """ |
|
218 inlined = True |
|
219 |
|
220 class destination_state(MetaRelationType): |
|
221 """destination state of a transition""" |
|
222 inlined = True |
|
223 |
|
224 class allowed_transition(MetaRelationType): |
|
225 """allowed transition from this state""" |
|
226 |
|
227 class in_state(UserRelationType): |
|
228 """indicate the current state of an entity""" |
|
229 meta = True |
|
230 # not inlined intentionnaly since when using ldap sources, user'state |
|
231 # has to be stored outside the EUser table |
|
232 |
|
233 # add/delete perms given to managers/users, after what most of the job |
|
234 # is done by workflow enforcment |
|
235 |
|
236 |
|
237 class EProperty(EntityType): |
134 class EProperty(EntityType): |
238 """used for cubicweb configuration. Once a property has been created you |
135 """used for cubicweb configuration. Once a property has been created you |
239 can't change the key. |
136 can't change the key. |
240 """ |
137 """ |
241 permissions = { |
138 permissions = { |