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 2 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
@@ -1,22 +1,22 @@
{% 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>
<div class="ten wide column collection-header middle aligned left floated pl-0">
<div class="nine wide column collection-header middle aligned right 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">
<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">{{ 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
Loading