From: Alex Sadleir Date: Mon, 23 Sep 2013 23:45:45 +0000 Subject: Move Disqus comments to package not resource page X-Git-Url: https://maxious.lambdacomplex.org/git/?p=ckanext-datagovau.git&a=commitdiff&h=3e644c55761b979a351ee63777a3c9fa8d4e6fe8 --- Move Disqus comments to package not resource page --- --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,21 +3,6 @@ - - - - - - - - - - - --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,14 +5,12 @@ - - - + - + @@ -39,7 +37,6 @@ - + @@ -88,7 +86,7 @@ - + @@ -97,25 +95,25 @@ - + - + - + - - + + - + @@ -129,6 +127,7 @@ + @@ -147,20 +146,21 @@ - @@ -188,7 +188,7 @@ - + @@ -231,7 +231,7 @@ @@ -248,6 +248,10 @@ - + + + + + + + + + + - - - - + + - - + + @@ -486,6 +479,23 @@ + + @@ -507,24 +517,24 @@ - - + + + - + - + - + - @@ -572,7 +582,7 @@ - - - - - - - - - - - + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - + + + + + + + + + + + + + - - - + + + @@ -681,11 +657,103 @@ - + + + + + + + + + + + + + + + + + + + + + + No facets are configured + + + + + + + + + + + + + + + + + + + + + + ckanext-datagovau + + + + + + + + + + + + + + + + + + + + --- a/ckanext/datagovau/plugin.py +++ b/ckanext/datagovau/plugin.py @@ -5,16 +5,26 @@ 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_list = [x['data']['package'] for x in + lib.helpers.get_action('user_activity_list',{'id':user_dict['id']}) if x['data'].get('package')] + return created_datasets_list + active_datasets_list class ExampleIDatasetFormPlugin(plugins.SingletonPlugin, @@ -52,7 +62,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 --- 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 %}
{{ _('My Datasets') }} + {% if h.get_user_datasets(c.user_dict) %} + {% snippet 'snippets/package_list.html', packages=h.get_user_datasets(c.user_dict) %} + {% else %} +

+ You haven\'t created/edited any datasets. + {% if h.check_access('package_create') %} + {% link_for _('Create one now?'), controller='package', action='new' %} + {% endif %} +

+ {% endif %} +{% endblock %} + --- /dev/null +++ b/ckanext/datagovau/templates/user/read.html @@ -1,1 +1,29 @@ +{% ckan_extends %} + +{% block primary_content_inner %} +

+ {% block page_heading %}{{ _('Datasets') }}{% endblock %} +

+ {% 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 %} +

+ {{ _('You haven\'t created any datasets.') }} + {% if h.check_access('package_create') %} + {% link_for _('Create one now?'), controller='package', action='new' %} + {% endif %} +

+ {% else %} +

+ {{ _('User hasn\'t created any datasets.') }} +

+ {% endif %} + {% endif %} + {% endblock %} +{% endblock %} + +