From: Alex Sadleir Date: Tue, 24 Sep 2013 01:54:51 +0000 Subject: Allow anonymous access to datastore API search X-Git-Url: https://maxious.lambdacomplex.org/git/?p=ckanext-datagovau.git&a=commitdiff&h=6d4c0830661e5d06a7e2d818491b99a469d52fee --- Allow anonymous access to datastore API search --- --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,21 +3,6 @@ - - - - - - - - - - - --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,26 +5,34 @@ - + + + + + + + - - - - - - - + + + + + + + - - + + - + + + - + @@ -85,28 +93,28 @@ - - + + - + - - + + - + - - + + - + @@ -115,7 +123,52 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -129,6 +182,7 @@ + @@ -139,28 +193,30 @@ - @@ -188,7 +244,7 @@ - + @@ -231,7 +287,7 @@ @@ -248,6 +304,10 @@ - + + + + + + + + + + - - - - + + - - + + @@ -486,6 +569,23 @@ + + @@ -507,24 +607,24 @@ - - + + + + - + - + - + - - @@ -572,7 +672,7 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + No facets are configured + + + + + + + + + + + + + + + + + + + + + + ckanext-datagovau + + + + + + + + + + + + + + + + + + + + --- a/ckanext/datagovau/plugin.py +++ b/ckanext/datagovau/plugin.py @@ -5,28 +5,29 @@ import ckan.lib.dictization.model_dictize as model_dictize import ckan.plugins.toolkit as tk import ckan.model as model +from pylons import config #parse the activity feed for last active non-system user def get_last_active_user(id): - system_user = "de0ba262-83fe-45e2-adda-41bb9f0c86d8" - user_list = [x for x in lib.helpers.get_action('package_activity_list',{'id':id}) if x['user_id'] != system_user] - user = user_list[0]['user_id'] + system_user = lib.helpers.get_action('user_show',{'id': config.get('ckan.site_id', 'ckan_site_user')}) + user_list = [x for x in lib.helpers.get_action('package_activity_list',{'id':id}) if x['user_id'] != system_user['id']] + user = None + if len(user_list) > 0: + user = user_list[0].get('user_id', None) if user is None: - return lib.helpers.get_action('user_show',{'id':system_user}) + return system_user else: return lib.helpers.get_action('user_show',{'id':user}) # get user created datasets and those they have edited def get_user_datasets(user_dict): created_datasets_list = user_dict['datasets'] - active_datasets_id_list = [x['data']['package'] for x in + active_datasets_list = [x['data']['package'] for x in lib.helpers.get_action('user_activity_list',{'id':user_dict['id']}) if x['data'].get('package')] - active_datasets_list = active_datasets_id_list #if you need more detail, fetch each dataset here - print active_datasets_list return created_datasets_list + active_datasets_list -class ExampleIDatasetFormPlugin(plugins.SingletonPlugin, +class DataGovAuPlugin(plugins.SingletonPlugin, tk.DefaultDatasetForm): '''An example IDatasetForm CKAN plugin. @@ -36,17 +37,13 @@ plugins.implements(plugins.IConfigurer, inherit=False) plugins.implements(plugins.IDatasetForm, inherit=False) plugins.implements(plugins.ITemplateHelpers, inherit=False) + plugins.implements(plugins.IAuthFunctions) - # These record how many times methods that this plugin's methods are - # called, for testing purposes. - num_times_new_template_called = 0 - num_times_read_template_called = 0 - num_times_edit_template_called = 0 - num_times_search_template_called = 0 - num_times_history_template_called = 0 - num_times_package_form_called = 0 - num_times_check_data_dict_called = 0 - num_times_setup_template_variables_called = 0 + def datastore_search(context, data_dict): + return {'success': True} # allow all + + def get_auth_functions(self): + return {'datastore_search': datastore_search} def update_config(self, config): --- a/ckanext/datagovau/templates/package/read.html +++ b/ckanext/datagovau/templates/package/read.html @@ -1,5 +1,11 @@ {% ckan_extends %} +{% block primary_content_inner %} +{{ super() }} +
+ {{ h.disqus_comments() }} +
+{% endblock %} {% block package_additional_info %}