コード例 #1
0
ファイル: views.py プロジェクト: xqd0924/crm
    def get(self, request):
        if reverse('customer_list') == request.path:
            label = "公户列表"
            customer_list = models.Customer.objects.filter(
                consultant__isnull=True).all()
        elif reverse('mycustomers') == request.path:
            label = "我的客户"
            customer_list = models.Customer.objects.filter(
                consultant=request.user).all()

        val = request.GET.get('q')
        field = request.GET.get('field')
        if val:
            q = Q()
            q.children.append((field + '__contains', val))
            customer_list = customer_list.filter(q)
        current_page_num = request.GET.get('page', 1)
        pagination = Pagination(current_page_num, customer_list.count(),
                                request)
        customer_list = customer_list[pagination.start:pagination.end]

        path = request.path
        next = "?next=%s" % path
        return render(
            request, 'customer_list.html', {
                'next': next,
                'customer_list': customer_list,
                'pagination': pagination,
                'label': label
            })
コード例 #2
0
ファイル: views.py プロジェクト: wliustc/Darily
    def get(self, request):
        if reverse("customer_table") == request.path:
            label = 'Publish Customer List'
            customer_list = Customer.objects.filter(consultant__isnull=True)
        else:
            label = 'My Customer List'
            customer_list = Customer.objects.filter(consultant=request.user)

        # 搜索
        val = request.GET.get('q')  # 获取搜索条件
        field = request.GET.get('field')  # 获取搜索范围
        if val:
            q = Q()
            q.children.append((field + "__contains", val))  # 注意必须是元组
            customer_list = customer_list.filter(q)

        # 分页 注意分页应用了切片,但是一旦切片就不能再filter
        current_page_num = request.GET.get("page")
        pagination = Pagination(current_page_num,
                                customer_list.count(),
                                request,
                                per_page_num=5)
        customer_list = customer_list[pagination.start:pagination.end]

        # 返回请求路径的获取
        path = request.path
        next_path = "?next=%s" % path

        return render(
            request, 'customer/site_customer_table.html', {
                "customer_list": customer_list,
                "pagination": pagination,
                'next_path': next_path,
                'label': label
            })
コード例 #3
0
ファイル: views.py プロジェクト: wanglili0512/CRM
    def get(self, request):

        user_id = request.session["user_id"]  # 拿到当前登录人id,即rbac用户表中的用户id
        userinfo_obj = UserInfo.objects.filter(
            user_rbac_id=user_id).first()  # 根据rbac的用户查询出app01的用户对象
        consult_record_list = ConsultRecord.objects.filter(
            consultant=userinfo_obj)  # 根据app01中的用户对象查询对应销售是该用户的跟进记录

        # 当用户url中含有参数customer_id=2的时候,说明是从用户列表中点击跟进详情链接进入的,则从上面该销售人的跟进记录中进一步筛选跟进记录
        customer_id = request.GET.get("customer_id")
        if customer_id:
            consult_record_list = consult_record_list.filter(
                customer_id=customer_id)

        # 分页
        current_page_num = request.GET.get("page")
        pagination = Pagination(current_page_num, consult_record_list.count(),
                                request)
        consult_record_list = consult_record_list[pagination.start:pagination.
                                                  end]

        return render(request, "customer/consultrecord.html", {
            "consult_record_list": consult_record_list,
            "pagination": pagination
        })
コード例 #4
0
    def get(self,request):
        if reverse("customers_list") == request.path:
            label="公户列表"
            customer_list = Customer.objects.filter(consultant__isnull=True)
        else:
            label = "我的客户"
            customer_list = Customer.objects.filter(consultant=request.user)

            # search过滤
        val = request.GET.get("q")
        field = request.GET.get("field")
        if val:
            q = Q()
            q.children.append((field + "__contains", val))
            customer_list = customer_list.filter(q)

            # customer_list=customer_list.filter(Q(name__contains=val)|Q(qq__contains=val))

        # 分页
        current_page_num = request.GET.get("page")
        pagination = Pagination(current_page_num, customer_list.count(), request)

        customer_list = customer_list[pagination.start:pagination.end]

        #
        path=request.path
        next="?next=%s"%path

        return render(request, "customer_list.html", {"next":next,"label":label,"customer_list": customer_list, "pagination": pagination})
コード例 #5
0
ファイル: views.py プロジェクト: simplesmall/Python-FullStack
def customers(request):

    if reverse("customers_list") == request.path:
        customer_list = Customer.objects.all()
    else:
        customer_list = Customer.objects.filter(consultant=request.user)

    # search过滤
    val = request.GET.get("q")
    filter_field = "name"
    if val:
        q = Q()
        q.children.append()

        customer_list = customer_list.filter(filter_field=val)

        #customer_list=customer_list.filter(Q(name__contains=val)|Q(qq__contains=val))

    # 分页
    current_page_num = request.GET.get("page")
    pagination = Pagination(current_page_num, customer_list.count(), request)

    customer_list = customer_list[pagination.start:pagination.end]

    return render(request, "customer_list.html", {
        "customer_list": customer_list,
        "pagination": pagination
    })
