def add_mess_committee(request, roll_number): print("\n\n\\n\n\n\n\n") print(roll_number) mess = Messinfo.objects.get(student_id__id=roll_number) print(mess) if mess.mess_option == 'mess1': designation = Designation.objects.get(name='mess_committee_mess1') else: designation = Designation.objects.get(name='mess_committee_mess2') # designation = Designation.objects.get(name='mess_committee') add_obj = HoldsDesignation.objects.filter( Q(user__username=roll_number) & Q(designation=designation)) if add_obj: data = { 'status': 2, 'message': roll_number + " is already a part of mess committee" } return data else: add_user = User.objects.get(username=roll_number) designation_object = HoldsDesignation(user=add_user, working=add_user, designation=designation) designation_object.save() data = { 'status': 1, 'message': roll_number + " is added to Mess Committee" } return data
def senator(request): """ to add a new student senator @param: request - contains metadata about the requested page @variables: current_user - gets the data of current user. user_details - gets the details of the required user. desig_id - used to check the designation ID. extraInfo - extraInfo object of the student with that rollno s - designation object of senator hDes - holdsDesignation object to store that the particualr student is holding the senator designation student - the student object of the new senator data - data of the student to be displayed in teh webpage """ current_user = get_object_or_404(User, username=request.user.username) user_details = ExtraInfo.objects.all().filter(user=current_user).first() desig_id = Designation.objects.all().filter(name='Upper Division Clerk') temp = HoldsDesignation.objects.all().filter(designation=desig_id).first() print(temp) print(current_user) acadadmin = temp.working k = str(user_details).split() print(k) final_user = k[2] if (str(acadadmin) != str(final_user)): return HttpResponseRedirect('/academic-procedures/') if request.method == 'POST': print(request.POST, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") rollno = request.POST.getlist('Roll Number')[0] # print(request.POST.get('rollno')) extraInfo = ExtraInfo.objects.get(id=rollno) s = Designation.objects.get(name='Senator') hDes = HoldsDesignation() hDes.user = extraInfo.user hDes.working = extraInfo.user hDes.designation = s hDes.save() student = Student.objects.get(id=extraInfo) data = { 'name': extraInfo.user.username, 'rollno': extraInfo.id, 'programme': student.programme, 'branch': extraInfo.department.name } return HttpResponseRedirect('/aims/') # return JsonResponse(data) else: return HttpResponseRedirect('/aims/')
def fillHoldsDesignation(self): for i in range(1, self.row + 1): try: user = User.objects.get( username=str(int(self.sheet.cell(i, 1).value))) add = HoldsDesignation() add.user = user add.working = user add.designation = Designation.objects.get(name='student') add.save() print('saved') except BaseException: print(user.username, 'unsucessful')
def add_convenor(request): """ to add a new student convenor/coconvenor @param: request - contains metadata about the requested page @variables: rollno - rollno of the student to become the convenor/coconvenor extraInfo - extraInfo object of the student with that rollno s - designation object of Convenor p - designation object of Co Convenor result - the data that contains where the student will become convenor or coconvenor hDes - holdsDesignation object to store that the particualr student is holding the convenor/coconvenor designation student - the student object of the new convenor/coconvenor data - data of the student to be displayed in the webpage """ s = Designation.objects.get(name='Convenor') p = Designation.objects.get(name='Co Convenor') if request.method == 'POST': rollno = request.POST.get('rollno_convenor') extraInfo = ExtraInfo.objects.get(id=rollno) s = Designation.objects.get(name='Convenor') p = Designation.objects.get(name='Co Convenor') result = request.POST.get('designation') hDes = HoldsDesignation() hDes.user = extraInfo.user hDes.working = extraInfo.user if result == "Convenor": hDes.designation = s else: hDes.designation = p hDes.save() data = { 'name': extraInfo.user.username, 'rollno_convenor': extraInfo.id, 'designation': hDes.designation.name, } return JsonResponse(data) else: data = {} return JsonResponse(data)
def add_convenor(request): if request.method == 'POST': rollno = request.POST.get('rollno_convenor') extraInfo = ExtraInfo.objects.get(id=rollno) s = Designation.objects.get(name='Convenor') p = Designation.objects.get(name='Co Convenor') result = request.POST.get('designation') hDes = HoldsDesignation() hDes.user = extraInfo.user hDes.working = extraInfo.user if result == "Convenor": hDes.designation = s else: hDes.designation = p hDes.save() data = { 'name': extraInfo.user.username, 'rollno_convenor': extraInfo.id, 'designation': hDes.designation.name, } return JsonResponse(data) else: data = {} return JsonResponse(data)
def senator(request): if request.method == 'POST': rollno = request.POST.get('rollno') extraInfo = ExtraInfo.objects.get(id=rollno) s = Designation.objects.get(name='senate') hDes = HoldsDesignation() hDes.user = extraInfo.user hDes.working = extraInfo.user hDes.designation = s hDes.save() student = Student.objects.get(id=extraInfo) data = { 'name': extraInfo.user.username, 'rollno': extraInfo.id, 'programme': student.programme, 'branch': extraInfo.department.name } return JsonResponse(data) else: data = {} return JsonResponse(data)