def get(self, request, params={}): service = RoleService() 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 = RoleService() 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(Role(), json_request) service = RoleService() 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 = RoleService() 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 preload(self, request, params={}): self.data = RoleService().search(self.form) preloadList = [] for x in self.data: preloadList.append(x.to_json()) return JsonResponse({"preloadList": preloadList})
def save(self, request, params={}): print("orsapi college 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(Role(), json_request) service = RoleService() 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["name"] = json_request.get("name", None) params["pageNo"] = json_request.get("pageNo", None) service = RoleService() 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 form_to_model(self, obj): c = RoleService().get(self.form["role_Id"]) pk = int(self.form["id"]) newdate = "" if (pk > 0): obj.id = pk obj.firstName = self.form["firstName"] obj.lastName = self.form["lastName"] obj.login_id = self.form["login_id"] obj.password = self.form["password"] obj.confirmpassword = self.form["confirmpassword"] obj.dob = self.form["dob"] obj.address = self.form["address"] obj.gender = self.form["gender"] obj.mobilenumber = self.form["mobilenumber"] obj.role_Id = self.form["role_Id"] obj.role_Name = c.name return obj
def get_service(self): return RoleService()
def preload(self, request): self.page_list = RoleService().search(self.form) self.preloadData = self.page_list
def preload(self, request): self.form['roleList'] = RoleService().preload(self.form)