From bdbf53caead548e3d798084cbca98c3c19f601aa Mon Sep 17 00:00:00 2001 From: amercader Date: Thu, 25 Oct 2018 12:19:43 +0200 Subject: [PATCH] Fix styling issues on Bootstrap 3 --- .../fanstatic_library/styles/harvest.css | 12 +++++++----- ckanext/harvest/helpers.py | 9 +++++++++ ckanext/harvest/plugin.py | 17 +++++++++-------- .../harvest/templates/snippets/job_details.html | 2 +- ckanext/harvest/templates/source/admin.html | 2 +- .../harvest/templates/source/admin_base.html | 14 ++++++++++---- ckanext/harvest/templates/source/job/list.html | 2 +- ckanext/harvest/templates/source/job/read.html | 2 +- .../templates/source/new_source_form.html | 6 +++--- 9 files changed, 42 insertions(+), 24 deletions(-) diff --git a/ckanext/harvest/fanstatic_library/styles/harvest.css b/ckanext/harvest/fanstatic_library/styles/harvest.css index 5232af3..29d7a84 100644 --- a/ckanext/harvest/fanstatic_library/styles/harvest.css +++ b/ckanext/harvest/fanstatic_library/styles/harvest.css @@ -11,6 +11,9 @@ header.with-filter h1 { text-shadow: none; font-weight: normal; } +[data-diff="error"] { + background-color: #b55457; +} [data-diff="added"] { background-color: #9ee592; } @@ -36,9 +39,8 @@ header.with-filter h1 { .harvest-types label.radio input { top: 3px; } -#source-new .controls { - margin-left: 135px; -} -#source-new .control-label { + +#source-new.bs2 .control-label { width: 125px; -} +-} + diff --git a/ckanext/harvest/helpers.py b/ckanext/harvest/helpers.py index 6cb6ff2..fab9147 100644 --- a/ckanext/harvest/helpers.py +++ b/ckanext/harvest/helpers.py @@ -110,3 +110,12 @@ def harvest_source_extra_fields(): fields[harvester.info()['name']] = harvester.extra_schema().keys() return fields + +def bootstrap_version(): + if p.toolkit.check_ckan_version(max_version='2.7.99'): + return 'bs2' + else: + return ( + 'bs2' if + p.toolkit.config.get('ckan.base_public_folder') == 'public-bs2' + else 'bs3') diff --git a/ckanext/harvest/plugin.py b/ckanext/harvest/plugin.py index 55ab3dd..a197144 100644 --- a/ckanext/harvest/plugin.py +++ b/ckanext/harvest/plugin.py @@ -218,7 +218,7 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm, DefaultTranslation): # Setup harvest model model_setup() - + # Configure database logger _configure_db_logger(config) @@ -293,6 +293,7 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm, DefaultTranslation): 'harvest_frequencies': harvest_helpers.harvest_frequencies, 'link_for_harvest_object': harvest_helpers.link_for_harvest_object, 'harvest_source_extra_fields': harvest_helpers.harvest_source_extra_fields, + 'bootstrap_version': harvest_helpers.bootstrap_version, } def dataset_facets(self, facets_dict, package_type): @@ -472,7 +473,7 @@ def _delete_harvest_source_object(context, data_dict): def _configure_db_logger(config): # Log scope - # + # # -1 - do not log to the database # 0 - log everything # 1 - model, logic.action, logic.validators, harvesters @@ -486,16 +487,16 @@ def _configure_db_logger(config): scope = p.toolkit.asint(config.get('ckan.harvest.log_scope', -1)) if scope == -1: return - + parent_logger = 'ckanext.harvest' - children = ['plugin', 'model', 'logic.action.create', 'logic.action.delete', - 'logic.action.get', 'logic.action.patch', 'logic.action.update', + children = ['plugin', 'model', 'logic.action.create', 'logic.action.delete', + 'logic.action.get', 'logic.action.patch', 'logic.action.update', 'logic.validators', 'harvesters.base', 'harvesters.ckanharvester'] - + children_ = {0: children, 1: children[1:], 2: children[1:-2], 3: children[1:-3], 4: children[2:-3], 5: children[1:2], 6: children[:1], 7: children[-2:]} - + # Get log level from config param - default: DEBUG from logging import DEBUG, INFO, WARNING, ERROR, CRITICAL level = config.get('ckan.harvest.log_level', 'debug').upper() @@ -513,7 +514,7 @@ def _configure_db_logger(config): level = DEBUG loggers = children_.get(scope) - + # Get root logger and set db handler logger = getLogger(parent_logger) if scope < 1: diff --git a/ckanext/harvest/templates/snippets/job_details.html b/ckanext/harvest/templates/snippets/job_details.html index a2bf26b..123a4ec 100644 --- a/ckanext/harvest/templates/snippets/job_details.html +++ b/ckanext/harvest/templates/snippets/job_details.html @@ -17,7 +17,7 @@ Example: {% if job.status == 'Finished' %}

- + {% if 'errored' in stats and stats['errored'] > 0 %} {{ stats['errored'] }} {% else %} diff --git a/ckanext/harvest/templates/source/admin.html b/ckanext/harvest/templates/source/admin.html index 95fb681..337b923 100644 --- a/ckanext/harvest/templates/source/admin.html +++ b/ckanext/harvest/templates/source/admin.html @@ -6,7 +6,7 @@ {% if source.status and source.status.last_job %} {% snippet "snippets/job_details.html", job=source.status.last_job %}

- + {{ _('View full job report') }} diff --git a/ckanext/harvest/templates/source/admin_base.html b/ckanext/harvest/templates/source/admin_base.html index 95860a1..7334281 100644 --- a/ckanext/harvest/templates/source/admin_base.html +++ b/ckanext/harvest/templates/source/admin_base.html @@ -14,7 +14,7 @@ {% else %} {% set locale = h.dump_json({'content': _('This will re-run the harvesting for this source. Any updates at the source will overwrite the local datasets. Sources with a large number of datasets may take a significant amount of time to finish harvesting. Please confirm you would like us to start reharvesting.')}) %} {{ '
  • ' if show_li }} - {{ _('Reharvest') }} @@ -23,7 +23,7 @@ {% endif %} {% if source.status and source.status.last_job and (source.status.last_job.status == 'Running') %} {{ '
  • ' if show_li }} - + {{ _('Stop') }} @@ -31,13 +31,19 @@ {% endif %} {% set locale = h.dump_json({'content': _('Warning: This will remove all datasets for this source, as well as all previous job reports. Are you sure you want to continue?')}) %} {{ '
  • ' if show_li }} - {{ _('Clear') }} {{ '
  • ' if show_li }} - {{ '
  • ' if show_li }}{{ h.nav_link(_('View harvest source'), named_route='{0}_read'.format(c.dataset_type), id=source.name, class_='btn', icon='eye-open')}}{{ '
  • ' if show_li }} + {{ '
  • ' if show_li }} + + + {{ _('View harvest source') }} + + + {{ '
  • ' if show_li }} {% endblock %} {# CKAN 2.0 #} diff --git a/ckanext/harvest/templates/source/job/list.html b/ckanext/harvest/templates/source/job/list.html index aefd494..89764ef 100644 --- a/ckanext/harvest/templates/source/job/list.html +++ b/ckanext/harvest/templates/source/job/list.html @@ -40,7 +40,7 @@