Replace base_name => basename for consisntency's sake

Changed on DRF 3.12.x and related to PR https://github.com/encode/django-rest-framework/pull/5990
This commit is contained in:
Santiago L 2021-07-08 12:46:55 +02:00
parent c21a52a756
commit 50f916fa4d
2 changed files with 18 additions and 18 deletions

View file

@ -23,16 +23,16 @@ def link_wrap(view, view_names):
return wrapper
def insert_links(viewset, base_name):
collection_links = ['api-root', '%s-list' % base_name]
object_links = ['api-root', '%s-list' % base_name, '%s-detail' % base_name]
def insert_links(viewset, basename):
collection_links = ['api-root', '%s-list' % basename]
object_links = ['api-root', '%s-list' % basename, '%s-detail' % basename]
exception_links = ['api-root']
list_links = ['api-root']
retrieve_links = ['api-root', '%s-list' % base_name]
retrieve_links = ['api-root', '%s-list' % basename]
# Determine any `@action` or `@link` decorated methods on the viewset
for methodname in dir(viewset):
method = getattr(viewset, methodname)
view_name = '%s-%s' % (base_name, methodname.replace('_', '-'))
view_name = '%s-%s' % (basename, methodname.replace('_', '-'))
if hasattr(method, 'collection_bind_to_methods'):
list_links.append(view_name)
retrieve_links.append(view_name)

View file

@ -65,12 +65,12 @@ class LinkHeaderRouter(DefaultRouter):
APIRoot.router = self
return APIRoot.as_view()
def register(self, prefix, viewset, base_name=None):
def register(self, prefix, viewset, basename=None):
""" inserts link headers on every viewset """
if base_name is None:
base_name = self.get_default_base_name(viewset)
insert_links(viewset, base_name)
self.registry.append((prefix, viewset, base_name))
if basename is None:
basename = self.get_default_basename(viewset)
insert_links(viewset, basename)
self.registry.append((prefix, viewset, basename))
def get_viewset(self, prefix_or_model):
for _prefix, viewset, __ in self.registry: