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

feat: add browse page #1206

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 4 additions & 0 deletions invenio_communities/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"upload": "/communities/<pid_value>/upload",
"settings": "/communities/<pid_value>/settings",
"requests": "/communities/<pid_value>/requests",
"browse": "/communities/<pid_value>/browse",
"new_subcommunity": "/communities/<pid_value>/subcommunities/new",
"settings_privileges": "/communities/<pid_value>/settings/privileges",
"settings_submission_policy": "/communities/<pid_value>/settings/submission-policy",
Expand Down Expand Up @@ -323,3 +324,6 @@

COMMUNITIES_DEFAULT_RECORD_SUBMISSION_POLICY = RecordSubmissionPolicyEnum.OPEN
"""Default value of record submission policy community access setting."""

COMMUNITIES_SHOW_BROWSE_PAGE = False
"""Whether the browse page is enabled for communities"""
7 changes: 7 additions & 0 deletions invenio_communities/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ def register_menus(app):

communities = current_menu.submenu("communities")

communities.submenu("browse").register(
endpoint="invenio_communities.communities_browse",
text=_("Browse"),
order=15,
expected_args=["pid_value"],
**{"icon": "list", "permissions": "can_read"},
)
communities.submenu("requests").register(
endpoint="invenio_communities.communities_requests",
text=_("Requests"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{# -*- coding: utf-8 -*-

This file is part of Invenio.
Copyright (C) 2024 CERN.

Invenio is free software; you can redistribute it and/or modify it
under the terms of the MIT License; see LICENSE file for more details.
#}

{% extends "invenio_communities/details/base.html" %}
{% set active_community_header_menu_item= 'browse' %}


{%- block page_body %}
{{ super() }}
<div class="ui text container rich-input-content rel-m-2 rel-pt-1">
Browse
</div>
{%- endblock page_body -%}
19 changes: 19 additions & 0 deletions invenio_communities/views/communities.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,25 @@ def communities_requests(pid_value, community, community_ui):
)


@pass_community(serialize=True)
def communities_browse(pid_value, community, community_ui):
"""Community browse page."""
permissions = community.has_permissions_to(MEMBERS_PERMISSIONS)

conf = current_app.config
if not conf.get("COMMUNITIES_SHOW_BROWSE_PAGE", False):
abort(404)

return render_community_theme_template(
"invenio_communities/details/browse/index.html",
theme=community_ui.get("theme", {}),
community=community_ui,
permissions=permissions,
roles_can_update=_get_roles_can_update(community.id),
roles_can_invite=_get_roles_can_invite(community.id),
)


@pass_community(serialize=True)
def communities_settings_privileges(pid_value, community, community_ui):
"""Community settings/privileges page."""
Expand Down
6 changes: 6 additions & 0 deletions invenio_communities/views/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from ..searchapp import search_app_context
from .communities import (
communities_about,
communities_browse,
communities_curation_policy,
communities_frontpage,
communities_new,
Expand Down Expand Up @@ -179,6 +180,11 @@ def create_ui_blueprint(app):
view_func=communities_requests,
)

blueprint.add_url_rule(
routes["browse"],
view_func=communities_browse,
)

blueprint.add_url_rule(
routes["settings_privileges"],
view_func=communities_settings_privileges,
Expand Down
Loading