Custom admin panel for CKAN to expand default functionality
Project description
ckanext-admin-panel
Next generation admin interface for CKAN.
Content
TODO
This extension is under development, so there are many things to do:
- CKAN forms:
- What do we want to do, if we are editing an entity from admin panel? Use default form or replace it with an admin version?
- Users:
- Add
User edit
page
- Add
- Recent log messages:
- We have some types, that we don't want to include in list. E.g xloader resources. Research what is better to do with them.
- Rework the pagination approach, because the current naive one will work very slow on big amount of data
- Rewrite
user_list
action. Currently it's just a copy of contrib one with one small change. Maybe it's a good idea to write our own versatile version. - Think about configuration section pages. Do we need a separate page for a section?
- Work on
Extensions
page. What do we want: replacestatus_show
. This page should be more informative. Show here what extensions we are using with the respective versions. For now we don't have a standartized mechanism to retrieve versions from extensions, think about it. - Work on
Available updates?
page. Show user if he could upgrade an extension or CKAN to a new version. - Work on
Appearance
page. TODO - Work on
Help
page. TODO
Registering config sections
We utilize the ISignal
interface for gathering configuration sections. For instance, to register a configuration section from your extension:
from __future__ import annotations
import ckan.types as types
import ckan.plugins as p
import ckan.plugins.toolkit as tk
import ckanext.ap_main.types as ap_types
class ExamplePlugin(p.SingletonPlugin):
...
p.implements(p.ISignal)
...
# 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 ap_types.SectionConfig(
name="Example plugin configuration",
configs=[
ap_types.ConfigurationItem(
name="Configuration",
blueprint="example_plugin.config,
info="Basic configuration options",
),
],
)
The structure of the section is outlined in the SectionConfig
and ConfigurationItem
here.
You can import these structures and use them to assemble the section or just return a dictionary mirroring the same structure. This method works the same as described above:
@staticmethod
def collect_config_sections_subs(sender: None):
return {
"name": "Example plugin configuration",
"configs": [
{
"name": "Configuration",
"blueprint": "example_plugin.config",
"info": "Basic configuration options",
},
],
}
If the section with the specified name
has already been registered by another plugin, the configuration options will be included into it.
The structure of ConfigurationItem
is as follows:
name
- defines the name of the configuration section linkblueprint
- indicates the configuration page blueprintinfo
(optional, default:No description
) - provides a description for the configuration link
Requirements
Compatibility with core CKAN versions:
CKAN version | Compatible? |
---|---|
2.9 | no |
2.10 | yes |
2.11 | yes |
Installation
To install ckanext-admin-panel:
-
Activate your CKAN virtual environment, for example:
. /usr/lib/ckan/default/bin/activate
-
Clone the source and install it on the virtualenv
git clone https://github.com/mutantsan/ckanext-admin-panel.git cd ckanext-admin-panel pip install -e . pip install -r requirements.txt
-
Add
admin_panel admin_panel_cron
to theckan.plugins
setting in your CKAN config file (by default the config file is located at/etc/ckan/default/ckan.ini
). -
Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reload
Config settings
None at present
Enabling logging
To store log messages in a database, you must enable the admin_panel_log
extension, initialize the database log table,
and create a handler in your 'ckan.ini' file.
-
Add
admin_panel_log
to theckan.plugins
setting in your CKAN config file. -
Initialize all missing tables with:
ckan db pending-migrations --apply
-
To register a handler, you must specify it in your CKAN configuration file. Due to some CKAN specifics, the logger needs to know the database URI to initialize itself. Provide it with the
kwargs
option.[handler_dbHandler] class = ckanext.ap_log.log_handlers.DatabaseHandler formatter = generic level = NOTSET kwargs={"db_uri": "postgresql://ckan_default:pass@localhost/master"}
-
The logging handler must be also included in
[handlers]
section.[handlers] keys = console, dbHandler
-
The last thing you need to do is to add our handler to a logger you need. For example, if you want to log only
ckan
logs, do this:[logger_ckan] level = INFO handlers = console, dbHandler
Enable CRON logging
Register a separate logger for a cron job logging. The DB handler must be initiated first if you want to have an access to logs via UI. Otherwise, you will be able to see logs only in CKAN logs files.
- Define a logger
[logger_ap_cron] level = DEBUG handlers = console, dbHandler qualname = ap_cron propagate = 0
- Use the newly created logger by specifiyng it in
loggers
section.[loggers] keys = root, ckan, ckanext, werkzeug, flask_app, ap_cron
Developer installation
To install ckanext-admin-panel for development, activate your CKAN virtualenv and do:
git clone https://github.com/mutantsan/ckanext-admin-panel.git
cd ckanext-admin-panel
python setup.py develop
pip install -r dev-requirements.txt
Tests
To run the tests, do:
pytest --ckan-ini=test.ini
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ckanext_admin_panel-1.0.11.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdbbfc429339d79beaea84b56711a0672d21e3c77ed7467b6d48a6abfc09748f |
|
MD5 | 760364b678ddeb7ec13c559c0cee8dad |
|
BLAKE2b-256 | 12c96d8ec0aa330f803c56fd459ec5c75ee42f519c857a359b05e08f92cb273a |
Hashes for ckanext_admin_panel-1.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 119f36fa112f3e57fb90dc5e68a93f4acffd4136bb4ea98b7cc0264559542d63 |
|
MD5 | 3ef31b3d833d4385ca4b716116787cca |
|
BLAKE2b-256 | df3658420e99f59cd9aaa679e26b8ccd2dad430238798a347b7a43f66ed9b190 |