From d77bf255b452fb06aeb553d2c6164806a4158471 Mon Sep 17 00:00:00 2001 From: amercader Date: Fri, 30 Nov 2012 18:53:13 +0000 Subject: [PATCH] Finish up create and edit forms, including breadcrumbs, links, etc --- ckanext/harvest/plugin.py | 10 +++++++ .../templates_new/source/base_form_page.html | 27 +++++++++++++++++++ .../harvest/templates_new/source/edit.html | 26 +++++++----------- ckanext/harvest/templates_new/source/new.html | 26 ++++-------------- .../templates_new/source/new_source_form.html | 2 +- 5 files changed, 52 insertions(+), 39 deletions(-) create mode 100644 ckanext/harvest/templates_new/source/base_form_page.html diff --git a/ckanext/harvest/plugin.py b/ckanext/harvest/plugin.py index e4a695f..5cdf8d2 100644 --- a/ckanext/harvest/plugin.py +++ b/ckanext/harvest/plugin.py @@ -52,9 +52,17 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm): def package_form(self): return 'source/new_source_form.html' + def new_template(self): + return 'source/new.html' + + def edit_template(self): + return 'source/edit.html' + def setup_template_variables(self, context, data_dict): harvesters_info = logic.get_action('harvesters_info_show')(context,{}) + p.toolkit.c.harvest_source = p.toolkit.c.pkg + p.toolkit.c.frequencies = [ {'text': p.toolkit._(f.title()), 'value': f} for f in UPDATE_FREQUENCIES @@ -65,6 +73,8 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm): ] p.toolkit.c.harvesters_info = harvesters_info + p.toolkit.c.dataset_type = DATASET_TYPE_NAME + def form_to_db_schema_options(self, options): ''' Similar to form_to_db_schema but with further options to allow diff --git a/ckanext/harvest/templates_new/source/base_form_page.html b/ckanext/harvest/templates_new/source/base_form_page.html new file mode 100644 index 0000000..8b9fac0 --- /dev/null +++ b/ckanext/harvest/templates_new/source/base_form_page.html @@ -0,0 +1,27 @@ +{% 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 39d718e..c1d4252 100644 --- a/ckanext/harvest/templates_new/source/edit.html +++ b/ckanext/harvest/templates_new/source/edit.html @@ -1,24 +1,16 @@ -{% extends "page.html" %} - -{% block title %}{{ _('Edit - Harvest Source') }} - {{ super() }}{% endblock %} +{% extends "source/base_form_page.html" %} {% block breadcrumb_content %} + +
  • {% link_for _('Harvest Sources'), controller='package', action='search', highlight_actions = 'new index' %}
  • +
  • {{ 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 styles %} - {{ super() }} - +{% 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 %} -{% block primary %} -
    -
    -
    -

    Edit harvest source

    - {{ h.literal(c.form) }} -
    -
    -
    -{% endblock %} + -{% block sidebar %}{% endblock %} +{% block subtitle %}{{ _('Edit harvest source') }}{% endblock %} diff --git a/ckanext/harvest/templates_new/source/new.html b/ckanext/harvest/templates_new/source/new.html index ee815b1..5914248 100644 --- a/ckanext/harvest/templates_new/source/new.html +++ b/ckanext/harvest/templates_new/source/new.html @@ -1,26 +1,10 @@ -{% extends "page.html" %} - -{% block title %}{{ _('New - Harvest Source') }} - {{ super() }}{% endblock %} +{% extends "source/base_form_page.html" %} {% block breadcrumb_content %} + +
  • {% link_for _('Harvest Sources'), controller='package', action='search', highlight_actions = 'new index' %}
  • +
  • {{ h.nav_named_link(_('Create Harvest Source'), '{0}_new'.format(c.dataset_type)) }}
  • {% endblock %} -{% block styles %} - {{ super() }} - -{% endblock %} +{% block subtitle %}{{ _('Create harvest source') }}{% endblock %} -{% block primary %} -
    -
    -
    -

    New harvest source

    - - {{ h.literal(c.form) }} - -
    -
    -
    -{% endblock %} - -{% block sidebar %}{% endblock %} diff --git a/ckanext/harvest/templates_new/source/new_source_form.html b/ckanext/harvest/templates_new/source/new_source_form.html index 7ba1260..df6124e 100644 --- a/ckanext/harvest/templates_new/source/new_source_form.html +++ b/ckanext/harvest/templates_new/source/new_source_form.html @@ -34,6 +34,6 @@
    TODO: state / delete
    - or Return to the harvest sources list +