def get(self, request, params={}): service = SubjectService() 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 = SubjectService() 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(Subject(), json_request) service = SubjectService() 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 = SubjectService() 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("tt search is found------------->") json_request = json.loads(request.body) if (json_request): params["subjectName"] = json_request.get("subjectName", None) params["semester"] = json_request.get("semester", None) service = TimeTableService() c = TimeTableService().search(params) print(params, " 1aaaaaaaaaaaaaaaa11111111111-->", c) res = {} data = [] courseList = CourseService().search(self.form) subject_List = SubjectService().search(self.form) for x in c: for y in courseList: if x.course_ID == y.id: x.courseName = y.courseName for z in subject_List: if x.subject_ID == z.id: x.subjectName = z.subjectName print("mk") 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 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(Subject(), json_request) service = SubjectService() 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["subjectName"] = json_request.get("subjectName", None) params["pageNo"] = json_request.get("pageNo", None) service = SubjectService() 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["subjectName"]=json_request.get("subjectName",None) service=SubjectService() 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={}): courseList=CourseService().search(self.form) subjectList = SubjectService().search(self.form) coursedata=[] for x in courseList: coursedata.append(x.to_json()) subpreload=[] for y in subjectList: subpreload.append(y.to_json()) return JsonResponse({"subpreload":subpreload,"coursedata":coursedata})
def search(self, request, params={}): json_request = json.loads(request.body) if (json_request): params["subjectName"] = json_request.get("subjectName", None) service = SubjectService() c = service.search(params) res = {} data = [] courseList = CourseService().search(self.form) for x in c: for y in courseList: if x.course_ID == y.id: x.courseName = y.courseName print("ddddd----------->", x.courseName) 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 form_to_model(self, obj): c = CourseService().get(self.form["course_ID"]) s = SubjectService().get(self.form["subject_ID"]) pk = int(self.form["id"]) newdate = "" if (pk > 0): obj.id = pk obj.examTime = self.form["examTime"] obj.examDate = self.form["examDate"] obj.subject_ID = self.form["subject_ID"] obj.course_ID = self.form["course_ID"] obj.semester = self.form["semester"] obj.courseName = c.courseName obj.subjectName = s.subjectName return obj
def display(self, request, params={}): self.page_list = self.get_service().search(self.form) courseList = CourseService().search(self.form) subject_List = SubjectService().search(self.form) for x in self.page_list: for y in courseList: if x.course_ID == y.id: x.courseName = y.courseName for z in subject_List: if x.subject_ID == z.id: x.subjectName = z.subjectName res = render( request, self.get_template(), { "form": self.form, "courseList": courseList, "subjectList": subject_List, "page_list": self.page_list }) return res
def form_to_model(self, obj): c = CourseService().get(self.form["course_ID"]) e = CollegeService().get(self.form["college_ID"]) s = SubjectService().get(self.form["subject_ID"]) pk = int(self.form["id"]) if (pk > 0): obj.id= pk obj.firstName = self.form["firstName"] obj.lastName = self.form["lastName"] obj.email = self.form["email"] obj.password = self.form["password"] obj.address = self.form["address"] obj.gender = self.form["gender"] obj.dob = self.form["dob"] obj.college_ID = self.form["college_ID"] obj.subject_ID= self.form["subject_ID"] obj.course_ID = self.form["course_ID"] obj.courseName=c.courseName obj.collegeName=e.collegeName obj.subjectName=s.subjectName return obj
def get_service(self): return SubjectService()
def preload(self,request): self.course_List = CourseService().search(self.form) self.college_List = CollegeService().search(self.form) self.subject_List = SubjectService().search(self.form)