Exemplo n.º 1
0
 def get(self, request, params={}):
     service = CourseService()
     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"]})
Exemplo n.º 2
0
 def delete(self, request, params={}):
     service = CourseService()
     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"]})
Exemplo n.º 3
0
 def save(self,request, params = {}):        
     json_request=json.loads(request.body)     
     r=self.form_to_model(Course(), json_request)
     service=CourseService()
     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})
Exemplo n.º 4
0
 def search(self, request, params={}):
     service = CourseService()
     c = service.search()
     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})
Exemplo n.º 5
0
    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})
Exemplo n.º 6
0
    def search(self, request, params={}):
        json_request = json.loads(request.body)
        if (json_request):
            params["courseName"] = json_request.get("courseName", None)
            params["pageNo"] = json_request.get("pageNo", None)

        service = CourseService()
        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})
Exemplo n.º 7
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(Course(), json_request)
            service = CourseService()
            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})
Exemplo n.º 8
0
 def search(self,request, params = {}):
     json_request=json.loads(request.body)
     if(json_request):
         params["courseName"]=json_request.get("courseName",None)
     service=CourseService()
     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})
Exemplo n.º 9
0
 def form_to_model(self,obj):
     c = CourseService().get(self.form["course_ID"])
     pk = int(self.form["id"])
     if(pk>0):
         obj.id = pk
     obj.subjectName=self.form["subjectName"]
     obj.subjectDescription=self.form["subjectDescription"]       
     obj.course_ID=self.form["course_ID"]        
     obj.courseName=c.courseName
     return obj
Exemplo n.º 10
0
 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})
Exemplo n.º 11
0
 def display(self,request,params={}):
     self.page_list = self.get_service().search(self.form)
     courseList=CourseService().search(self.form)
     
     for x in self.page_list: 
         for y in courseList:
             if x.course_ID==y.id:
                 print("ddddd----------->",x.course_ID==y.id)
                 x.courseName=y.courseName
     res = render(request,self.get_template(),{"pageList":self.page_list})
     return res
Exemplo n.º 12
0
    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
Exemplo n.º 14
0
 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
Exemplo n.º 15
0
    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})
Exemplo n.º 16
0
 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)
Exemplo n.º 17
0
 def get_service(self):
     return CourseService()        
Exemplo n.º 18
0
 def preload(self, request, params={}):
     self.data = CourseService().search(self.form)
     preloadList = []
     for x in self.data:
         preloadList.append(x.to_json())
     return JsonResponse({"preloadList": preloadList})
Exemplo n.º 19
0
 def preload(self,request):
     self.page_list = CourseService().search(self.form)
     self.preload_data=self.page_list