Skip to content

Commit

Permalink
Add Featured Group on homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
blagojabozinovski committed Mar 5, 2024
1 parent d568687 commit 60bb477
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
17 changes: 16 additions & 1 deletion ckanext/iaea/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
from ckan.lib.plugins import DefaultTranslation
from ckanext.iaea.helpers import get_helpers
from ckanext.iaea.logic import action, validators
import ckan.logic as logic
import ckan.model as model


def featured_group():
try:
group_list = logic.get_action('group_list')(
{}, {'sort': 'package_count', 'all_fields': True})
if group_list:
return group_list
else:
return logic.get_action('group_list')(
{}, {'all_fields': True})
except (logic.NotFound, logic.ValidationError, logic.NotAuthorized):
return {}


class IaeaPlugin(plugins.SingletonPlugin, DefaultTranslation):
Expand All @@ -22,7 +37,7 @@ def update_config(self, config_):

def get_helpers(self):
iaea_helpers = {
# 'featured_group': featured_group,
'featured_group': featured_group,
# 'package_activity_html': package_activity_html,
# 'suggested_filter_fields_serializer': suggested_filter_fields_serializer,
# 'featured_view_url': featured_view_url,
Expand Down
11 changes: 9 additions & 2 deletions ckanext/iaea/templates/home/layout1.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,20 @@ <h1 class="title">{{ _("IAEA Data Platform") }}</h1>
<div class="title">
<h1> Topics</h1>
</div>
<a href="{{ url }}"/>
{% for group in h.featured_group() %}
{% set type = group.type or 'group' %}
{% set url = h.url_for(type ~ '_read', action = 'read', id = group.name) %}
<a href="{{ url }}" title="{{ _('View {name}').format(name=group.display_name) }}" />
<div class="col-xs-3 col-md-3">
<div class="group-feature-item">
<img class="media-image img-responsive">
<img src="{{ group.image_display_url or h.url_for_static('/base/images/placeholder-group.png') }}"
alt="{{ group.name }}" class="media-image img-responsive">
<h3>{{group.title or group.display_name}}</h3>
<p>{{ h.markdown_extract(group.description)|urlize |truncate(135) }}</p>
</div>
</div>
</a>
{% endfor%}
{% endblock %}
</div>
</div>
Expand Down

0 comments on commit 60bb477

Please sign in to comment.