Exemplo n.º 1
0
def pass_change(request):

    if request.method == 'POST':
        if (hf.student_check(request.user) or
            hf.instructor_check(request.user) or
            hf.registrar_check(request.user) or
            hf.dean_check(request.user)):

            pass_form  =  form.Password_change_Form(request.POST)
            previous_password  =  request.POST.get('previousPassword')

            # confirm  =  request.POST.get('confirm_password')
            user_password  =  request.POST.get('password')
            user_confirmed_password  =  request.POST.get('confirm_password')

            if(pass_form.is_valid()):
                if(hf.check_previous_password(previous_password,request.user)):
                    if(hf.change_user_password(request.user,user_password,user_confirmed_password)):
                        password_change_dict['pass_message'] = "Password Change"
                    else:
                        password_change_dict['pass_message'] = "Password and confirmed password does not match"
                else:
                    password_change_dict['pass_message'] = "Previous Password does not match"
            else:
                password_change_dict['pass_message'] = "Form is not valid"

            return render(request,'password_change.html',password_change_dict)
        else:
            error_message = {'error_message':"Password Form can't be open"}

            return render(request,'error_message.html',error_message)
    else:
        return render(request,'password_change.html',password_change_dict)
Exemplo n.º 2
0
    def get_context_data(self, **kwargs):
        context  =  super(IndexPage, self).get_context_data(**kwargs)

        # Check are kept based on the type login.
        if hf.student_check(self.request.user):
            IndexPage.template_name  =  'student/student_index.html'
        elif hf.hod_check(self.request.user):
            IndexPage.template_name  =  'instructor/hod_index.html'
        elif hf.instructor_check(self.request.user):
            # Sending the file list to instructor and
            # display file name and reseaon of file which are rejected.
            user_obj  =  get_object_or_404(get_user_model(), email  =  self.request.user)
            context['instructor_file_list']  =  TempFile.objects.filter(
            instructor__user  =  user_obj)
            IndexPage.template_name  =  'instructor/instructor_index.html'
        elif hf.registrar_check(self.request.user):
            IndexPage.template_name  =  'registrar/index.html'
        elif hf.dean_check(self.request.user):
            IndexPage.template_name  =  'dean/index.html'
        else:
            IndexPage.template_name = 'error.html'
            context['error_message']  =  "You have not login. Please login to proceed further"
            logout(self.request)

        return context
Exemplo n.º 3
0
def rejected_marks_file(request):
    if request.method == 'POST':
        file_name  =  request.POST.get('get_file_name')
        try:
            tt  =  TempFile.objects.get(file_name  =  file_name,file_rejected  =  False)
            root_file  =  os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
            file_dir  =  os.path.join(root_file,'media',str(tt.file_path))
            rejected_file_name  =  hf.random_name()+"_"+str(file_name)
            rejected_dir  =  os.path.join(root_file,'media','rejected',rejected_file_name)
            os.rename(file_dir,rejected_dir)
            if(hf.registrar_check(request.user)):
                tt.file_status = "File Rejected by Registrar"
            elif(hf.hod_check(request.user)):
                tt.file_status = "File Rejected by HOD"
            elif(hf.dean_check(request.user)):
                tt.file_status = "File Rejected by Dean"
            tt.file_rejected  =  True
            tt.file_path  =  os.path.join('rejected',file_name)
            tt.save()
            return redirect('view_file_upload')
        except Exception as e:
            print(e)
            return render(request,'error.html',{'error_message':"File is alredy exists in approved folder"})
    else:
        logout(request)
        return render(request,'error.html',{'error_message':"You are trying to access unoffical things"})
Exemplo n.º 4
0
    def get_context_data(self, **kwargs):
        context  =  super(View_Uploaded_File, self).get_context_data(**kwargs)
        # print(self.request.user)
        d_name  =  Department.objects.filter(instructor__user  =  self.request.user).values('Department_name')

        try:
            TempFile.objects.filter(file_name = '').delete()
        except Exception as e:
            # print(e)
            pass

        if hf.instructor_check(self.request.user) and hf.hod_check(self.request.user):
            context['upload_file_list']  =  TempFile.objects.filter(instructor__instructor_department =
                            (Department.objects.get(Department_name  =  str(
                                d_name[0]['Department_name'])
                                ))).order_by('-created')

            context['department_name']  = str(d_name[0]['Department_name'])

            context['reject_reason_form'] = View_Uploaded_File.reject_reason_form

            View_Uploaded_File.template_name = 'instructor/hod_view_file.html'
            # print(str(self.request.user)+" (HOD) viewed uploaded file")

        elif hf.instructor_check(self.request.user):
            # print("In instructor only")
            user_obj  =  get_object_or_404(get_user_model(), email  =  self.request.user)
            context['upload_file_list'] = TempFile.objects.filter(instructor__user =  user_obj).order_by('-created')
            # print(TempFile.objects.filter(instructor__user =  user_obj))
            context['department_name']  = str(d_name[0]['Department_name'])
            View_Uploaded_File.template_name = 'instructor/instructor_view_uploaded_file.html'
            # print(str(self.request.user) +" (Instructor) viewed uploaded file")

        elif hf.registrar_check(self.request.user):
            print("Only registrar")
            context['upload_file_list'] = TempFile.objects.all().order_by('-created')
            # .order_by('file_time_stamp'.desc()).
            # print(TempFile.objects.all())

            context['reject_reason_form'] = View_Uploaded_File.reject_reason_form

            View_Uploaded_File.template_name = 'registrar/registrar_view_file.html'
            # print(str(self.request.user)+" (Registrar) viewed uploaded file")

        elif hf.dean_check(self.request.user):
            context['upload_file_list'] = TempFile.objects.all().order_by('-created')

            context['reject_reason_form'] = View_Uploaded_File.reject_reason_form

            View_Uploaded_File.template_name = 'dean/dean_view_file.html'
            # print(str(self.request.user)+" (Dean) viewed uploaded file")

        else:
            View_Uploaded_File.template_name = 'error.html'
            context['error_message']  =  "Your are not Authorized to login in. To access this page please login."
            logout(self.request)

        return context
Exemplo n.º 5
0
def reject_marks_reason(request):
    if request.method == 'POST':
        file_name  =  request.POST.get('get_file_name')
        file_reject_message  =  request.POST.get('reject_message')
        print(file_reject_message, "   ",type(file_reject_message))
        try:
            tt  =  TempFile.objects.get(pk  =  file_name)
            if(hf.registrar_check(request.user)):
                tt.file_status = "Registrar: "+file_reject_message
            elif(hf.hod_check(request.user)):
                tt.file_status = ("HOD: "+str(file_reject_message))
            elif(hf.dean_check(request.user)):
                tt.file_status = "Dean: "+file_reject_message
            tt.file_rejected_reason  =  True
            tt.save()
            return redirect('view_file_upload')
        except Exception as e:
            print(e)
            return render(request,'error.html',{'error_message':"File is alredy exists in approvedddd folder"})
    else:
        logout(request)
        return render(request,'error.html',{'error_message':"You are trying to access unoffical things"})