Merge pull request #1662 from AlanCoding/1407_credential_post_fields_rebased

Allow credentials to be created in UI touch up documentation for owners
This commit is contained in:
Alan Rominger
2016-04-29 12:33:59 -04:00
2 changed files with 25 additions and 1 deletions

View File

@@ -1224,6 +1224,10 @@ class CredentialList(ListCreateAPIView):
serializer_class = CredentialSerializer
def post(self, request, *args, **kwargs):
for field in [x for x in ['user', 'team', 'organization'] if x in request.data and request.data[x] in ('', None)]:
request.data.pop(field)
kwargs.pop(field, None)
if not any([x in request.data for x in ['user', 'team', 'organization']]):
return Response({'detail': 'Missing user, team, or organization'}, status=status.HTTP_400_BAD_REQUEST)