diff --git a/ckanext/tour/plugin.py b/ckanext/tour/plugin.py index 6a95fa6..9feecdd 100644 --- a/ckanext/tour/plugin.py +++ b/ckanext/tour/plugin.py @@ -1,11 +1,13 @@ from __future__ import annotations +from typing import Literal + +import ckan.types as types import ckan.plugins as plugins import ckan.plugins.toolkit as tk from ckanext.collection.interfaces import ICollection, CollectionFactory -from ckanext.ap_main.interfaces import IAdminPanel from ckanext.ap_main.types import ConfigurationItem, SectionConfig from ckanext.tour.collection import TourListCollection @@ -18,8 +20,8 @@ @tk.blanket.validators class TourPlugin(plugins.SingletonPlugin): plugins.implements(plugins.IConfigurer) - plugins.implements(IAdminPanel, inherit=True) plugins.implements(ICollection, inherit=True) + plugins.implements(plugins.ISignal) # IConfigurer @@ -28,36 +30,34 @@ def update_config(self, config_): tk.add_public_directory(config_, "public") tk.add_resource("assets", "tour") - # IAdminPanel - - def register_config_sections( - self, config_list: list[SectionConfig] - ) -> list[SectionConfig]: - config_list.append( - SectionConfig( - name="Tour", - configs=[ - # ConfigurationItem( - # name="Global settings", - # blueprint="tour.config", - # info="Global configuration for a tour", - # ), - ConfigurationItem( - name="List of tours", - blueprint="tour.list", - info="Manage existing tours", - ), - ConfigurationItem( - name="Add tour", - blueprint="tour.add", - info="Add new tour", - ), - ], - ) - ) - return config_list + # ISignal + + def get_signal_subscriptions(self) -> types.SignalMapping: + return { + tk.signals.ckanext.signal("ap_main:collect_config_sections"): [ + collect_config_sections_subs + ], + } # ICollection def get_collection_factories(self) -> dict[str, CollectionFactory]: return {"tour-list": TourListCollection} + + +def collect_config_sections_subs(sender: None): + return SectionConfig( + name="Tour", + configs=[ + ConfigurationItem( + name="List of tours", + blueprint="tour.list", + info="Manage existing tours", + ), + ConfigurationItem( + name="Add tour", + blueprint="tour.add", + info="Add new tour", + ), + ], + )