Skip to content

Commit

Permalink
Merge pull request #40 from AltSchool/feature/options-updates
Browse files Browse the repository at this point in the history
metadata updates: add resource names, use plural name for related_to
  • Loading branch information
aleontiev committed Sep 22, 2015
2 parents 467ce9f + a4a8145 commit dbd6873
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dynamic_rest/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def determine_metadata(self, request, view):
metadata['features'] = getattr(view, 'features', [])
if hasattr(view, 'get_serializer'):
serializer = view.get_serializer(dynamic=False)
if hasattr(serializer, 'get_name'):
metadata['resource_name'] = serializer.get_name()
if hasattr(serializer, 'get_plural_name'):
metadata['resource_name_plural'] = serializer.get_plural_name()
metadata['properties'] = self.get_serializer_info(serializer)
return metadata

Expand Down Expand Up @@ -52,7 +56,7 @@ def get_field_info(self, field):
many = True
if isinstance(field, ModelSerializer):
type = 'many' if many else 'one'
field_info['related_to'] = field.get_name()
field_info['related_to'] = field.get_plural_name()
else:
type = self.label_lookup[field]

Expand Down

0 comments on commit dbd6873

Please sign in to comment.