mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-23 00:11:48 -05:00
Move validation of credential creation to the serializer. Use SubListCreateAPIView for creating a credential under another object, and remove fields from serializer and API docs that aren't valid when creating a credential under another object.
This commit is contained in:
@@ -9,6 +9,7 @@ import time
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.db import connection
|
||||
from django.http import QueryDict
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.encoding import smart_text
|
||||
@@ -328,10 +329,11 @@ class SubListCreateAPIView(SubListAPIView, ListCreateAPIView):
|
||||
|
||||
# Make a copy of the data provided (since it's readonly) in order to
|
||||
# inject additional data.
|
||||
if hasattr(request.data, 'dict'):
|
||||
data = request.data.dict()
|
||||
if hasattr(request.data, 'copy'):
|
||||
data = request.data.copy()
|
||||
else:
|
||||
data = request.data
|
||||
data = QueryDict('')
|
||||
data.update(request.data)
|
||||
|
||||
# add the parent key to the post data using the pk from the URL
|
||||
parent_key = getattr(self, 'parent_key', None)
|
||||
|
||||
Reference in New Issue
Block a user