def user_list(request): pager = Pagination(request.GET.get('page', '1'), len(userlist), per_num=10, max_show=15) return render(request, 'user_list.html', {"all_user": userlist[pager.start:pager.end], 'page_html': pager.page_html }, )
def get(self, request): # Q查询的第一种写法 # query = request.GET.get('query', '') # q = Q() # q.connector = 'OR' # 连接条件默认是AND # 里面放查询条件 # q.children.append(Q(qq__contains=query)) # 里面放元组 # q.children.append(Q(name__contains=query)) # Q(('qq__contains', query)) Q(qq__contains=query) q = self.search(['qq', 'name']) # 公户 if request.path_info == reverse('customer_list'): public = 1 all_customers = models.Customer.objects.filter(q, consultant__isnull=True) # all_customers = models.Customer.objects.filter(Q(qq__contains=query)|Q(name__contains=query), consultant__isnull=True, ) else: # 私户 public = 0 all_customers = models.Customer.objects.filter(q, consultant=request.account) # 要求传参 Pagination(page, all_count, params, per_num=15, max_show=11), # 此处request.GET.get('page', '1') 获取页码数, 获取不到默认值是1, pager = Pagination(request.GET.get('page', '1'), all_customers.count(), request.GET.copy(), 2) return render(request, 'consultant/customer_list.html', {'all_customers': all_customers[pager.start: pager.end], 'page_html': pager.page_html, 'public': public})
def get(self, request): # query = request.GET.get('query', '') # 'django.http.request.QueryDict' # dic = request.GET # dic._mutable = True # dic['page'] = 1 # print(dic) q = self.search([ 'qq', 'name', ]) if request.path_info == reverse('customer_list'): all_customer = models.Customer.objects.filter( q, consultant__isnull=True, ) else: all_customer = models.Customer.objects.filter( q, consultant=request.user_obj) page = Pagination(request.GET.get('page'), all_customer.count(), request.GET.copy(), 10) return render( request, 'consultant/customer_list.html', { 'all_customer': all_customer[page.start:page.end], 'page_html': page.page_html }, )
def get(self, request, customer_id): q = self.search([]) if customer_id == '0': all_consult = models.ConsultRecord.objects.filter( q, delete_status=False, consultant=request.user_obj).order_by('-date') else: all_consult = models.ConsultRecord.objects.filter( q, delete_status=False, customer_id=customer_id, consultant=request.user_obj).order_by('-date') page = Pagination(request.GET.get('page'), all_consult.count(), request.GET.copy(), 10) return render( request, 'consultant/consult_list.html', { 'all_consult': all_consult[page.start:page.end], 'page_html': page.page_html }, )
def get(self, request): q = self.search([ 'course', ]) all_classes = models.ClassList.objects.filter(q) pager = Pagination(request.GET.get('page', '1'), all_classes.count(), request.GET.copy(), 2) return render(request, 'teacher/class_list.html', { 'all_classes': all_classes, 'page_html': pager.page_html, })
def get(self, request): q = self.search([]) all_class = models.ClassList.objects.filter(q) pager = Pagination(request.GET.get('page', '1'), all_class.count(), request.GET.copy(), 10) return render( request, 'teacher/class_list.html', { 'all_class': all_class[pager.start:pager.end], 'page_html': pager.page_html })
def get(self, request, class_id): q = self.search([]) all_course_record = models.CourseRecord.objects.filter( q, re_class_id=class_id) pager = Pagination(request.GET.get('page', '1'), all_course_record.count(), request.GET.copy()) return render( request, 'teacher/course_record_list.html', { 'all_course_record': all_course_record, 'page_html': pager.page_html, 'class_id': class_id, })
def user(request): pager = Pagination(request.GET.get('page', '1'), len(all_user), per_num=10, max_show=15) return render( request, 'consultant/user.html', { "all_user": all_user[pager.start:pager.end], 'page_html': pager.page_html }, )
def get(self, request): q = self.search([]) all_enrollment = models.Enrollment.objects.filter( q, delete_status=False, customer_id__in=[i.pk for i in request.user_obj.customers.all()]) page = Pagination(request.GET.get('page'), request.GET.copy(), all_enrollment.count(), 10) return render( request, 'enrollment_list.html', { 'all_enrollment': all_enrollment[page.start:page.end], 'page_html': page.page_html })
def get(self, request): q = self.search(['qq', 'name', ]) if request.path_info == reverse('customer_list'): all_customer = models.Customer.objects.filter(q, consultant__isnull=True, ) else: # 私户 all_customer = models.Customer.objects.filter(q, consultant=request.account) pager = Pagination(request.GET.get('page', '1'), all_customer.count(), request.GET.copy(), 10) return render(request, 'consultant/customer_list.html', { 'all_customer': all_customer[pager.start: pager.end], 'page_html': pager.page_html })
def get(self, request): q = self.search(['course', 'teachers__username', 'class_type']) all_class = models.ClassList.objects.filter(q) pager = Pagination(request.GET.get('page', '1'), len(all_class), params=request.GET.copy(), per_num=10, max_show=15) return render( request, 'teacher/class_list.html', { 'all_class': all_class[pager.start:pager.end], 'page_html': pager.page_html, })
def get(self, request): q = self.search(['qq', 'name', ]) # 1. 如果是公户 if request.path_info == reverse('customer_list'): # 1.1 查询出所有 没有销售在跟进的 客户 all_customer = models.Customer.objects.filter(q, consultant__isnull=True, ) # 2. 如果是私户 else: # 2.1 查询出所有 当前用户正在跟进的 客户 all_customer = models.Customer.objects.filter(q, consultant=request.user_obj) # 3. 将需要展示的数据交给分页器 进行分页展示 page = Pagination(request.GET.get('page'), all_customer.count(), request.GET.copy(), 10) # 4. 跳转到 客户展示页面 return render(request, 'consultant/customer_list.html', {'all_customer': all_customer[page.start:page.end], 'page_html': page.page_html}, )
def get(self, request, class_id): q = self.search([]) all_course_record = models.CourseRecord.objects.filter( q, re_class_id=class_id).order_by('-date') page = Pagination(request.GET.get('page'), all_course_record.count(), request.GET.copy(), 10) return render( request, 'teacher/course_record_list.html', { 'class_id': class_id, 'all_course_record': all_course_record[page.start:page.end], 'page_html': page.page_html }, )
def get(self, request, class_id): q = self.search(['date', 'course_title', 'teacher__username']) all_course_record = models.CourseRecord.objects.filter( q, re_class_id=class_id) pager = Pagination(request.GET.get('page', '1'), len(all_course_record), params=request.GET.copy(), per_num=10, max_show=15) return render( request, 'teacher/course_record_list.html', { 'all_course_record': all_course_record[pager.start:pager.end], 'page_html': pager.page_html, 'class_id': class_id, })
def get(self, request): q = self.search(['qq', 'name', 'date']) if request.path_info == reverse('customer_list'): all_customer = models.Customer.objects.filter( q, consultant__isnull=True) else: all_customer = models.Customer.objects.filter( q, consultant=request.account) pager = Pagination(request.GET.get('page', '1'), len(all_customer), params=request.GET.copy(), per_num=10, max_show=15) return render( request, 'consultant/customer_list.html', { 'all_customer': all_customer[pager.start:pager.end], 'page_html': pager.page_html, })