@@ -29,6 +29,9 @@ def get_resource_name(view):
2929 name = format_keys (name )
3030 resource_name = name [:1 ].lower () + name [1 :]
3131
32+ if getattr (settings , 'REST_EMBER_FORMAT_KEYS' , False ):
33+ return inflection .camelize (resource_name , False )
34+
3235 return resource_name
3336
3437
@@ -39,18 +42,18 @@ def format_keys(obj, format_type=None):
3942
4043 :format_type: Either 'camelize' or 'underscore'
4144 """
42- if getattr (settings , 'REST_EMBER_FORMAT_KEYS' , False )\
43- and format_type in ('camelize' , 'underscore' ):
45+ if ( getattr (settings , 'REST_EMBER_FORMAT_KEYS' , False )
46+ and format_type in ('camelize' , 'underscore' )) :
4447
4548 if isinstance (obj , dict ):
4649 formatted = {}
4750 for key , value in obj .items ():
4851 if format_type == 'camelize' :
49- formatted [inflection .camelize (key , False )]\
50- = format_keys (value , format_type )
52+ ( formatted [inflection .camelize (key , False )]
53+ = format_keys (value , format_type ))
5154 elif format_type == 'underscore' :
52- formatted [inflection .underscore (key )]\
53- = format_keys (value , format_type )
55+ ( formatted [inflection .underscore (key )]
56+ = format_keys (value , format_type ))
5457 return formatted
5558 if isinstance (obj , list ):
5659 return [format_keys (item , format_type ) for item in obj ]
@@ -64,7 +67,9 @@ def format_resource_name(obj, name):
6467 """
6568 Pluralize the resource name if more than one object in results.
6669 """
67- if getattr (settings , 'REST_EMBER_PLURALIZE_KEYS' , False ) and isinstance (obj , list ):
70+ if (getattr (settings , 'REST_EMBER_PLURALIZE_KEYS' , False )
71+ and isinstance (obj , list )):
72+
6873 return inflection .pluralize (name ) if len (obj ) > 1 else name
6974 else :
7075 return name
0 commit comments