Merge branch 'master' of git+ssh://maxious.lambdacomplex.org/git/ckanext-datagovau
--- a/ckanext/datagovau/plugin.py
+++ b/ckanext/datagovau/plugin.py
@@ -15,6 +15,15 @@
return lib.helpers.get_action('user_show',{'id':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
+ 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,
@@ -52,7 +61,7 @@
# config['licenses_group_url'] = 'http://%(ckan.site_url)/licenses.json'
def get_helpers(self):
- return {'get_last_active_user': get_last_active_user}
+ return {'get_last_active_user': get_last_active_user, 'get_user_datasets': get_user_datasets}
def is_fallback(self):
# Return True to register this plugin as the default handler for
--- /dev/null
+++ b/ckanext/datagovau/templates/user/dashboard_datasets.html
@@ -1,1 +1,16 @@
+{% ckan_extends %}
+{% block primary_content_inner %}
+ <h2 class="page-heading">{{ _('My Datasets') }}</h2>
+ {% if h.get_user_datasets(c.user_dict) %}
+ {% snippet 'snippets/package_list.html', packages=h.get_user_datasets(c.user_dict) %}
+ {% else %}
+ <p class="empty">
+ You haven\'t created/edited any datasets.
+ {% if h.check_access('package_create') %}
+ {% link_for _('Create one now?'), controller='package', action='new' %}
+ {% endif %}
+ </p>
+ {% endif %}
+{% endblock %}
+
--- /dev/null
+++ b/ckanext/datagovau/templates/user/read.html
@@ -1,1 +1,29 @@
+{% ckan_extends %}
+
+{% block primary_content_inner %}
+ <h2 class="hide-heading">
+ {% block page_heading %}{{ _('Datasets') }}{% endblock %}
+ </h2>
+ {% block package_list %}
+ {% if h.get_user_datasets(c.user_dict) %}
+ {% snippet 'snippets/package_list.html', packages=h.get_user_datasets(c.user_dict) %}
+ {% else %}
+
+ {% if c.is_myself %}
+ <p class="empty">
+ {{ _('You haven\'t created any datasets.') }}
+ {% if h.check_access('package_create') %}
+ {% link_for _('Create one now?'), controller='package', action='new' %}
+ {% endif %}
+ </p>
+ {% else %}
+ <p class="empty">
+ {{ _('User hasn\'t created any datasets.') }}
+ </p>
+ {% endif %}
+ {% endif %}
+ {% endblock %}
+{% endblock %}
+
+