Skip to content

Commit

Permalink
ui: passing collections to communities_home
Browse files Browse the repository at this point in the history
  • Loading branch information
0einstein0 committed Oct 16, 2024
1 parent 88ec8b1 commit 6ea2606
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{% macro render_depth_one_collection(community, tree, collection) %}
{% set root_collection=collection[collection.root] %}
<div class="ui card borderless facet mt-0 mb-0 rel-ml-1">
<div class="ui mt-0 mb-0 rel-ml-1">
<div class="content rel-mb-1">
{% set logo_url = url_for("static", filename="images/collections/" ~ root_collection.slug ~ ".jpg") %}
<div class="ui grid">
<div class="four wide column collection-logo mr-0 computer only">
<div class="three wide column collection-logo mr-0 computer only">
<img src="{{ logo_url }}" width="45" height="auto" alt=""
onerror="null;"/>
</div>
Expand All @@ -16,7 +16,7 @@ <h4 class="theme-primary-text">
</a>
</h4>
</div>
<div class="two wide column collection-number middle aligned">
<div class="three wide column collection-number middle aligned">
<label class="ui small label middle aligned">{{ root_collection.num_records }}</label>
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion invenio_app_rdm/communities_ui/views/communities.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def communities_detail(pid_value, community, community_ui):
def communities_home(pid_value, community, community_ui):
"""Community home page."""
query_params = request.args

collections_service = current_rdm_records.collections_service
permissions = community.has_permissions_to(HEADER_PERMISSIONS)
if not permissions["can_read"]:
raise PermissionDeniedError()
Expand Down Expand Up @@ -94,6 +94,8 @@ def communities_home(pid_value, community, community_ui):
expand=True,
)

collections = collections_service.list_trees(g.identity, community.id, depth=0)

# TODO resultitem does not expose aggregations except labelled facets
_metric_aggs = recent_uploads._results.aggregations
metrics = {
Expand All @@ -113,6 +115,7 @@ def communities_home(pid_value, community, community_ui):
permissions=permissions,
records=records_ui,
metrics=metrics,
collections=collections.to_dict(),
)


Expand Down

0 comments on commit 6ea2606

Please sign in to comment.