def get(self, request, params={}): service = StudentService() c = service.get(params["id"]) res = {} if (c != None): res["data"] = c.to_json() res["error"] = False res["message"] = "Data is found" else: res["error"] = True res["message"] = "record not found" return JsonResponse({"data": res["data"]})
def delete(self, request, params={}): service = StudentService() c = service.get(params["id"]) res = {} if (c != None): service.delete(params["id"]) res["data"] = c.to_json() res["error"] = False res["message"] = "Data is Successfully deleted" else: res["error"] = True res["message"] = "Data is not deleted" return JsonResponse({"data": res["data"]})
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})
def search(self, request, params={}): service = StudentService() c = service.search(params) res = {} data = [] for x in c: data.append(x.to_json()) if (c != None): res["data"] = data res["error"] = False res["message"] = "Data is found" else: res["error"] = True res["message"] = "record not found" return JsonResponse({"data": res})
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})
def search(self, request, params={}): json_request = json.loads(request.body) if (json_request): params["collegeName"] = json_request.get("collegeName", None) params["pageNo"] = json_request.get("pageNo", None) service = StudentService() c = service.search(params) res = {} if (c != None): res["data"] = c["data"] res["error"] = False res["message"] = "Data is found" else: res["error"] = True res["message"] = "record not found" return JsonResponse({"result": res})
def search(self, request, params={}): json_request = json.loads(request.body) if (json_request): params["collegeName"] = json_request.get("collegeName", None) service = StudentService() c = service.search(params) res = {} data = [] for x in c: data.append(x.to_json()) if (c != None): res["data"] = data res["error"] = False res["message"] = "Data is found" else: res["error"] = True res["message"] = "record not found" return JsonResponse({"data": res})
def search(self, request, params={}): print("orsapi student search is run") json_request = json.loads(request.body) if (json_request): params["email"] = json_request.get("email", None) service = StudentService() c = service.search(params) collegeList = CollegeService().search(self.form) res = {} data = [] for x in c: for y in collegeList: if x.college_ID == y.id: x.collegeName = y.collegeName print("ddddd----------->", x.collegeName) data.append(x.to_json()) if (c != None): res["data"] = data res["error"] = False res["message"] = "Data is found" else: res["error"] = True res["message"] = "record not found" return JsonResponse({"data": res})
def get_service(self): return StudentService()
def preload(self, request): self.page_list = StudentService().search(self.form) self.preloadData = self.page_list