Skip to content

Commit

Permalink
update: support changed in admin_panel
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed Jan 2, 2024
1 parent a0df56e commit 3fcd89a
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ckanext/tour/col_renderers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

import ckanext.admin_panel.types as ap_types
import ckanext.ap_main.types as ap_types
from ckanext.toolbelt.decorators import Collector

renderer, get_renderers = Collector("tour").split()
Expand Down
1 change: 1 addition & 0 deletions ckanext/tour/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ def tour_get_position_options():
)
]


def tour_random_step_id() -> str:
return str(uuid.uuid4())
5 changes: 2 additions & 3 deletions ckanext/tour/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import ckan.plugins as plugins
import ckan.plugins.toolkit as tk

from ckanext.admin_panel.interfaces import IAdminPanel
from ckanext.admin_panel.types import (ColRenderer, ConfigurationItem,
SectionConfig)
from ckanext.ap_main.interfaces import IAdminPanel
from ckanext.ap_main.types import ColRenderer, ConfigurationItem, SectionConfig
from ckanext.tour.col_renderers import get_renderers


Expand Down
6 changes: 4 additions & 2 deletions ckanext/tour/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from flask import Blueprint

from ckanext.admin_panel.utils import ap_before_request
from ckanext.ap_main.utils import ap_before_request
from ckanext.tour.views.tour_add import TourAddStepView, TourAddView
from ckanext.tour.views.tour_config import TourConfigView
from ckanext.tour.views.tour_delete import TourDeleteView, TourStepDeleteView
Expand All @@ -19,7 +19,9 @@
tour.add_url_rule("/list", view_func=TourListView.as_view("list"))
tour.add_url_rule("/new", view_func=TourAddView.as_view("add"))
tour.add_url_rule("/delete/<tour_id>", view_func=TourDeleteView.as_view("delete"))
tour.add_url_rule("/delete_step/<tour_step_id>", view_func=TourStepDeleteView.as_view("delete_step"))
tour.add_url_rule(
"/delete_step/<tour_step_id>", view_func=TourStepDeleteView.as_view("delete_step")
)
tour.add_url_rule("/edit/<tour_id>", view_func=TourUpdateView.as_view("edit"))
tour.add_url_rule("/add_step", view_func=TourAddStepView.as_view("add_step"))

Expand Down
2 changes: 1 addition & 1 deletion ckanext/tour/views/tour_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from flask import Blueprint
from flask.views import MethodView

from ckanext.admin_panel.utils import ap_before_request
from ckanext.ap_main.utils import ap_before_request

tour = Blueprint("tour", __name__)
tour.before_request(ap_before_request)
Expand Down
3 changes: 2 additions & 1 deletion ckanext/tour/views/tour_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from flask import Blueprint, Response
from flask.views import MethodView

from ckanext.admin_panel.utils import ap_before_request
from ckanext.ap_main.utils import ap_before_request

tour = Blueprint("tour", __name__)
tour.before_request(ap_before_request)
Expand All @@ -25,6 +25,7 @@ def post(self, tour_id: str) -> Response:

return tk.redirect_to("tour.list")


class TourStepDeleteView(MethodView):
def post(self, tour_step_id: str) -> str:
try:
Expand Down
12 changes: 6 additions & 6 deletions ckanext/tour/views/tour_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from flask import Blueprint
from flask.views import MethodView

from ckanext.admin_panel.utils import ap_before_request
from ckanext.ap_main.utils import ap_before_request

tour = Blueprint("tour", __name__)
tour.before_request(ap_before_request)
Expand Down Expand Up @@ -56,16 +56,16 @@ def _get_table_columns(self) -> list[dict[str, Any]]:
actions=[
tk.h.ap_table_action(
"tour.delete",
tk._("Delete"),
{"tour_id": "$id"},
label=tk._("Delete"),
params={"tour_id": "$id"},
attributes={"class": "btn btn-danger"},
),
tk.h.ap_table_action(
"tour.edit",
tk._("Edit"),
{"tour_id": "$id"},
label=tk._("Edit"),
params={"tour_id": "$id"},
),
],
]
),
]

Expand Down
4 changes: 2 additions & 2 deletions ckanext/tour/views/tour_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from flask import Blueprint, Response
from flask.views import MethodView

from ckanext.admin_panel.utils import ap_before_request
from ckanext.ap_main.utils import ap_before_request

tour = Blueprint("tour", __name__)
tour.before_request(ap_before_request)
Expand Down Expand Up @@ -58,7 +58,7 @@ def _prepare_payload(self, tour_id: str):
"step_intro",
"step_position",
"step_clear",
"step_index"
"step_index",
)

steps = {}
Expand Down

0 comments on commit 3fcd89a

Please sign in to comment.