Skip to content

Commit

Permalink
update: use signal to gather config sections
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed Feb 12, 2024
1 parent a7a3944 commit 9d1d37d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
45 changes: 23 additions & 22 deletions ckanext/drupal_api/plugin.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
from __future__ import annotations

import ckan.types as types
import ckan.plugins as p
import ckan.plugins.toolkit as tk

import ckanext.drupal_api.helpers as helpers
from ckanext.drupal_api.views import blueprints

import ckanext.ap_main.types as ap_types
from ckanext.ap_main.interfaces import IAdminPanel


class DrupalApiPlugin(p.SingletonPlugin):
p.implements(p.ITemplateHelpers)
p.implements(p.IConfigurer)
p.implements(p.IBlueprint)
p.implements(IAdminPanel, inherit=True)
p.implements(p.ISignal)

# ITemplateHelpers

Expand All @@ -31,24 +29,27 @@ def update_config(self, config_):
def get_blueprint(self):
return blueprints

# IAdminPanel

def register_config_sections(
self, config_list: list[ap_types.SectionConfig]
) -> list[ap_types.SectionConfig]:
config_list.append(
ap_types.SectionConfig(
name="Drupal API",
configs=[
ap_types.ConfigurationItem(
name="Configuration",
blueprint="drupal_api.config",
info="Drupal API settings",
)
],
)
)
return config_list
# ISignal

def get_signal_subscriptions(self) -> types.SignalMapping:
return {
tk.signals.ckanext.signal("ap_main:collect_config_sections"): [
self.collect_config_sections_subs
],
}

@staticmethod
def collect_config_sections_subs(sender: None):
return {
"name": "Drupal API",
"configs": [
{
"name": "Configuration",
"blueprint": "drupal_api.config",
"info": "Drupal API settings",
},
],
}


if tk.check_ckan_version("2.10"):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# http://packaging.python.org/en/latest/tutorial.html#version
version='0.7.1',
version='0.7.2',

description='''''',
long_description=long_description,
Expand Down

0 comments on commit 9d1d37d

Please sign in to comment.