Skip to content

Commit

Permalink
fix: fix registering conditional bp
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed Oct 30, 2024
1 parent 00ee476 commit aef3213
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
7 changes: 1 addition & 6 deletions ckanext/search_tweaks/field_relevance/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
DEFAULT_BOOST_FN = None


@tk.blanket.blueprints
class FieldRelevancePlugin(p.SingletonPlugin):
p.implements(ISearchTweaks, inherit=True)
p.implements(p.IAuthFunctions)
p.implements(p.IBlueprint)
p.implements(p.IConfigurer, inherit=True)

# ISearchTweaks
Expand All @@ -28,11 +28,6 @@ def get_search_boost_fn(self, search_params: dict[str, Any]) -> str | None:

return tk.config.get(CONFIG_BOOST_FN, DEFAULT_BOOST_FN)

# IBlueprint

def get_blueprint(self):
return views.get_blueprints()

# IConfigurer

def update_config(self, config):
Expand Down
16 changes: 6 additions & 10 deletions ckanext/search_tweaks/field_relevance/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@
field_relevance = Blueprint("search_tweaks_field_relevance", __name__)


def get_blueprints():
if tk.asbool(
tk.config.get(CONFIG_ENABLE_PROMOTION_ROUTE, DEFAULT_ENABLE_PROMOTION_ROUTE),
):
path = tk.config.get(CONFIG_PROMOTION_PATH, DEFAULT_PROMOTION_PATH)
field_relevance.add_url_rule(path, view_func=PromoteView.as_view("promote"))

return [field_relevance]


class PromoteView(MethodView):
def _check_access(self, id: str) -> None:
try:
Expand Down Expand Up @@ -96,3 +86,9 @@ def get(
}

return tk.render("search_tweaks/field_relevance/promote.html", extra_vars)


if tk.asbool(
tk.config.get(CONFIG_ENABLE_PROMOTION_ROUTE, DEFAULT_ENABLE_PROMOTION_ROUTE),
):
field_relevance.add_url_rule("/dataset/promote/<id>", view_func=PromoteView.as_view("promote"))
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "ckanext-search-tweaks"
version = "0.6.1.post1"
version = "0.6.2"
description = ""
classifiers = [ "Development Status :: 4 - Beta", "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10",]
keywords = [ "CKAN",]
Expand Down

0 comments on commit aef3213

Please sign in to comment.