aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/utils
diff options
context:
space:
mode:
authorChristopher Paolini2013-08-17 17:44:51 -0400
committerChristopher Paolini2013-08-17 17:44:51 -0400
commite6662d434f0214d21d38e4388a40fd63e1f9dcc6 (patch)
tree9da7194df8987b9f1bf194089bfea5be8cac55a7 /rest_framework/utils
parenta95984e4d4b034c196d40f74fbdc6345e6d4124c (diff)
downloaddjango-rest-framework-e6662d434f0214d21d38e4388a40fd63e1f9dcc6.tar.bz2
Improved view/description function setting
Now supports each View having its own name and description function and overriding the global default.
Diffstat (limited to 'rest_framework/utils')
-rw-r--r--rest_framework/utils/breadcrumbs.py5
-rw-r--r--rest_framework/utils/formatting.py15
2 files changed, 2 insertions, 18 deletions
diff --git a/rest_framework/utils/breadcrumbs.py b/rest_framework/utils/breadcrumbs.py
index d51374b0..0384faba 100644
--- a/rest_framework/utils/breadcrumbs.py
+++ b/rest_framework/utils/breadcrumbs.py
@@ -1,6 +1,5 @@
from __future__ import unicode_literals
from django.core.urlresolvers import resolve, get_script_prefix
-from rest_framework.utils.formatting import get_view_name
def get_breadcrumbs(url):
@@ -29,8 +28,8 @@ def get_breadcrumbs(url):
# Don't list the same view twice in a row.
# Probably an optional trailing slash.
if not seen or seen[-1] != view:
- suffix = getattr(view, 'suffix', None)
- name = get_view_name(view.cls, suffix)
+ instance = view.cls()
+ name = instance.get_view_name()
breadcrumbs_list.insert(0, (name, prefix + url))
seen.append(view)
diff --git a/rest_framework/utils/formatting.py b/rest_framework/utils/formatting.py
index 4f59f659..5780301a 100644
--- a/rest_framework/utils/formatting.py
+++ b/rest_framework/utils/formatting.py
@@ -45,21 +45,6 @@ def _camelcase_to_spaces(content):
content = re.sub(camelcase_boundry, ' \\1', content).strip()
return ' '.join(content.split('_')).title()
-
-def get_view_name(cls, suffix=None):
- """
- Return a formatted name for an `APIView` class or `@api_view` function.
- """
- return api_settings.VIEW_NAME_FUNCTION(cls, suffix)
-
-
-def get_view_description(cls, html=False):
- """
- Return a description for an `APIView` class or `@api_view` function.
- """
- return api_settings.VIEW_DESCRIPTION_FUNCTION(cls)
-
-
def markup_description(description):
"""
Apply HTML markup to the given description.