def userfilter(request): form = StudentFilter() person = Person.objects.get(pk = request.session['personpk']) if person.role_id == 1: object_list = Person.objects.all().order_by('facility').order_by('verified') else: object_list = Person.objects.filter(facility_id=person.facility_id) if request.session['ulname'] != 'all': if person.role_id == 1: object_list = Person.objects.filter(lname__icontains=request.session['ulname']) else: object_list = Person.objects.filter(facility_id = person.facility_id).filter(lname__icontains=request.session['ulname']) if request.method=='POST': form = StudentFilter(request.POST) if form.is_valid(): if form.cleaned_data['lname'] is None: request.session['ulname'] = 'all' else: request.session['ulname'] = form.cleaned_data['lname'] return HttpResponseRedirect(reverse('register:userlist')) paginator = Paginator(object_list, 10) page = request.GET.get('page') try: staff = paginator.page(page) except PageNotAnInteger: staff = paginator.page(1) except EmptyPage: staff = paginator.page(paginator.num_pages) return render(request, 'register/person_list.html', {'object_list':staff,'form':form,})
def userfilter(request): form = StudentFilter() person = Person.objects.get(pk=request.session['personpk']) if person.role_id == 1: object_list = Person.objects.all().order_by('facility').order_by( 'verified') else: object_list = Person.objects.filter(facility_id=person.facility_id) if request.session['ulname'] != 'all': if person.role_id == 1: object_list = Person.objects.filter( lname__icontains=request.session['ulname']) else: object_list = Person.objects.filter( facility_id=person.facility_id).filter( lname__icontains=request.session['ulname']) if request.method == 'POST': form = StudentFilter(request.POST) if form.is_valid(): if form.cleaned_data['lname'] is None: request.session['ulname'] = 'all' else: request.session['ulname'] = form.cleaned_data['lname'] return HttpResponseRedirect(reverse('register:userlist')) paginator = Paginator(object_list, 10) page = request.GET.get('page') try: staff = paginator.page(page) except PageNotAnInteger: staff = paginator.page(1) except EmptyPage: staff = paginator.page(paginator.num_pages) return render(request, 'register/person_list.html', { 'object_list': staff, 'form': form, })
def userfilter(request): form = StudentFilter() person = Person.objects.get(pk = request.session['personpk']) if person.role_id == 1: object_list = Person.objects.all().order_by('facility').order_by('verified') else: object_list = Person.objects.filter(facility_id=person.facility_id) if request.session['ulname'] != 'all': if person.role_id == 1: object_list = Person.objects.filter(lname__icontains=request.session['ulname']) else: object_list = Person.objects.filter(facility_id = person.facility_id).filter(lname__icontains=request.session['ulname']) if request.method=='POST': form = StudentFilter(request.POST) if form.is_valid(): if form.cleaned_data['lname'] is None: request.session['ulname'] = 'all' else: request.session['ulname'] = form.cleaned_data['lname'] return HttpResponseRedirect(reverse('register:userlist')) return render(request, 'register/person_list.html', {'object_list':object_list,'form':form,})