コード例 #6
0
ファイル: views.py プロジェクト: loveguan/page_demo
def index(request):
    '''
    book_list=[]
    for i  in range(500):
        book_obj=Book(title="book_%s"%i,price=i*i)
        book_list.append(book_obj)
    Book.objects.bulk_create(book_list)
    '''
    current_page = request.GET.get("page", 1)

    all_count = Book.objects.all().count()
    base_url = request.path  # /index/
    from app01.utils.page import Pagination

    pagination = Pagination(all_count,
                            int(current_page),
                            base_url,
                            request.GET,
                            per_page=10,
                            max_show=11)

    print(pagination.start)
    print(pagination.end)
    book_list = Book.objects.all()[pagination.start:pagination.end]
    print(request.GET)
    # import copy
    # params = copy.deepcopy(request.GET)
    # params["xxx"] = 123
    # params['2222']=222
    # print(params)
    return render(request, 'index.html', locals())
コード例 #7
0
def get_page(request, article_list):
    current_page = int(request.GET.get("page", 1))
    data_count = article_list.count()
    base_path = request.path

    pagination = Pagination(current_page,
                            data_count,
                            base_path,
                            request.GET,
                            per_page_num=10,
                            pager_count=9)
    article_list = article_list[pagination.start:pagination.end]
    return pagination, article_list
コード例 #8
0
ファイル: views.py プロジェクト: wanglili0512/CRM
    def get(self, request):
        ss_record_list = StudentStudyRecord.objects.all()

        # 分页
        current_page_num = request.GET.get("page")
        pagination = Pagination(current_page_num, ss_record_list.count(),
                                request)
        ss_record_list = ss_record_list[pagination.start:pagination.end]

        return render(request, 'student/ss_record_list.html', {
            "ss_record_list": ss_record_list,
            "pagination": pagination
        })
コード例 #9
0
ファイル: views.py プロジェクト: wanglili0512/CRM
    def get(self, request):
        enrollment_list = Enrollment.objects.all()

        # 分页
        current_page_num = request.GET.get("page")
        pagination = Pagination(current_page_num, enrollment_list.count(),
                                request)
        enrollment_list = enrollment_list[pagination.start:pagination.end]

        return render(request, "customer/enrollment_list.html", {
            "enrollment_list": enrollment_list,
            "pagination": pagination
        })
コード例 #10
0
ファイル: views.py プロジェクト: CH-chen/vail_admin_01_15
def users(request, num=3):
    current_page = request.GET.get("page", 1)
    all_count = models.UserInfo.objects.all().count()
    base_url = request.path
    pagination = Pagination(all_count,
                            int(current_page),
                            base_url,
                            request.GET,
                            per_page=int(num),
                            max_show=6)
    user_list = models.UserInfo.objects.all()[pagination.start:pagination.end]
    import copy
    params = copy.deepcopy(request.GET)
    return render(request, "x-admin/member-list.html", locals())
コード例 #11
0
ファイル: views.py プロジェクト: sun1613/oldboy
def index(request):
    current_page = request.GET.get("page", 1)
    all_count = Book.objects.all().count()
    base_url = request.path

    pagination = Pagination(all_count,
                            current_page,
                            base_url,
                            request.GET,
                            per_page=1,
                            max_show=3)

    # print(pagination.start)
    # print(pagination.end)

    book_list = Book.objects.all()[pagination.start:pagination.end]
    # book_list = Book.objects.all()

    return render(request, "index.html", locals())
コード例 #12
0
ファイル: views.py プロジェクト: wanglili0512/CRM
    def get(self, request):  # get请求
        if reverse("all_customers") == request.path:
            head_text = "所有客户"
            customer_list = Customer.objects.all()
        elif reverse("customers_list") == request.path:
            head_text = "公户列表"
            customer_list = Customer.objects.filter(
                consultant__isnull=True)  # 注意:判断一个字段是不是为空,一定不能写consultant=""
        else:
            head_text = "我的客户"
            user_id = request.session["user_id"]
            userinfo_obj = UserInfo.objects.filter(
                user_rbac_id=user_id).first()
            customer_list = Customer.objects.filter(consultant=userinfo_obj)

        # search过滤
        field = request.GET.get('field')  # 搜索字段
        val = request.GET.get("q")  # 搜索关键字
        if val:
            q = Q()  # Q实例化,Q继承了tree.Node类,Node类有children属性,是一个列表,append条件
            q.children.append(
                (field + "__contains",
                 val))  # q.children.append(('name_contains', 'wang'))
            customer_list = customer_list.filter(
                q)  # 按照上面的条件过滤(name__contains=wang)

        # 分页
        current_page_num = request.GET.get("page")  # 取出用户发送的"页码数"
        pagination = Pagination(current_page_num, customer_list.count(),
                                request)  # 调用分页器组件
        customer_list = customer_list[pagination.start:pagination.end]

        path = request.path  # 当前请求路径
        next = "?next=%s" % path  # 封装当前请求路径为url中的参数,与next组成键值对,传到页面
        # 因为公户列表,所有客户,我的客户中都有添加客户的按钮,添加成功后要自动跳转到进入之前的页面,所以加next参数来标识

        return render(
            request, "customer/customer_list.html", {
                "next": next,
                "head_text": head_text,
                "customer_list": customer_list,
                "pagination": pagination
            })
コード例 #13
0
def index(request):
    '''
    book_list=[]
    for  i in range(500):
        book_obj=Book(title="book_%s"%i,price=i*i)
        book_list.append(book_obj)
    Book.objects.bulk_create(book_list)

    :param request:
    :return:
    '''

    current_page = request.GET.get("page", 1)

    all_count = Book.objects.all().count()
    base_url = request.path  # /index/
    from app01.utils.page import Pagination

    pagination = Pagination(all_count,
                            int(current_page),
                            base_url,
                            request.GET,
                            per_page=10,
                            max_show=11)

    print(pagination.start)
    print(pagination.end)

    book_list = Book.objects.all()[pagination.start:pagination.end]

    from django.http.request import QueryDict
    # dic = QueryDict(mutable=True)
    # dic["info"] = 123

    # print(type(request.GET))
    # request.GET["info"]=123

    import copy
    params = copy.deepcopy(request.GET)
    params["xxx"] = 123

    return render(request, "index.html", locals())
コード例 #14
0
ファイル: views.py プロジェクト: duanyaozong/crm
    def get(self, request):
        if reverse('customers_public') == request.path:
            label = "公户列表"
            customer_list = Customer.objects.filter(
                consultant__isnull=True)  # 没有销售
        elif reverse('customers_list') == request.path:
            label = '全部客户'
            customer_list = Customer.objects.all()
        else:
            label = "我的客户"
            customer_list = Customer.objects.filter(consultant=request.user)

        # search过滤
        val = request.GET.get("q")
        select = request.GET.get('select')
        # filter_field = "name"
        if val:
            q = Q()
            q.connector = 'or'
            q.children.append((select + '__contains', val))

            customer_list = customer_list.filter(q)

            # customer_list=customer_list.filter(Q(name__contains=val)|Q(qq__contains=val))

        # 分页
        current_page_num = request.GET.get("page")
        pagination = Pagination(current_page_num, customer_list.count(),
                                request)

        customer_list = customer_list[pagination.start:pagination.end]

        path = request.path
        next = "?next=%s" % path

        return render(
            request, "customer/customer_list.html", {
                "customer_list": customer_list,
                "pagination": pagination,
                'label': label,
                'next': next
            })
コード例 #15
0
    def get(self, request):

        if reverse("customers_list") == request.path:
            label = "全部客户"
            # from django.utils.functional import SimpleLazyObject
            #
            # if (isinstance(request.user, SimpleLazyObject)) and str(request.user) == 'lyq':
            # customers_list = Customer.objects.all()
            # else:

            customers_list = Customer.objects.filter(consultant__isnull=True)

        else:
            label = "我的客户"
            customers_list = Customer.objects.filter(consultant=request.user)

            # search过滤
        val = request.GET.get('val')
        file = request.GET.get('file')
        if val:
            ret = Q()
            ret.children.append((file + "__contains", val))
            customers_list = customers_list.filter(ret)
            # customers_list=customers_list.filter(Q(name__contains=val)|Q(qq__contains=val)|Q(phone__contains=val))

        current_page_num = request.GET.get("page")
        pagination = Pagination(current_page_num,
                                customers_list.count(),
                                request,
                                per_page_num=10)
        customers_list = customers_list[pagination.start:pagination.end]

        path = request.path

        next = "?next=%s" % (path)

        return render(request, "customers_list.html", locals())
コード例 #16
0
def customers(request):
    print(copy.deepcopy(request.GET))
    if reverse("customers_list") == request.path:
        customers_list = Customer.objects.all()
    else:
        customers_list = Customer.objects.filter(consultant=request.user)

    #search过滤
    val = request.GET.get('val')
    file = request.GET.get('file')
    if val:
        ret = Q()
        ret.children.append((file + "__contains", val))
        customers_list = customers_list.filter(ret)
        # customers_list=customers_list.filter(Q(name__contains=val)|Q(qq__contains=val)|Q(phone__contains=val))

    current_page_num = request.GET.get("page")
    pagination = Pagination(current_page_num,
                            customers_list.count(),
                            request,
                            per_page_num=10)
    customers_list = customers_list[pagination.start:pagination.end]

    return render(request, "customers_list.html", locals())