83 contained entity is enough since it will implicitly reindex the container |
83 contained entity is enough since it will implicitly reindex the container |
84 entity. |
84 entity. |
85 """ |
85 """ |
86 ftcontainer = session.repo.schema.rschema(rtype).fulltext_container |
86 ftcontainer = session.repo.schema.rschema(rtype).fulltext_container |
87 if ftcontainer == 'subject': |
87 if ftcontainer == 'subject': |
88 FTIndexEntityOp(session, entity=session.entity(eidto)) |
88 FTIndexEntityOp(session, entity=session.entity_from_eid(eidto)) |
89 elif ftcontainer == 'object': |
89 elif ftcontainer == 'object': |
90 FTIndexEntityOp(session, entity=session.entity(eidfrom)) |
90 FTIndexEntityOp(session, entity=session.entity_from_eid(eidfrom)) |
91 def fti_update_after_delete_relation(session, eidfrom, rtype, eidto): |
91 def fti_update_after_delete_relation(session, eidfrom, rtype, eidto): |
92 """sync fulltext index when relevant relation is deleted. Reindexing both |
92 """sync fulltext index when relevant relation is deleted. Reindexing both |
93 entities is necessary. |
93 entities is necessary. |
94 """ |
94 """ |
95 if session.repo.schema.rschema(rtype).fulltext_container: |
95 if session.repo.schema.rschema(rtype).fulltext_container: |
96 FTIndexEntityOp(session, entity=session.entity(eidto)) |
96 FTIndexEntityOp(session, entity=session.entity_from_eid(eidto)) |
97 FTIndexEntityOp(session, entity=session.entity(eidfrom)) |
97 FTIndexEntityOp(session, entity=session.entity_from_eid(eidfrom)) |
98 |
98 |
99 class SyncOwnersOp(PreCommitOperation): |
99 class SyncOwnersOp(PreCommitOperation): |
100 |
100 |
101 def precommit_event(self): |
101 def precommit_event(self): |
102 self.session.unsafe_execute('SET X owned_by U WHERE C owned_by U, C eid %(c)s,' |
102 self.session.unsafe_execute('SET X owned_by U WHERE C owned_by U, C eid %(c)s,' |
377 assert rtype == 'in_state' |
377 assert rtype == 'in_state' |
378 state = previous_state(session, fromeid) |
378 state = previous_state(session, fromeid) |
379 etype = session.describe(fromeid)[0] |
379 etype = session.describe(fromeid)[0] |
380 if not (session.is_super_session or 'managers' in session.user.groups): |
380 if not (session.is_super_session or 'managers' in session.user.groups): |
381 if not state is None: |
381 if not state is None: |
382 entity = session.entity(fromeid) |
382 entity = session.entity_from_eid(fromeid) |
383 # we should find at least one transition going to this state |
383 # we should find at least one transition going to this state |
384 try: |
384 try: |
385 iter(state.transitions(entity, toeid)).next() |
385 iter(state.transitions(entity, toeid)).next() |
386 except StopIteration: |
386 except StopIteration: |
387 msg = session._('transition is not allowed') |
387 msg = session._('transition is not allowed') |