def _log_event(cls, instance): indexer = get_indexer() db.session.flush() user = cls._get_user() revision = models.Revision(instance, user.id, 'created', instance.log_json()) event = models.Event( modified_by=user, action="POST", resource_id=instance.id, resource_type=instance.type, context=instance.context, revisions=[revision], ) db.session.add(revision) db.session.add(event) indexer.update_record(fts_record_for(instance), commit=False)
def _log_event(cls, instance, action="POST"): db.session.flush() user = cls._get_user() revision = models.Revision(instance, user.id, 'created', instance.log_json()) event = models.Event( modified_by=user, action=action, resource_id=instance.id, resource_type=instance.type, revisions=[revision], ) db.session.add(revision) db.session.add(event) indexer = get_indexer() if cls._is_reindex_needed(instance): indexer.delete_record(instance.id, instance.type, commit=False) indexer.create_record(instance, commit=False)