Exemple #1
0
 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"]})
Exemple #2
0
 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"]})
Exemple #3
0
 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})
Exemple #4
0
 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})
Exemple #5
0
    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})
Exemple #6
0
    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})
Exemple #7
0
    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})
Exemple #8
0
    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
Exemple #9
0
 def get_service(self):
     return RoleService()
Exemple #10
0
 def preload(self, request):
     self.page_list = RoleService().search(self.form)
     self.preloadData = self.page_list
Exemple #11
0
 def preload(self, request):
     self.form['roleList'] = RoleService().preload(self.form)