Fixup attach logic for inventory hosts/groups on subcollections. Pass serializer errors through on conflict scenarios.

This commit is contained in:
Michael DeHaan
2013-03-26 19:21:18 -04:00
parent 88b171bd5b
commit c2bffe47d4
5 changed files with 54 additions and 125 deletions

View File

@@ -372,4 +372,21 @@ class GroupsDetail(BaseDetail):
serializer_class = GroupSerializer
permission_classes = (CustomRbac,)
class InventoryGroupsList(BaseSubList):
model = Group
serializer_class = GroupSerializer
permission_classes = (CustomRbac,)
# to allow the sub-aspect listing
parent_model = Inventory
relationship = 'groups'
# to allow posting to this resource to create resources
postable = True
# FIXME: go back and add these to other SubLists
inject_primary_key_on_post_as = 'inventory'
def _get_queryset(self):
# FIXME: more DRY methods like this
return Inventory._filter_queryset(Inventory.objects.get(pk=self.kwargs['pk']).groups)