예제 #1
0
 def save(self, request, params={}):
     json_request = json.loads(request.body)
     r = self.form_to_model(Student(), json_request)
     service = StudentService()
     c = service.save(r)
     res = {}
     if (r != None):
         res["data"] = r.to_json()
         res["error"] = False
         res["message"] = "Data is Successfully saved"
     else:
         res["error"] = True
         res["message"] = "Data is not saved"
     return JsonResponse({"data": res})
예제 #2
0
    def save(self, request, params={}):
        print("orsapi student save is run")
        json_request = json.loads(request.body)
        self.request_to_form(json_request)
        res = {}
        if (self.input_validation()):
            res["error"] = True
            res["message"] = ""
        else:
            r = self.form_to_model(Student(), json_request)
            service = StudentService()
            c = service.save(r)

            if (r != None):
                res["data"] = r.to_json()
                res["error"] = False
                res["message"] = "Data is Successfully saved"
        return JsonResponse({"data": res, 'form': self.form})