Example #1
0
 def post(self, request):
     """
     Authentication Required, list of BootScripts on your account.
     """
     data = request.data
     serializer = BootScriptSerializer(data=data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return failure_response(status.HTTP_400_BAD_REQUEST, serializer.errors)
 def post(self, request):
     """
     Authentication Required, list of BootScripts on your account.
     """
     data = request.data
     serializer = BootScriptSerializer(data=data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return failure_response(status.HTTP_400_BAD_REQUEST, serializer.errors)
Example #3
0
 def _update_script(self, request, script_id):
     user = request.user
     data = request.DATA
     partial = True if request.method == "PATCH" else False
     # Step 1: Retrieve or 'Forbidden' on updating script
     scripts = get_scripts_for_user(user.username)
     try:
         script = scripts.get(id=script_id)
     except CoreBootScript.DoesNotExist:
         return failure_response(status.HTTP_404_NOT_FOUND, "BootScript of id %s does not exist." % script_id)
     serializer = BootScriptSerializer(script, data=data, partial=partial)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return failure_response(status.HTTP_400_BAD_REQUEST, serializer.errors)
Example #4
0
 def _update_script(self, request, script_id):
     user = request.user
     data = request.DATA
     partial = True if request.method == 'PATCH' else False
     # Step 1: Retrieve or 'Forbidden' on updating script
     scripts = get_scripts_for_user(user.username)
     try:
         script = scripts.get(id=script_id)
     except CoreBootScript.DoesNotExist:
         return failure_response(
             status.HTTP_404_NOT_FOUND,
             "BootScript of id %s does not exist." % script_id)
     serializer = BootScriptSerializer(script, data=data, partial=partial)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return failure_response(status.HTTP_400_BAD_REQUEST, serializer.errors)