|
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): |
@@ -250,8 +253,7 @@ def dispatch(self, request, tool, **kwargs): |
250 | 253 | raise Http404("Action does not exist") |
251 | 254 |
|
252 | 255 | # TODO move ('get', 'post' config default someplace else) |
253 | | - allowed_methods = getattr(view, "methods", ("GET", "POST")) |
254 | | - print("dispatch", request.method, allowed_methods) |
| 256 | + allowed_methods = getattr(view, "methods", DEFAULT_METHODS_ALLOWED) |
255 | 257 | if request.method.upper() not in allowed_methods: |
256 | 258 | return HttpResponseNotAllowed(allowed_methods) |
257 | 259 |
|
@@ -324,8 +326,8 @@ def action( |
324 | 326 | description=None, |
325 | 327 | label=None, |
326 | 328 | attrs=None, |
327 | | - methods=("GET", "POST"), |
328 | | - button_type="a", |
| 329 | + methods=DEFAULT_METHODS_ALLOWED, |
| 330 | + button_type=DEFAULT_BUTTON_TYPE, |
329 | 331 | ): |
330 | 332 | """ |
331 | 333 | Conveniently add attributes to an action function: |
|
0 commit comments