mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-29 01:20:02 +03:00
Rename underscore2dash to dasherize_url
This commit is contained in:
parent
d11b569ef4
commit
6579d8e170
|
@ -120,7 +120,7 @@ def schema(view_inspector):
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
def action(methods=None, detail=None, url_path=None, url_name=None, underscore2dash=None, **kwargs):
|
def action(methods=None, detail=None, url_path=None, url_name=None, dasherize_url=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Mark a ViewSet method as a routable action.
|
Mark a ViewSet method as a routable action.
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ def action(methods=None, detail=None, url_path=None, url_name=None, underscore2d
|
||||||
if url_path:
|
if url_path:
|
||||||
func.url_path = url_path
|
func.url_path = url_path
|
||||||
else:
|
else:
|
||||||
func.url_path = func.__name__.replace('_', '-') if underscore2dash else func.__name__
|
func.url_path = func.__name__.replace('_', '-') if dasherize_url else func.__name__
|
||||||
|
|
||||||
func.url_name = url_name if url_name else func.__name__.replace('_', '-')
|
func.url_name = url_name if url_name else func.__name__.replace('_', '-')
|
||||||
func.kwargs = kwargs
|
func.kwargs = kwargs
|
||||||
|
|
|
@ -183,8 +183,8 @@ class ActionDecoratorTestCase(TestCase):
|
||||||
'description': 'Description',
|
'description': 'Description',
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_underscore2dash(self):
|
def test_dasherize_url(self):
|
||||||
@action(detail=True, underscore2dash=True)
|
@action(detail=True, dasherize_url=True)
|
||||||
def test_action(request):
|
def test_action(request):
|
||||||
"""Description"""
|
"""Description"""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user