Skip to content

Commit

Permalink
redirector: move community home page view up to app-rdm
Browse files Browse the repository at this point in the history
  • Loading branch information
kpsherva authored and slint committed Feb 16, 2024
1 parent 20f598e commit d94c9f9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
6 changes: 0 additions & 6 deletions site/zenodo_rdm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from .params import ZenodoArgsSchema, ZenodoSearchOptions
from .redirector import (
communities_detail_view_function,
communities_home_view_function,
communities_records_search,
communities_requests_view_function,
communities_settings_view_function,
Expand Down Expand Up @@ -233,11 +232,6 @@
"rule_options": {"strict_slashes": False},
"target": communities_settings_view_function,
},
"redirect_communities_home": {
"source": "/communities/<community_id>",
"rule_options": {"strict_slashes": False},
"target": communities_home_view_function,
},
"redirect_communities_search": {
"source": "/communities/<community_id>/search",
"rule_options": {"strict_slashes": False},
Expand Down
29 changes: 0 additions & 29 deletions site/zenodo_rdm/redirector.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,35 +80,6 @@ def communities_settings_view_function():
return target


def communities_home_view_function():
"""Implements redirector view function for community landing page.
The following routes are redirected as follows:
- /communities/<community_id>/ -> GET /communities/<community_id>/records
- /communities/<community_id>?q=<query> -> GET /communities/<community_id>/records?q=<query>
:return: url for the view 'invenio_app_rdm_communities.communities_detail'
:rtype: str
"""
_id = request.view_args["community_id"]
community = current_communities.service.record_cls.pid.resolve(_id)
values = {"pid_value": _id}
query_params = request.args

if query_params:
# If there are query parameters, redirect to records page
query_string = urlencode(query_params)
url = url_for("invenio_app_rdm_communities.communities_detail", **values)
target = f"{url}?{query_string}"
return target
elif community.theme and community.theme.get("enabled", False):
# If theme is enabled, redirect to the home page of the community
return url_for("invenio_app_rdm_communities.communities_home", **values)
else:
# If theme is not enabled and no query parameters, redirect to records page of the community
return url_for("invenio_app_rdm_communities.communities_detail", **values)


def communities_requests_view_function():
"""Implements redirector view function for communities requests.
Expand Down

0 comments on commit d94c9f9

Please sign in to comment.