Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
Adding helper functions / extended fjelltopp-theme layout
Browse files Browse the repository at this point in the history
  • Loading branch information
toavina committed Jul 23, 2024
1 parent a1630da commit 1945725
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ckanext/zarr/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import ckan.model as model
from ckan.common import c, request, is_flask_request, g
from datetime import datetime, timedelta
from ckan.plugins import toolkit


def get_user_obj(field=""):
Expand Down Expand Up @@ -127,3 +128,9 @@ def lower_formatter(input):

def month_formatter(month):
return datetime.strptime(month, "%Y-%m").strftime("%b %Y")


def get_recently_updated_datasets():
recently_updated = toolkit.get_action('package_search')(
data_dict={'q': '*:*', 'sort': 'metadata_modified desc', 'rows': 3})['results']
return recently_updated[:3]
1 change: 1 addition & 0 deletions ckanext/zarr/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def get_helpers(self):
'get_user_from_id': zarr_helpers.get_user_from_id,
'get_user_obj': zarr_helpers.get_user_obj,
'month_formatter': zarr_helpers.month_formatter,
'get_recently_updated_datasets': zarr_helpers.get_recently_updated_datasets,
}

# IConfigurer
Expand Down
18 changes: 18 additions & 0 deletions ckanext/zarr/templates/home/layout1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% ckan_extends %}

{% block featured %}
<div class="recently-updated">
<div class="container">
<div class="recently-updated-title">
<h3>{{ _('Featured Datasets') }}</h3>
<a class="view-all-btn" href="{{ url_for('dataset.search', tags='Featured') }}">{{ _('See all') }}</a>
</div>
{% snippet 'home/snippets/recently_updated.html', packages=h.get_featured_datasets(), origin='homepage' %}
<div class="recently-updated-title">
<h3>{{ _('Recently Updated Datasets') }}</h3>
<a class="view-all-btn" href="{{ h.url_for('/dataset') }}">{{ _('See all') }}</a>
</div>
{% snippet 'home/snippets/recently_updated.html', packages=h.get_recently_updated_datasets(), origin='homepage' %}
</div>
</div>
{% endblock %}

0 comments on commit 1945725

Please sign in to comment.