diff --git a/ckanext/harvest/controllers/view.py b/ckanext/harvest/controllers/view.py index bb8c9de..778d852 100644 --- a/ckanext/harvest/controllers/view.py +++ b/ckanext/harvest/controllers/view.py @@ -314,7 +314,7 @@ class ViewController(BaseController): c.harvest_source = source_dict c.is_last_job = is_last - return render('job/read.html') + return render('source/job/read.html') except NotFound: abort(404,_('Harvest job not found')) @@ -334,6 +334,16 @@ class ViewController(BaseController): except NotAuthorized,e: abort(401,self.not_auth_message) + def admin(self, id): + try: + context = {'model':model, 'user':c.user} + c.harvest_source = get_action('harvest_source_show')(context, {'id':id}) + return render('source/admin.html') + except NotFound: + abort(404,_('Harvest source not found')) + except NotAuthorized,e: + abort(401,self.not_auth_message) + def show_last_job(self, source): source_dict = self._get_source_for_job(source) @@ -350,7 +360,7 @@ class ViewController(BaseController): c.harvest_source = get_action('harvest_source_show')(context, {'id': source}) c.jobs = get_action('harvest_job_list')(context, {'source_id': c.harvest_source['id']}) - return render('job/list.html') + return render('source/job/list.html') except NotFound: abort(404,_('Harvest source not found')) diff --git a/ckanext/harvest/plugin.py b/ckanext/harvest/plugin.py index 5a833cf..e394c41 100644 --- a/ckanext/harvest/plugin.py +++ b/ckanext/harvest/plugin.py @@ -216,6 +216,7 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm): map.connect('harvest_object_show', '/harvest/object/:id', controller=controller, action='show_object') + map.connect('harvest_source_admin', '/' + DATASET_TYPE_NAME + '/admin/:id', controller=controller, action='admin') map.connect('harvest_source_about', '/' + DATASET_TYPE_NAME + '/about/:id', controller=controller, action='about') map.connect('harvest_job_list', '/' + DATASET_TYPE_NAME + '/{source}/job', controller=controller, action='list_jobs') diff --git a/ckanext/harvest/templates_new/source/admin.html b/ckanext/harvest/templates_new/source/admin.html new file mode 100644 index 0000000..5c3de7b --- /dev/null +++ b/ckanext/harvest/templates_new/source/admin.html @@ -0,0 +1,7 @@ +{% extends "source/admin_base.html" %} + +{% block primary_content_inner %} +
+ +
+{% endblock %} diff --git a/ckanext/harvest/templates_new/source/admin_base.html b/ckanext/harvest/templates_new/source/admin_base.html new file mode 100644 index 0000000..c161f29 --- /dev/null +++ b/ckanext/harvest/templates_new/source/admin_base.html @@ -0,0 +1,21 @@ +{% extends "source/read_base.html" %} + +{% block breadcrumb_content_root_selected %}{% endblock %} + +{% block breadcrumb_content %} + {{ super() }} +
  • {{ _('Admin') }}
  • +{% endblock %} + +{% block actions_content %} +
  • {{ h.nav_named_link(_('Refresh'), 'harvesting_job_create', id=source.id, class_='btn', icon='refresh')}}
  • +
  • {{ h.nav_named_link(_('View harvest source'), '{0}_read'.format(c.dataset_type), id=source.name, class_='btn', icon='eye-open')}}
  • +{% endblock %} + +{% block page_header %} + {% snippet 'snippets/page_header.html', items=[ + h.build_nav_icon('{0}_admin'.format(c.dataset_type), _('Dashboard'), id=source.name), + h.build_nav_icon('harvest_job_list'.format(c.dataset_type), _('Jobs'), source=source.name), + h.build_nav_icon('{0}_edit'.format(c.dataset_type), _('Edit'), id=source.name), + ] %} +{% endblock %} diff --git a/ckanext/harvest/templates_new/source/base.html b/ckanext/harvest/templates_new/source/base.html new file mode 100644 index 0000000..2e964c5 --- /dev/null +++ b/ckanext/harvest/templates_new/source/base.html @@ -0,0 +1,24 @@ +{% extends "page.html" %} + +{% set source = c.pkg_dict or c.harvest_source %} +{% set authorized_user = h.check_access('harvest_source_update', {'id':source.id }) %} + +{% block subtitle %}{{ source.title or source.name }}{% endblock %} + +{% block breadcrumb_content_root_selected %} class="active"{% endblock %} + +{# + TODO: once #354 is merged in CKAN core we can re-adjust the truncation + lengths here (as the breadcrumbs are a little different in #354) +#} +{% block breadcrumb_content %} + {% if source.organization %} +
  • {{ h.nav_named_link(_('Organizations'), 'organizations_index') }}
  • +
  • {{ h.nav_named_link(source.organization.title or source.organization.name|truncate(10), 'organization_read', id=source.organization.name) }}
  • +
  • {{ h.nav_named_link(_('Harvest Sources'), '{0}_search'.format(c.dataset_type)) }}
  • + {{ h.nav_named_link(c.harvest_source.title|truncate(10), '{0}_read'.format(c.dataset_type), id=c.harvest_source.name) }} + {% else %} +
  • {{ h.nav_named_link(_('Harvest Sources'), '{0}_search'.format(c.dataset_type)) }}
  • + {{ h.nav_named_link(c.harvest_source.title|truncate(30), '{0}_read'.format(c.dataset_type), id=c.harvest_source.name) }} + {% endif %} +{% endblock %} diff --git a/ckanext/harvest/templates_new/source/base_form_page.html b/ckanext/harvest/templates_new/source/base_form_page.html deleted file mode 100644 index 8b9fac0..0000000 --- a/ckanext/harvest/templates_new/source/base_form_page.html +++ /dev/null @@ -1,27 +0,0 @@ -{% extends "page.html" %} - -{% block primary_content %} -
    -
    - {% block form %}{{ c.form | safe }}{% endblock %} -
    -
    -{% endblock %} - -{% block secondary_content %} - {% block info_module %} -
    -

    {{ _('Harvest sources') }}

    -
    -

    - {% trans %} - Harvest sources allow importing metadata from other catalogues - as CKAN datasets. These can be other CKAN instances or other - protocols and formats. (TODO: Review) - {% endtrans %} -

    -
    -
    - {% endblock %} - -{% endblock %} diff --git a/ckanext/harvest/templates_new/source/edit.html b/ckanext/harvest/templates_new/source/edit.html index 19ca984..c5a62bc 100644 --- a/ckanext/harvest/templates_new/source/edit.html +++ b/ckanext/harvest/templates_new/source/edit.html @@ -1,15 +1,9 @@ -{% extends "source/base_form_page.html" %} - -{% block breadcrumb_content %} -
  • {{ h.nav_named_link(_('Harvest Sources'), '{0}_search'.format(c.dataset_type)) }}
  • -
  • {{ h.nav_named_link(c.harvest_source.title|truncate(30), '{0}_read'.format(c.dataset_type), id=c.harvest_source.name) }}
  • -
  • {{ h.nav_named_link(_('Edit Harvest Source'), '{0}_edit'.format(c.dataset_type), id=c.harvest_source.name) }}
  • -{% endblock %} - -{% block actions_content %} -
  • {{ h.nav_named_link(_('View harvest source'), '{0}_read'.format(c.dataset_type), id=c.harvest_source.name, class_='btn', icon='eye-open')}}
  • -{% endblock %} - - +{% extends "source/admin_base.html" %} {% block subtitle %}{{ _('Edit harvest source') }}{% endblock %} + +{% block primary_content_inner %} +
    + {% block form %}{{ c.form | safe }}{% endblock %} +
    +{% endblock %} diff --git a/ckanext/harvest/templates_new/job/list.html b/ckanext/harvest/templates_new/source/job/list.html similarity index 68% rename from ckanext/harvest/templates_new/job/list.html rename to ckanext/harvest/templates_new/source/job/list.html index f383f24..c6a9dc4 100644 --- a/ckanext/harvest/templates_new/job/list.html +++ b/ckanext/harvest/templates_new/source/job/list.html @@ -1,18 +1,10 @@ -{% extends "page.html" %} +{% extends "source/admin_base.html" %} {% block subtitle %}{{ _('Harvest Jobs')}}{% endblock %} -{% block breadcrumb_content %} -
  • {{ h.nav_named_link(_('Harvest Sources'), '{0}_search'.format(c.dataset_type)) }}
  • -
  • {{ h.nav_named_link(c.harvest_source.title|truncate(30), '{0}_read'.format(c.dataset_type), id=c.harvest_source.name) }}
  • -
  • {{ h.nav_link(_('Jobs'), controller='ckanext.harvest.controllers.view:ViewController', action='list_jobs', source=c.harvest_source.name)}}
  • -{% endblock %} - -{% block primary %} - -
    -
    -

    {{ _('Harvest Jobs') }}

    +{% block primary_content_inner %} +
    +

    {{ _('Harvest Jobs') }}

    {% if c.jobs|length == 0 %}

    {{ _('No jobs yet for this source') }}

    @@ -49,8 +41,6 @@ {% endif %} -
    - -
    + {% endblock %} diff --git a/ckanext/harvest/templates_new/job/read.html b/ckanext/harvest/templates_new/source/job/read.html similarity index 54% rename from ckanext/harvest/templates_new/job/read.html rename to ckanext/harvest/templates_new/source/job/read.html index c98b25a..31c8bbd 100644 --- a/ckanext/harvest/templates_new/job/read.html +++ b/ckanext/harvest/templates_new/source/job/read.html @@ -1,24 +1,15 @@ -{% extends "page.html" %} +{% extends "source/admin_base.html" %} {% block subtitle %}{{ _('Harvest Job Report')}}{% endblock %} -{% block breadcrumb_content %} -
  • {{ h.nav_named_link(_('Harvest Sources'), '{0}_search'.format(c.dataset_type)) }}
  • -
  • {{ h.nav_named_link(c.harvest_source.title|truncate(30), '{0}_read'.format(c.dataset_type), id=c.harvest_source.name) }}
  • -
  • {{ h.nav_link(_('Jobs'), controller='ckanext.harvest.controllers.view:ViewController', action='list_jobs', source=c.harvest_source.name)}}
  • - {% if c.is_last_job %} -
  • {{ h.nav_link(_('Last'), controller='ckanext.harvest.controllers.view:ViewController', action='show_last_job', source=c.harvest_source.name)}}
  • - {% else %} -
  • {{ h.nav_link(c.job.id|truncate(30), controller='ckanext.harvest.controllers.view:ViewController', action='show_job', id=c.job.id, source=c.harvest_source.name)}}
  • - {% endif %} +{% block primary_content_inner %} +
    -{% endblock %} +

    + {{ h.nav_named_link(_('Back to job list'), 'harvest_job_list', source=source.name, class_='btn', icon='arrow-left')}} +

    -{% block primary %} - -
    -
    -

    {{ _('Harvest Job Report') }}

    +

    {{ _('Job Report') }}

    {% snippet 'snippets/job_details.html', job=c.job %} @@ -48,11 +39,8 @@
    {% endfor %}
    - {% endfor %} - - {% endblock %} {% block styles %} diff --git a/ckanext/harvest/templates_new/source/new.html b/ckanext/harvest/templates_new/source/new.html index f174edd..183b985 100644 --- a/ckanext/harvest/templates_new/source/new.html +++ b/ckanext/harvest/templates_new/source/new.html @@ -1,9 +1,34 @@ -{% extends "source/base_form_page.html" %} +{% extends "source/admin_base.html" %} {% block breadcrumb_content %}
  • {{ h.nav_named_link(_('Harvest Sources'), '{0}_search'.format(c.dataset_type)) }}
  • {{ h.nav_named_link(_('Create Harvest Source'), '{0}_new'.format(c.dataset_type)) }}
  • {% endblock %} +{% block actions_content %} +{% endblock %} + {% block subtitle %}{{ _('Create harvest source') }}{% endblock %} +{% block primary_content %} +
    +
    + {% block form %}{{ c.form | safe }}{% endblock %} +
    +
    +{% endblock %} + +{% block secondary_content %} +
    +

    {{ _('Harvest sources') }}

    +
    +

    + {% trans %} + Harvest sources allow importing metadata from other catalogues + as CKAN datasets. These can be other CKAN instances or other + protocols and formats. (TODO: Review) + {% endtrans %} +

    +
    +
    +{% endblock %} diff --git a/ckanext/harvest/templates_new/source/read_base.html b/ckanext/harvest/templates_new/source/read_base.html index 39dd654..ac8d6b2 100644 --- a/ckanext/harvest/templates_new/source/read_base.html +++ b/ckanext/harvest/templates_new/source/read_base.html @@ -1,24 +1,14 @@ -{% extends "package/read_base.html" %} - -{% set source = c.pkg_dict or c.harvest_source %} -{% set authorized_user = h.check_access('harvest_source_update', {'id':source.id }) %} - -{% block subtitle %}{{ source.title or source.name }}{% endblock %} - -{% block breadcrumb_content %} -
  • {{ h.nav_named_link(_('Harvest Sources'), '{0}_search'.format(c.dataset_type)) }}
  • -
  • {{ h.nav_named_link(c.harvest_source.title|truncate(30), '{0}_read'.format(c.dataset_type), id=c.harvest_source.name) }}
  • -{% endblock %} +{% extends "source/base.html" %} {% block actions_content %} {% if authorized_user %}
  • {{ h.nav_named_link(_('Admin'), '{0}_admin'.format(c.dataset_type), id=c.harvest_source.name, class_='btn btn-primary', icon='wrench')}}
  • {% endif %} -
  • {{ h.follow_button('dataset', source.id) }}
  • {% endblock %} +{# TODO: once #354 is merged in CKAN core .profile-info doesn't exist #} {% block secondary_content %} -
    +

    {{ c.harvest_source.title }}

    {% if c.harvest_source.notes %} @@ -39,15 +29,14 @@
    {% endblock %} -{% block page_header %} - +{% block primary_content %} +
    + {% block page_header %} + {% snippet 'snippets/page_header.html', items=[ + h.build_nav_icon('{0}_read'.format(c.dataset_type), _('Datasets'), id=source.name), + h.build_nav_icon('{0}_about'.format(c.dataset_type), _('About'), id=source.name), + ] %} + {% endblock %} + {% block primary_content_inner %}{% endblock %} +
    {% endblock %}