Exemple #1
0
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')
Exemple #3
0
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)
Exemple #4
0
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)
Exemple #5
0
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)