From 80559a6272ea24e0643ac6adaebacc9e2d39b8ff Mon Sep 17 00:00:00 2001 From: Mikko Nieminen Date: Tue, 28 Mar 2017 10:39:41 +0300 Subject: [PATCH] Index ratings in solr --- ckanext/rating/plugin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ckanext/rating/plugin.py b/ckanext/rating/plugin.py index ea871d2..0e07553 100644 --- a/ckanext/rating/plugin.py +++ b/ckanext/rating/plugin.py @@ -52,6 +52,7 @@ class RatingPlugin(plugins.SingletonPlugin, DefaultTranslation): plugins.implements(plugins.IActions) plugins.implements(plugins.ITemplateHelpers) plugins.implements(plugins.IAuthFunctions) + plugins.implements(plugins.IPackageController, inherit=True) plugins.implements(plugins.IRoutes, inherit=True) if toolkit.check_ckan_version(min_version='2.5.0'): plugins.implements(plugins.ITranslation, inherit=True) @@ -89,7 +90,12 @@ class RatingPlugin(plugins.SingletonPlugin, DefaultTranslation): def get_auth_functions(self): return rating_auth.get_rating_auth_dict() + # IPackageController + def before_index(self, data_dict): + rating_dict = action.rating_package_get(None, { 'package_id': data_dict['id'] }) + data_dict['rating'] = rating_dict.get('rating') + return data_dict # IRoutes