From: Alex Sadleir Date: Wed, 25 Sep 2013 06:55:24 +0000 Subject: Fix refactoring of plugin name X-Git-Url: https://maxious.lambdacomplex.org/git/?p=ckanext-datagovau.git&a=commitdiff&h=7c7d8b7e913dcff8ad6320b4d2d175e6f6b874b4 --- Fix refactoring of plugin name --- --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,21 +3,7 @@ - - - - - - - - - - - + --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,26 +5,32 @@ - + + + + + - - - - - - - + + + + + + + - - + + - + + + - + @@ -85,28 +91,28 @@ - - + + - + - - + + - + - - + + - + @@ -115,7 +121,52 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -129,6 +180,7 @@ + @@ -139,28 +191,30 @@ - @@ -188,7 +242,7 @@ - + @@ -231,7 +285,7 @@ @@ -248,6 +302,10 @@ - + + + + + + + + + + - - - - + + - - + + @@ -486,6 +567,23 @@ + + @@ -507,24 +605,24 @@ - - + + + + - + - + - + - - @@ -572,7 +670,7 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + No facets are configured + + + + + + + + + + + + + + + + + + + + + + ckanext-datagovau + + + + + + + + + + + + + + + + + + + + --- a/ckanext/datagovau/plugin.py +++ b/ckanext/datagovau/plugin.py @@ -5,19 +5,31 @@ 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, +def datastore_search(context, data_dict): + return {'success': True} # allow all datastore search + +class DataGovAuPlugin(plugins.SingletonPlugin, tk.DefaultDatasetForm): '''An example IDatasetForm CKAN plugin. @@ -27,17 +39,11 @@ 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 get_auth_functions(self): + return {'datastore_search': datastore_search} def update_config(self, config): @@ -52,7 +58,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 @@ -66,17 +72,17 @@ def create_package_schema(self): - schema = super(ExampleIDatasetFormPlugin, self).create_package_schema() + schema = super(DataGovAuPlugin, self).create_package_schema() schema = self._modify_package_schema(schema) return schema def update_package_schema(self): - schema = super(ExampleIDatasetFormPlugin, self).update_package_schema() + schema = super(DataGovAuPlugin, self).update_package_schema() schema = self._modify_package_schema(schema) return schema def show_package_schema(self): - schema = super(ExampleIDatasetFormPlugin, self).show_package_schema() + schema = super(DataGovAuPlugin, self).show_package_schema() # Don't show vocab tags mixed in with normal 'free' tags # (e.g. on dataset pages, or on the search page) @@ -139,25 +145,25 @@ # called. def setup_template_variables(self, context, data_dict): - return super(ExampleIDatasetFormPlugin, self).setup_template_variables( + return super(DataGovAuPlugin, self).setup_template_variables( context, data_dict) def new_template(self): - return super(ExampleIDatasetFormPlugin, self).new_template() + return super(DataGovAuPlugin, self).new_template() def read_template(self): - return super(ExampleIDatasetFormPlugin, self).read_template() + return super(DataGovAuPlugin, self).read_template() def edit_template(self): - return super(ExampleIDatasetFormPlugin, self).edit_template() + return super(DataGovAuPlugin, self).edit_template() def search_template(self): - return super(ExampleIDatasetFormPlugin, self).search_template() + return super(DataGovAuPlugin, self).search_template() def history_template(self): - return super(ExampleIDatasetFormPlugin, self).history_template() + return super(DataGovAuPlugin, self).history_template() def package_form(self): - return super(ExampleIDatasetFormPlugin, self).package_form() + return super(DataGovAuPlugin, self).package_form() --- a/ckanext/datagovau/templates/package/read.html +++ b/ckanext/datagovau/templates/package/read.html @@ -1,13 +1,19 @@ {% ckan_extends %} +{% block primary_content_inner %} +{{ super() }} +
+ {{ h.disqus_comments() }} +
+{% endblock %} {% block package_additional_info %} -
+

{{ _('Additional Info') }}

