|
11 | 11 | from django.views.generic.list import MultipleObjectMixin
|
12 | 12 | from django.urls import re_path, reverse
|
13 | 13 |
|
| 14 | +DEFAULT_METHODS_ALLOWED = ("GET", "POST") |
| 15 | +DEFAULT_BUTTON_TYPE = "a" |
| 16 | + |
14 | 17 |
|
15 | 18 | class BaseDjangoObjectActions(object):
|
16 | 19 | """
|
@@ -159,7 +162,7 @@ def _get_tool_dict(self, tool_name):
|
159 | 162 | label=getattr(tool, "label", tool_name.replace("_", " ").capitalize()),
|
160 | 163 | standard_attrs=standard_attrs,
|
161 | 164 | custom_attrs=custom_attrs,
|
162 |
| - button_type=getattr(tool, "button_type", "a"), |
| 165 | + button_type=getattr(tool, "button_type", DEFAULT_BUTTON_TYPE), |
163 | 166 | )
|
164 | 167 |
|
165 | 168 | def _get_button_attrs(self, tool):
|
@@ -249,9 +252,7 @@ def dispatch(self, request, tool, **kwargs):
|
249 | 252 | except KeyError:
|
250 | 253 | raise Http404("Action does not exist")
|
251 | 254 |
|
252 |
| - # TODO move ('get', 'post' config default someplace else) |
253 |
| - allowed_methods = getattr(view, "methods", ("GET", "POST")) |
254 |
| - print("dispatch", request.method, allowed_methods) |
| 255 | + allowed_methods = getattr(view, "methods", DEFAULT_METHODS_ALLOWED) |
255 | 256 | if request.method.upper() not in allowed_methods:
|
256 | 257 | return HttpResponseNotAllowed(allowed_methods)
|
257 | 258 |
|
@@ -324,8 +325,8 @@ def action(
|
324 | 325 | description=None,
|
325 | 326 | label=None,
|
326 | 327 | attrs=None,
|
327 |
| - methods=("GET", "POST"), |
328 |
| - button_type="a", |
| 328 | + methods=DEFAULT_METHODS_ALLOWED, |
| 329 | + button_type=DEFAULT_BUTTON_TYPE, |
329 | 330 | ):
|
330 | 331 | """
|
331 | 332 | Conveniently add attributes to an action function:
|
|
0 commit comments