Implement IPermissionLabel interface to suppport searchable datasets in v2.7

This commit is contained in:
Francisco de la Vega 2017-11-15 19:09:36 +01:00
parent efae19f0fb
commit c7eef4df32
1 changed files with 21 additions and 1 deletions

View File

@ -20,6 +20,7 @@
import ckan.lib.search as search
import ckan.model as model
import ckan.plugins as p
from ckan.lib.plugins import DefaultPermissionLabels
import ckan.plugins.toolkit as tk
import auth
import actions
@ -32,7 +33,7 @@ import helpers as helpers
HIDDEN_FIELDS = [constants.ALLOWED_USERS, constants.SEARCHABLE]
class PrivateDatasets(p.SingletonPlugin, tk.DefaultDatasetForm):
class PrivateDatasets(p.SingletonPlugin, tk.DefaultDatasetForm, DefaultPermissionLabels):
p.implements(p.IDatasetForm)
p.implements(p.IAuthFunctions)
@ -41,6 +42,7 @@ class PrivateDatasets(p.SingletonPlugin, tk.DefaultDatasetForm):
p.implements(p.IActions)
p.implements(p.IPackageController, inherit=True)
p.implements(p.ITemplateHelpers)
p.implements(p.IPermissionLabels)
######################################################################
############################ DATASET FORM ############################
@ -291,6 +293,24 @@ class PrivateDatasets(p.SingletonPlugin, tk.DefaultDatasetForm):
return search_results
####
def get_dataset_labels(self, dataset_obj):
labels = super(PrivateDatasets, self).get_dataset_labels(
dataset_obj)
if getattr(dataset_obj, 'searchable', False):
labels.append('searchable')
return labels
def get_user_dataset_labels(self, user_obj):
labels = super(PrivateDatasets, self).get_user_dataset_labels(
user_obj)
labels.append('searchable')
return labels
######################################################################
######################### ITEMPLATESHELPER ###########################
######################################################################