Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: passing collections to communities_home #2882

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h1 class="ui medium header">
{%- endif -%}
</div>
</div>
<div class="ui divider mt-0 mb-0" aria-hidden="true"></div>
<div class="ui divider mt-10 mb-0" aria-hidden="true"></div>
<!-- Collection record search -->
<div id="collection-search"
data-invenio-search-config='{{search_app_collection_config(app_id="InvenioAppRDM.CollectionsSearch", endpoint=root_collection["links"]["search"], hidden_params=[["collection_id", root_collection["id"]]]) | tojson }}'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{% 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">
<img src="{{ logo_url }}" width="45" height="auto" alt=""
onerror="null;"/>
<div class="twelve wide column middle aligned left floated">
<div class="flex align-items-center">
<img class="computer only rel-mr-1" src="{{ logo_url }}" width="45" height="auto" alt=""
onerror="null;"/>
<h4 class="theme-primary-text mt-0">
<a
href='{{ url_for("invenio_app_rdm_communities.community_collection", pid_value=community.slug, collection_slug=root_collection.slug, tree_slug=tree.slug )}}'>
{{ root_collection.title }}
</a>
</h4>
</div>
</div>
<div class="ten wide column collection-header middle aligned left floated pl-0">
<h4 class="theme-primary-text">
<a
href='{{ url_for("invenio_app_rdm_communities.community_collection", pid_value=community.slug, collection_slug=root_collection.slug, tree_slug=tree.slug )}}'>
{{ root_collection.title }}
</a>
</h4>
</div>
<div class="two wide column collection-number middle aligned">
<label class="ui small label middle aligned">{{ root_collection.num_records }}</label>
<div class="four wide column collection-number middle aligned left floated">
ptamarit marked this conversation as resolved.
Show resolved Hide resolved
<label class="ui small label middle aligned">{{ "{:,}".format(root_collection.num_records) }}</label>
</div>
</div>

Expand All @@ -33,7 +33,7 @@ <h5 class="theme-primary-text">
collection_slug=child_collection.slug, tree_slug=tree.slug )}}'>
{{ child_collection.title }}
</a>
<label class="ui tiny text-muted">{{ "(" ~ child_collection.num_records ~ ")"}}</label>
<label class="ui tiny text-muted">{{ "(" ~ "{:,}".format(child_collection.num_records) ~ ")"}}</label>
</h5>
</div>
{%- endfor -%}
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
Loading