@@ -38,17 +44,11 @@ {% endif %} - {% if pkg.get('Agency Program') %} - - - - - {% endif %} - {% if h.get_pkg_dict_extra(pkg,'DCTERMS.Source.URI') %} + {% if pkg.get('url') %} - {% endif %} @@ -67,13 +67,6 @@ {% endif %} - {% if h.get_pkg_dict_extra(pkg,'Geospatial Coverage') %} - - - - - - {% endif %} {% if pkg.get('granularity') %} @@ -81,43 +74,19 @@ {% endif %} - {% if h.get_pkg_dict_extra(pkg,'Granularity') %} - - - - - - {% endif %} {% if pkg.get('jurisdiction') %} - {% endif %} - {% if h.get_pkg_dict_extra(pkg,'AGLSTERMS.Jurisdiction') %} - - - - - - {% endif %} {% if pkg.get('temporal_coverage') %} - {% endif %} - {% if h.get_pkg_dict_extra(pkg,'Temporal Coverage') %} - - - - - - {% endif %} {% if pkg.get('data_state') %} - @@ -128,12 +97,6 @@ - - {% endif %} - {% if h.get_pkg_dict_extra(pkg,'Update Frequency') %} - - - {% endif %} --- a/ckanext/datagovau/templates/package/read.rdf +++ b/ckanext/datagovau/templates/package/read.rdf @@ -88,40 +88,21 @@ - ${h.get_pkg_dict_extra(c.pkg_dict,'DCTERMS.Source.URI') } - - + ${c.pkg_dict.get('url')}${c.pkg_dict.contact_point }${ c.pkg_dict.spatial_coverage } - ${ h.get_pkg_dict_extra(c.pkg_dict,'Geospatial Coverage') }${ c.pkg_dict.jurisdiction } - ${ h.get_pkg_dict_extra(c.pkg_dict,'AGLSTERMS.Jurisdiction') }${ c.pkg_dict.get('temporal_coverage') } - ${ h.get_pkg_dict_extra(c.pkg_dict,'Temporal Coverage') } Data State ${ c.pkg_dict.get('data_state') } - Update Frequency ${ c.pkg_dict.get('update_freq') } - - - - - Update Frequency - ${ h.get_pkg_dict_extra(c.pkg_dict,'Update Frequency') } - - - - - - Agency Program - ${ h.get_pkg_dict_extra(c.pkg_dict,'Agency Program') } @@ -130,20 +111,12 @@ ${ c.pkg_dict.get('agency_program') } - - - - Data Granularity - ${ h.get_pkg_dict_extra(c.pkg_dict,'Granularity') } - - Data Granularity ${ c.pkg_dict.get('granularity') } - --- a/ckanext/datagovau/templates/package/read_base.html +++ b/ckanext/datagovau/templates/package/read_base.html @@ -14,11 +14,11 @@ -{% if h.get_pkg_dict_extra(pkg,'DCTERMS.Source.URI') %}{% endif %} + - - - + + + @@ -30,7 +30,7 @@ {% block package_info %}
-

{{ pkg.title or pkg.name }}

+

{{ pkg.title or pkg.name }}

{{ _('Followers') }}
--- a/ckanext/datagovau/templates/package/resource_read.html +++ b/ckanext/datagovau/templates/package/resource_read.html @@ -14,11 +14,11 @@ -{% if h.get_pkg_dict_extra(pkg,'DCTERMS.Source.URI') %}{% endif %} +{% endif %} - - - + + + @@ -26,7 +26,6 @@ - --- a/ckanext/datagovau/templates/package/snippets/package_basic_fields.html +++ b/ckanext/datagovau/templates/package/snippets/package_basic_fields.html @@ -3,6 +3,7 @@ {% block package_basic_fields_org %} {{ super() }} + {{ form.input('agency_program', label=_('Agency Program'), id='field-agency_program', placeholder=_('Name of the Agency Program that generated the data if relevant'), --- a/ckanext/datagovau/templates/package/snippets/package_metadata_fields.html +++ b/ckanext/datagovau/templates/package/snippets/package_metadata_fields.html @@ -10,8 +10,9 @@ {# https://github.com/okfn/ckan/blob/master/ckan/templates/macros/form.html documents the macros for fields #} {% block package_metadata_fields %} - - +{{ form.input('url', label=_('Source URL'), id='field-url', +placeholder=_('URL where dataset came from or more information can be obtained'), +value=data.url, error=errors.url, classes=['control-medium']) }} {{ super() }} {% endblock %} --- /dev/null +++ b/ckanext/datagovau/templates/package/snippets/resource_item.html @@ -1,1 +1,54 @@ +{% ckan_extends %} +{% set url = h.url_for(controller='package', action='resource_read', id=pkg.name, resource_id=res.id) %} +
  • + {% block resource_item_title %} + + {{ h.resource_display_name(res) | truncate(50) }}{{ res.format }} + {{ h.popular('views', res.tracking_summary.total, min=10) }} + + {% endblock %} +

    + {% if res.description %} + {{ h.markdown_extract(res.description, extract_length=80) }} + {% else %} + {{ _('No description for this resource') }} + {% endif %} +

    + {% block resource_item_explore %} + + {% endblock %} +
  • --- /dev/null +++ b/ckanext/datagovau/templates/user/dashboard_datasets.html @@ -1,1 +1,16 @@ +{% ckan_extends %} +{% block primary_content_inner %} +

    {{ _('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 %} + + --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ entry_points=\ """ [ckan.plugins] - datagovau=ckanext.datagovau.plugin:ExampleIDatasetFormPlugin + datagovau=ckanext.datagovau.plugin:DataGovAuPlugin """, )
    {{ pkg.agency_program }}
    Agency Program {{ pkg.get('Agency Program') }}
    {{ _('Source') }}{{ h.link_to(h.get_pkg_dict_extra(pkg,'DCTERMS.Source.URI'), - h.get_pkg_dict_extra(pkg,'DCTERMS.Source.URI'), rel='dct:source', target='_blank') }} + {{ h.link_to(pkg.get('url'), + pkg.get('url'), rel='dct:source', target='_blank') }}
    {{ pkg.spatial_coverage }}
    Geospatial Coverage {{ h.get_pkg_dict_extra(pkg,'Geospatial Coverage') }}
    {{ pkg.granularity }}
    Data Granularity {{ h.get_pkg_dict_extra(pkg,'Granularity') }}
    Government Jurisdiction {{ pkg.jurisdiction }}
    Government Jurisdiction {{ h.get_pkg_dict_extra(pkg,'AGLSTERMS.Jurisdiction') }}
    Temporal Coverage {{ pkg.temporal_coverage }}
    Temporal Coverage {{ h.get_pkg_dict_extra(pkg,'Temporal Coverage') }}
    Data State {{ pkg.data_state }}
    Update Frequency {{ pkg.update_freq }}
    Update Frequency {{ h.get_pkg_dict_extra(pkg,'Update Frequency') }}