Exemplo n.º 1
0
 def get(self, request):
     if authenticateuser.checkauth(request.META['HTTP_AUTHORIZATION'].__str__(),authenticateuser.defaulttoken)==1:
         college = College.objects.all()
         serializer = CollegeSerializer(college, many=True)
         return Response(serializer.data)
     else:
         pass
Exemplo n.º 2
0
 def get(self, request):
     print(request.GET)
     if authenticateuser.checkauth(request.META['HTTP_AUTHORIZATION'].__str__(),authenticateuser.defaulttoken)==1:
         student = Student.objects.filter(studentemailid=request.GET['email'])
         serializer = StudentSerializer(student, many=True)
         return Response(serializer.data)
     else:
         pass
Exemplo n.º 3
0
 def post(self, request, format=None):
     if authenticateuser.checkauth(request.META['HTTP_AUTHORIZATION'].__str__(),authenticateuser.defaulttoken)==1:
         serializer = StateSerializer(data=request.data)
         if serializer.is_valid():
             serializer.save()
             return Response(serializer.data, status=status.HTTP_201_CREATED)
         else:
             return Response(
                 serializer.errors, status=status.HTTP_400_BAD_REQUEST
             )
     else:
         pass
Exemplo n.º 4
0
 def post(self, request, format=None):
     print(request.POST)
     if authenticateuser.checkauth(request.META['HTTP_AUTHORIZATION'].__str__(),authenticateuser.defaulttoken)==1:
         serializer = StudentSerializer(data=request.data)
         print(serializer)
         status="fail" ## response for student add
         if serializer.is_valid():
             print(serializer)
             serializer.save()
             p={
                 "status":"pass"
             }
             return JsonResponse(p)
         else:
             p = {
                 "status": "fail"
             }
             return JsonResponse(p)
     else:
         pass
Exemplo n.º 5
0
    def post(self, request, format=None):
        if authenticateuser.checkauth(
                request.META['HTTP_AUTHORIZATION'].__str__(),
                authenticateuser.defaulttoken) == 1:
            roll = request.POST['studentrollno']

            choices = [
                request.POST['choice1'], request.POST['choice2'],
                request.POST['choice3'], request.POST['choice4'],
                request.POST['choice5'], request.POST['choice6'],
                request.POST['choice7'], request.POST['choice8'],
                request.POST['choice9'], request.POST['choice10']
            ]
            allocationtype = request.GET['randomallocation']

            status = allocate(choices, roll, allocationtype)
            if status != "null":
                return JsonResponse({"status": status})
            else:
                return JsonResponse({"status": status})
Exemplo n.º 6
0
    def get(self, request):
        if authenticateuser.checkauth(
                request.META['HTTP_AUTHORIZATION'].__str__(),
                authenticateuser.defaulttoken) == 1:
            roll = request.GET['studentrollno']
            obj = FinalAllocatedList.objects.filter(studentrollno=roll)

            if obj.count() != 0:
                cv = obj.values('roomallocated')
                val = cv.first()
                val['studentrollno'] = roll
                # room=val['roomallocated']
                # print(room)
                # p = {
                #     "rollno": "null"
                #
                # }
                # print(p)
                return JsonResponse(val)
            else:
                return JsonResponse({
                    "studentrollno": roll,
                    "roomallocated": "None"
                })