Add support for label batch "quick entry" API
plus other general improvements to API core/master views and config
This commit is contained in:
parent
c520dc23ba
commit
bd09acd0fd
4 changed files with 159 additions and 3 deletions
|
@ -62,6 +62,40 @@ class APIMasterView(APIView):
|
|||
return cls.normalized_model_name
|
||||
return cls.get_model_class().__name__.lower()
|
||||
|
||||
@classmethod
|
||||
def get_route_prefix(cls):
|
||||
"""
|
||||
Returns a prefix which (by default) applies to all routes provided by
|
||||
this view class.
|
||||
"""
|
||||
prefix = getattr(cls, 'route_prefix', None)
|
||||
if prefix:
|
||||
return prefix
|
||||
model_name = cls.get_normalized_model_name()
|
||||
return 'api.{}s'.format(model_name)
|
||||
|
||||
@classmethod
|
||||
def get_permission_prefix(cls):
|
||||
"""
|
||||
Returns a prefix which (by default) applies to all permissions
|
||||
leveraged by this view class.
|
||||
"""
|
||||
prefix = getattr(cls, 'permission_prefix')
|
||||
if prefix:
|
||||
return prefix
|
||||
return cls.get_route_prefix()
|
||||
|
||||
@classmethod
|
||||
def get_url_prefix(cls):
|
||||
"""
|
||||
Returns a prefix which (by default) applies to all URLs provided by
|
||||
this view class.
|
||||
"""
|
||||
prefix = getattr(cls, 'url_prefix', None)
|
||||
if prefix:
|
||||
return prefix
|
||||
return '/{}'.format(cls.get_route_prefix())
|
||||
|
||||
@classmethod
|
||||
def get_object_key(cls):
|
||||
if hasattr(cls, 'object_key'):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue