Commit 40684257 authored by Marko Kuder's avatar Marko Kuder
Browse files

Merge branch 'fix/gui' into 'feature/downloadall'

Some GUI fixes

See merge request !17
parents 2c6fc913 7d8d67bc
......@@ -2,6 +2,7 @@
import logging
from ckan.lib.cli import CkanCommand
from ckan.model.meta import metadata, mapper, Session
class Migrate(CkanCommand):
"""
......@@ -20,7 +21,22 @@ class Migrate(CkanCommand):
self._load_config()
log = logging.getLogger(__name__)
self.migrate_v2_10()
self.migrate_v2_20()
def migrate_v2_10(self):
from ckanext.dgu.model.package_likes import migrate_v2_10 as migrate_likes
migrate_likes()
\ No newline at end of file
migrate_likes()
def migrate_v2_20(self):
log = logging.getLogger(__name__)
#create additional index to aid optimized revision retrieval which is slower when ordering by revision_timestamp
log.info('Migrating v2.20 - adding index for package_extra with better column ordering')
conn = Session.connection()
statements = '''
CREATE INDEX idx_package_extra_package_period on package_extra_revision(package_id, revision_timestamp, expired_timestamp);
'''
conn.execute(statements)
Session.commit()
log.info('Migrated to v2.20')
\ No newline at end of file
......@@ -112,85 +112,45 @@
{% set publisher_name = c.pkg.get_organization().name %}
{% set issue_count = h.get_issue_count(c.pkg.id) %}
{#<!--
{% if not h.is_unpublished_item(c.pkg_dict) %}
<h2>Arhiv podatkov</h2>
{% if h.packagezip_has_data(c.pkg) == None %}
<p style="margin-bottom: 20px;">
<!-- Data Package Zip še ni bil ustvarjen za to podatkovno zbirko. -->
Arhiv ZIP s podatki te zbirke še ni bil ustvarjen.
<a class="js-tooltip" data-toggle="tooltip" data-html='true' data-placement="right" title="Razlog za to je verjetno relativna novost te podatkovne zbirke. Poizkusite ponovno kasneje." href="javascript:0" style="text-decoration:none;color:#000;">
<i class="fi-info-sign"></i>
</a>
</p>
{% elif not h.packagezip_has_data(c.pkg) %}
<p style="margin-bottom: 20px;">
<a href="{{h.packagezip_url(c.pkg)}}">Arhiv ZIP</a> ni priporočen za to podatkovno zbirko
<a class="js-tooltip" data-toggle="tooltip" data-html='true' data-placement="right" title="Zip datoteka morda ne vsebuje podatkov. To se zgodi v kolikor izvorni podatki niso na voljo, če je prišlo do napak med arhiviranjem, ali če so podatki na voljo le preko API-ja." href="javascript:0" style="text-decoration:none;color:#000;">
<i class="fi-info-sign"></i>
</a>
</p>
{% else %}
<p>Prenesite paket vseh datotek te podatkovne zbirke</p>
<div class="datapackage-zip">
<div class="row">
<div class="col-sm-6">
<div class="dataset-resource">
<div class="dataset-resource-format">
<i class="fi-25x icon-archive"></i>
<span class="format-name">ZIP</span>
</div>
<div class="dataset-resource-text">
<div class="inner">
<div class="inner-row description">
<div class="inner-cell">
Vsi podatki
</div>
</div>
<div class="inner-row actions">
<div class="inner-cell">
<a href="{{h.packagezip_url(c.pkg)}}" class="dataset-resource-chevron" style="pointer-events:auto;">
<strong>
Prenos ZIP
</strong>
{% if h.packagezip_size(c.pkg) %}
({{h.packagezip_size(c.pkg)|filesizeformat}})
{% endif %}
</a>
</div>
</div>
</div>
</div>
</div><!-- /dataset-resource -->
</div><!-- /col-sm-6 -->
</div>
</div>
{% endif %}
{% endif %}
-->#}
<div class="dataset-resources">
<!-- Resources -->
{% if h.individual_resources(not can_update) %}
<h2>Podatkovni viri ({{h.individual_resources(not can_update)|length}})</h2>
{{resource_table(h.individual_resources(not can_update), publisher_name)}}
{% endif %}
{% if h.timeseries_resources(not can_update) %}
<h2>Podatkovni viri ({{h.timeseries_resources(not can_update)|length}} v periodični vrsti)</h2>
{% for year, items in h.groupby(h.timeseries_resources(not can_update)|reverse, h.extract_year) %}
<div class="year">
<h3>{{year}} <span class="showyear" style="display: none;">Več podrobnosti <i class="fi-arrow-down"></i></span><span class="hideyear" style="display: none;"> Manj podrobnosti <i class="fi-arrow-up"></i></span></h3>
<div class="year_items">
{{resource_table(items, publisher_name)}}
</div>
</div>
{% endfor %}
{% endif %}
<div class="dataset-resources">
<!-- Resources -->
{% if h.individual_resources(not can_update) %}
<div class="row">
<div class="small-12 medium-8 columns">
<h2>Podatkovni viri ({{ h.individual_resources(not can_update)|length }})</h2>
</div>
{{ download_all() }}
</div>
{{ resource_table(h.individual_resources(not can_update), publisher_name) }}
{% endif %}
{% if h.timeseries_resources(not can_update) %}
<div class="row">
<div class="small-12 medium-8 columns">
<h2>Podatkovni viri ({{ h.timeseries_resources(not can_update)|length }} v periodični vrsti)</h2>
</div>
{{ download_all() }}
</div>
{% for year, items in h.groupby(h.timeseries_resources(not can_update)|reverse, h.extract_year) %}
<div class="year">
<h3>{{ year }} <span class="showyear" style="display: none;">Več podrobnosti <i
class="fi-arrow-down"></i></span><span class="hideyear" style="display: none;"> Manj podrobnosti <i
class="fi-arrow-up"></i></span></h3>
<div class="year_items">
{{ resource_table(items, publisher_name) }}
</div>
</div>
{% endfor %}
{% endif %}
</div>
<div class="dataset-resources-additional">
{% if h.additional_resources(not can_update) or h.gemini_resources() or h.csv_resources()%}
<h2>Dodatne povezave ({{h.additional_resources(not can_update)|length + h.gemini_resources()|length + h.csv_resources()|length}})</h2>
<div class="row">
<div class="small-12 medium-8 columns">
<h2>Dodatne povezave ({{h.additional_resources(not can_update)|length + h.gemini_resources()|length + h.csv_resources()|length}})</h2>
</div>
</div>
{{resource_table(h.additional_resources(not can_update) + h.gemini_resources() + h.csv_resources(), publisher_name)}}
{% endif %}
......@@ -199,41 +159,49 @@
{% endif %}
</div>
<div class="dataset-additional-information" >
<!-- Dataset Information Section -->
<h2>Dodatne informacije</h2>
<table class="table table-bordered table-condensed table-dgu-fixed-size dgu-table">
<tbody>
<div class="dataset-additional-information">
<!-- Dataset Information Section -->
<div class="row">
<div class="small-12 columns">
<h2>Dodatne informacije</h2>
</div>
</div>
<div class="row">
<div class="small-12 columns">
<table class="table table-bordered table-condensed table-dgu-fixed-size dgu-table">
<tbody>
{% for field_dict, label_attributes, value_attributes in h.get_package_fields(c.pkg, c.pkg_dict, h.as_dict(c.pkg_extras), h.was_dataset_harvested(c.pkg_extras), is_location_data, dataset_is_from_ns_pubhub) %}
<tr>
{# TODO: label_attributes and value_attributes are dicts, we need to decouple them #}
<th class="key" {{m.dict_to_attributes(label_attributes)}}>{{field_dict.get('label') or field_dict['name']}}</th>
<td class="value" {{m.dict_to_attributes(value_attributes)}}>{{field_dict.get('value') or 'Ni podatka'}}</td>
</tr>
<tr>
{# TODO: label_attributes and value_attributes are dicts, we need to decouple them #}
<th class="key" {{ m.dict_to_attributes(label_attributes) }}>{{ field_dict.get('label') or field_dict['name'] }}</th>
<td class="value" {{ m.dict_to_attributes(value_attributes) }}>{{ field_dict.get('value') or 'Ni podatka' }}</td>
</tr>
{% endfor %}
{% if is_location_data and h.as_dict(c.pkg_extras).get('resource-type') in ('dataset', 'series', 'service') %}
<tr>
{% set is_service=h.as_dict(c.pkg_extras).get('resource-type')=='service' %}
<th class="key">Povezane {{m.if_(is_service,'zbirke','storitve')}}</th>
<td class="value">
{% if h.coupled_pkg_tuples(c.pkg)%}
<ul>
{% for name, title in h.coupled_pkg_tuples(c.pkg) %}
<li>
<a href="/dataset/{{name}}">{{title}}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% if not h.coupled_pkg_tuples(c.pkg) %}
<span>(ni povezav)</span>
{% endif %}
</td>
</tr>
<tr>
{% set is_service=h.as_dict(c.pkg_extras).get('resource-type')=='service' %}
<th class="key">Povezane {{ m.if_(is_service,'zbirke','storitve') }}</th>
<td class="value">
{% if h.coupled_pkg_tuples(c.pkg) %}
<ul>
{% for name, title in h.coupled_pkg_tuples(c.pkg) %}
<li>
<a href="/dataset/{{ name }}">{{ title }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% if not h.coupled_pkg_tuples(c.pkg) %}
<span>(ni povezav)</span>
{% endif %}
</td>
</tr>
{% endif %}
</tbody>
</table>
</tbody>
</table>
</div>
</div>
</div>
{% if h.has_related_apps(c.pkg_dict.get('id')) %}
<h2>Povezane aplikacije</h2>
......@@ -288,23 +256,25 @@
{% endmacro %}
{% macro resource_table(resources, publisher_name) %}
{% set non_download_formats = ('HTML', 'API', 'WMS', 'WCS', 'SPARQL') %}
{% if h.is_plugin_enabled('downloadall') %}
<div class="btn-group" style="float:right; margin-top: -7px;">
{% macro download_all() %}
<div class="small-12 medium-4 columns text-right">
<div class="mr-15">
{% if h.is_plugin_enabled('downloadall') %}
{% set zip_res = h.downloadall__pop_zip_resource(c.pkg_dict) %}
{% if zip_res %}
<a class="button resource-url-analytics resource-type-{{ zip_res.resource_type }}" href="{{ zip_res.url }}">
{% else %}
<a class="button" disabled="disabled" title="{{ _('This download is not currently available') }}" href="#">
{% endif %}
<span class="icon-download"></span><strong>{{ _('Download all') }}</strong>
</a>
<a class="button w-230 resource-url-analytics resource-type-{{ zip_res.resource_type }}" href="{{ zip_res.url }}">
{% else %}
<a class="button w-230" disabled="disabled" title="{{ _('This download is not currently available') }}" href="#">
{% endif %}
<span class="icon-download"></span><strong>{{ _('Download all') }}</strong>
</a>
{% endif %}
</div>
</div>
{% endif %}
{% endmacro %}
{% macro resource_table(resources, publisher_name) %}
{% set non_download_formats = ('API', 'ASPX', 'HTML', 'SPARQL', 'WCS', 'WFS', 'WMS') %}
<div class="row">
{% for res in resources %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment