From 6673e316757ac5ca0dfb9be003a3cfb1a5508c29 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Fri, 29 Apr 2016 13:37:01 +0200 Subject: [PATCH] Skip indexing of nodes of a private project --- pillar/application/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pillar/application/__init__.py b/pillar/application/__init__.py index 3032a8a4..42a96870 100644 --- a/pillar/application/__init__.py +++ b/pillar/application/__init__.py @@ -189,7 +189,15 @@ def before_replacing_node(item, original): def after_replacing_node(item, original): - """Push an update to the Algolia index when a node item is updated""" + """Push an update to the Algolia index when a node item is updated. If the + project is private, prevent public indexing. + """ + projects_collection = app.data.driver.db['projects'] + project = projects_collection.find_one({'_id': item['project']}, + {'is_private': 1}) + if 'is_private' in project and project['is_private']: + # Skip index updating and return + return from algoliasearch.client import AlgoliaException from utils.algolia import algolia_index_node_save