Skip to content

Commit

Permalink
Merge branch 'master' into LIKA-590_fix_xroad_graphs_view
Browse files Browse the repository at this point in the history
  • Loading branch information
Zharktas committed Feb 15, 2024
2 parents 8987a9d + bea990e commit 915870d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ this.ckan.module('datepicker', function (jQuery, _) {

_onReady: function() {
var editor = $(this.el).datetimepicker();

if($(this.el.attr('autosubmit'))) {
editor.on('dp.change', () => {
editor.parents('form:first').submit()
});
}
}
}
});
13 changes: 11 additions & 2 deletions ckanext/ckanext-apicatalog/ckanext/apicatalog/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,17 @@ def get_orgs_with_visible_packages(ids):


def get_homepage_datasets(count=1):
datasets = get_action('package_search')({}, {'q': 'type:dataset', 'rows': count}).get('results', [])
return datasets
context = {}
datasets = package_generator(context=context,
query='res_name:*',
page_size=count*5,
sort='metadata_created desc',
dataset_type='dataset')

def criteria(dataset):
return dataset.get('notes') and len(dataset.get('resources', [])) > 0

return list(itertools.islice(filter(criteria, datasets), count))


NEWS_CACHE = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@
"form_snippet": false,
"display_snippet": null
},
{
"field_name": "rest_endpoints",
"label": "Rest endpoints",
"form_snippet": false,
"display_snippet": null
},
{
"field_name": "url_type",
"form_snippet": "hidden.html",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
{% set note = _('This content is not available in English. If you have any questions about this topic, please contact our customer service at <a href="mailto:[email protected]">[email protected]</a>.') %}
{% set news_lang = 'fi' %}
{% endif %}
{% snippet 'home/snippets/news.html', news=h.get_homepage_news(count=5, language=news_lang), language=news_lang, note=note %}
{% snippet 'home/snippets/news.html', news=h.get_homepage_news(count=3, language=news_lang), language=news_lang, note=note %}
{% endblock %}
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions ckanext/ckanext-apicatalog/ckanext/apicatalog/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
ResourceDict = Dict[str, Any]


def package_generator(context, query='*:*', page_size=1000, dataset_type='dataset'):
def package_generator(context, query='*:*', page_size=1000,
sort='score desc, metadata_modified desc', dataset_type='dataset'):
package_search = toolkit.get_action('package_search')

# Loop through all items. Each page has {page_size} items.
# Stop iteration when all items have been looped.
for index in itertools.count(start=0, step=page_size):
data_dict = {'include_private': True, 'rows': page_size, 'q': query, 'start': index,
'fq': '+dataset_type:' + dataset_type}
'fq': '+dataset_type:' + dataset_type, 'sort': sort}
data = package_search(context, data_dict)
packages = data.get('results', [])
for package in packages:
Expand Down

0 comments on commit 915870d

Please sign in to comment.