|
11 | 11 | from django.template.response import TemplateResponse |
12 | 12 | from django.urls import path, reverse |
13 | 13 |
|
14 | | -from .handlers import BaseExtraHandler |
| 14 | +from .handlers import BaseExtraHandler, ViewHandler |
15 | 15 |
|
16 | 16 | logger = logging.getLogger(__name__) |
17 | 17 |
|
@@ -90,7 +90,7 @@ def check(cls, **kwargs): |
90 | 90 | try: |
91 | 91 | from admin_extra_buttons.utils import check_decorator_errors |
92 | 92 | errors.extend(check_decorator_errors(cls)) |
93 | | - except (OperationalError, ProgrammingError): # pragma: no cover |
| 93 | + except (OSError, OperationalError, ProgrammingError): # pragma: no cover |
94 | 94 | pass |
95 | 95 | return errors |
96 | 96 |
|
@@ -133,11 +133,15 @@ def get_urls(self): |
133 | 133 | if callable(method) and isinstance(method, BaseExtraHandler): |
134 | 134 | handlers[method_name] = method.get_instance(self) |
135 | 135 |
|
| 136 | + handler: ViewHandler |
136 | 137 | for handler in handlers.values(): |
137 | 138 | handler.url_name = f'{opts.app_label}_{opts.model_name}_{handler.func.__name__}' |
138 | 139 | if handler.url_pattern: |
| 140 | + f = partial(getattr(self, handler.func.__name__), self) |
| 141 | + for deco in handler.decorators[::-1]: |
| 142 | + f = deco(f) |
139 | 143 | extra_urls.append(path(handler.url_pattern, |
140 | | - partial(getattr(self, handler.func.__name__), self), |
| 144 | + f, |
141 | 145 | name=handler.url_name)) |
142 | 146 | if hasattr(handler, 'button_class'): |
143 | 147 | self.extra_button_handlers[handler.func.__name__] = handler |
|
0 commit comments