Commit 3b008245 by Tom Christie

Merge pull request #2518 from longhotsummer/patch-1

FIX: Don't default to list in method args
parents d21617ff e13d2af1
...@@ -18,8 +18,7 @@ def api_view(http_method_names=None): ...@@ -18,8 +18,7 @@ def api_view(http_method_names=None):
Decorator that converts a function-based view into an APIView subclass. Decorator that converts a function-based view into an APIView subclass.
Takes a list of allowed methods for the view as an argument. Takes a list of allowed methods for the view as an argument.
""" """
if http_method_names is None: http_method_names = ['GET'] if (http_method_names is None) else http_method_names
http_method_names = ['GET']
def decorator(func): def decorator(func):
...@@ -109,10 +108,12 @@ def permission_classes(permission_classes): ...@@ -109,10 +108,12 @@ def permission_classes(permission_classes):
return decorator return decorator
def detail_route(methods=['get'], **kwargs): def detail_route(methods=None, **kwargs):
""" """
Used to mark a method on a ViewSet that should be routed for detail requests. Used to mark a method on a ViewSet that should be routed for detail requests.
""" """
methods = ['get'] if (methods is None) else methods
def decorator(func): def decorator(func):
func.bind_to_methods = methods func.bind_to_methods = methods
func.detail = True func.detail = True
...@@ -121,10 +122,12 @@ def detail_route(methods=['get'], **kwargs): ...@@ -121,10 +122,12 @@ def detail_route(methods=['get'], **kwargs):
return decorator return decorator
def list_route(methods=['get'], **kwargs): def list_route(methods=None, **kwargs):
""" """
Used to mark a method on a ViewSet that should be routed for list requests. Used to mark a method on a ViewSet that should be routed for list requests.
""" """
methods = ['get'] if (methods is None) else methods
def decorator(func): def decorator(func):
func.bind_to_methods = methods func.bind_to_methods = methods
func.detail = False func.detail = False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment