Skip to content

Commit

Permalink
views: move homepage view out of the module
Browse files Browse the repository at this point in the history
* moved to invenio_app_rdm/communities_ui
  • Loading branch information
kpsherva committed Feb 9, 2024
1 parent 72c2e91 commit e7bb9d9
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 188 deletions.
1 change: 0 additions & 1 deletion invenio_communities/communities/records/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class Community(Record):
custom_fields = DictField(clear_none=True, create_if_missing=True)
theme = DictField(clear_none=True)

theme = DictField(clear_none=True)

bucket_id = ModelField(dump=False)
bucket = ModelField(dump=False)
Expand Down
2 changes: 0 additions & 2 deletions invenio_communities/communities/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ class CommunityThemeSchema(Schema):
style = fields.Nested(CommunityThemeStyleSchema)
brand = fields.Str()
enabled = fields.Boolean()
heading = fields.Str()
subheading = fields.Str()


class BaseCommunitySchema(BaseRecordSchema, FieldPermissionsMixin):
Expand Down
3 changes: 1 addition & 2 deletions invenio_communities/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"frontpage": "/communities",
"search": "/communities/search",
"new": "/communities/new",
"details": "/communities/<pid_value>/records",
"details": "/communities/<pid_value>",
"upload": "/communities/<pid_value>/upload",
"settings": "/communities/<pid_value>/settings",
"requests": "/communities/<pid_value>/requests",
Expand All @@ -30,7 +30,6 @@
"members": "/communities/<pid_value>/members",
"invitations": "/communities/<pid_value>/invitations",
"about": "/communities/<pid_value>/about",
"home": "/communities/<pid_value>/",
"curation_policy": "/communities/<pid_value>/curation-policy",
}

Expand Down

This file was deleted.

This file was deleted.

37 changes: 0 additions & 37 deletions invenio_communities/views/communities.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
from jinja2 import TemplateError

from invenio_communities.proxies import current_communities
from invenio_rdm_records.proxies import current_community_records_service
from invenio_rdm_records.resources.serializers import UIJSONSerializer

from ..communities.resources.ui_schema import TypesSchema
from .decorators import pass_community
Expand Down Expand Up @@ -421,41 +419,6 @@ def communities_about(pid_value, community, community_ui):
)


@pass_community(serialize=True)
def communities_home(pid_value, community, community_ui):
"""Community home page."""
permissions = community.has_permissions_to(
[
"update",
"read",
"search_requests",
"moderate",
]
)
if not permissions["can_read"]:
raise PermissionDeniedError()

recent_uploads = current_community_records_service.search(
community_id=pid_value,
identity=g.identity,
params={
"sort": "newest",
"size": 3,
},
expand=False,
)

records_ui = UIJSONSerializer().dump_list(recent_uploads.to_dict())["hits"]["hits"]

return render_community_theme_template(
"invenio_communities/details/home/index.html",
theme=community_ui.get("theme", {}),
community=community_ui,
permissions=permissions,
records=records_ui,
)


@pass_community(serialize=True)
def communities_curation_policy(pid_value, community, community_ui):
"""Community curation policy page."""
Expand Down
23 changes: 0 additions & 23 deletions invenio_communities/views/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
communities_about,
communities_curation_policy,
communities_frontpage,
communities_home,
communities_new,
communities_requests,
communities_search,
Expand Down Expand Up @@ -111,14 +110,6 @@ def _has_about_page_content():
return False


def _is_branded_community():
"""Function used to check if community is branded."""
community = request.community
if community.get("theme", {}).get("enabled", False):
return True
return False


def _has_curation_policy_page_content():
"""Function used to check if curation policy page has content."""
community = request.community
Expand Down Expand Up @@ -168,11 +159,6 @@ def create_ui_blueprint(app):
view_func=communities_about,
)

blueprint.add_url_rule(
routes["home"],
view_func=communities_home,
)

blueprint.add_url_rule(
routes["curation_policy"],
view_func=communities_curation_policy,
Expand Down Expand Up @@ -232,15 +218,6 @@ def register_menus():

communities = current_menu.submenu("communities")

communities.submenu("home").register(
"invenio_communities.communities_home",
text=_("Home"),
order=1,
visible_when=_is_branded_community,
expected_args=["pid_value"],
**dict(icon="home", permissions="can_read"),
)

communities.submenu("requests").register(
"invenio_communities.communities_requests",
text=_("Requests"),
Expand Down

0 comments on commit e7bb9d9

Please sign in to comment.