-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: extract logs into a separate module
- Loading branch information
Showing
22 changed files
with
115 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from typing import Any, Callable | ||
|
||
from ckanext.collection.types import BaseSerializer | ||
|
||
from ckanext.toolbelt.decorators import Collector | ||
|
||
from ckanext.ap_main.types import ColRenderer | ||
|
||
renderer: Collector[ColRenderer] | ||
get_renderers: Callable[[], dict[str, ColRenderer]] | ||
renderer, get_renderers = Collector().split() | ||
|
||
|
||
@renderer | ||
def log_level( | ||
value: Any, options: dict[str, Any], name: str, record: Any, self: BaseSerializer | ||
) -> str: | ||
return logging.getLevelName(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
11 changes: 6 additions & 5 deletions
11
...versions/65d431520aa2_add_aplogs_table.py → ...l_log/versions/fe11724f1867_init_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from __future__ import annotations | ||
|
||
import ckan.plugins as p | ||
import ckan.plugins.toolkit as tk | ||
|
||
from ckanext.collection.interfaces import ICollection, CollectionFactory | ||
from ckanext.ap_main.interfaces import IAdminPanel | ||
import ckanext.ap_main.types as ap_types | ||
|
||
from ckanext.ap_log.col_renderers import get_renderers | ||
from ckanext.ap_log import collection | ||
|
||
|
||
@tk.blanket.blueprints | ||
class AdminPanelLogPlugin(p.SingletonPlugin): | ||
p.implements(p.IConfigurer) | ||
p.implements(IAdminPanel, inherit=True) | ||
p.implements(ICollection, inherit=True) | ||
|
||
# IConfigurer | ||
|
||
def update_config(self, config_: tk.CKANConfig): | ||
tk.add_template_directory(config_, "templates") | ||
tk.add_public_directory(config_, "public") | ||
tk.add_resource("assets", "ap_log") | ||
|
||
# IAdminPanel | ||
|
||
def get_col_renderers(self) -> dict[str, ap_types.ColRenderer]: | ||
return get_renderers() | ||
|
||
def register_toolbar_button( | ||
self, toolbar_buttons_list: list[ap_types.ToolbarButton] | ||
) -> list[ap_types.ToolbarButton]: | ||
"""Extension will receive the list of toolbar button objects.""" | ||
|
||
for button in toolbar_buttons_list: | ||
if button.get("label") == "Reports": | ||
button.setdefault("subitems", []) | ||
|
||
button["subitems"].append( # type: ignore | ||
ap_types.ToolbarButton( | ||
label=tk._("Logs"), | ||
url=tk.url_for("ap_log.list"), | ||
) | ||
) | ||
|
||
return toolbar_buttons_list | ||
|
||
# ICollection | ||
def get_collection_factories(self) -> dict[str, CollectionFactory]: | ||
return { | ||
"ap-logs": collection.DbLogCollection, | ||
} |
Empty file.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
from .content import ContentCollection | ||
from .user import UserCollection | ||
from .report import DbLogCollection | ||
|
||
__all__ = [ | ||
"ContentCollection", | ||
"UserCollection", | ||
"DbLogCollection", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
from ckanext.ap_main.views.basic import ap_basic | ||
from ckanext.ap_main.views.config import ap_config_list | ||
from ckanext.ap_main.views.content import ap_content | ||
from ckanext.ap_main.views.reports import ap_report | ||
from ckanext.ap_main.views.user import ap_user | ||
|
||
__all__ = [ | ||
"ap_basic", | ||
"ap_config_list", | ||
"ap_user", | ||
"ap_report", | ||
"ap_content", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters