Exemplo n.º 1
0
    def get(self, request):

        # 调用下方的模糊搜索方法
        q = self.get_search_contion(['qq', 'name', 'last_consult_date'])

        if request.path_info == reverse('customer'):
            all_customer = models.Customer.objects.filter(
                q, consultant__isnull=True)
        else:
            all_customer = models.Customer.objects.filter(
                q, consultant=request.user)

        # query_params = copy.deepcopy(request.GET)  # <QueryDict: {'query': ['alex']}>
        query_params = request.GET.copy()  # <QueryDict: {'query': ['alex']}>
        # query=alex
        # print(request.GET.urlencode())

        # query_params['page'] = 1  # <QueryDict: {'query': ['alex'],'page': ['1']}>
        # print(request.GET.urlencode())  # query=alex&page=1
        page = Pagination(request, all_customer.count(), query_params, 2)

        # 生成添加按钮
        add_btn, query_params = self.get_add_btn()

        return render(
            request, 'crm/consultant/customer_list.html', {
                "all_customer": all_customer[page.start:page.end],
                'pagination': page.show_li,
                'add_btn': add_btn,
                'query_params': query_params
            })
Exemplo n.º 2
0
def solicitations(page):
    user_search_terms = request.args.get('search')

    if user_search_terms:
        page = 1

    offset = Pagination.offset(page, SOLICITATIONS_PER_PAGE)
    
    search_terms = '(SBIR OR "small business innovation research" OR STTR OR "small business technology transfer")'
    all_search_terms = ''
    if user_search_terms:
        all_search_terms = ' AND '.join([search_terms, user_search_terms])
    else:
        all_search_terms = search_terms
    print all_search_terms
    
    columns = 'description,title,summary,listing_url,solnbr,office,agency,close_dt,open_dt,posted_dt'
    r = requests.get(FBOPEN_URI, params={'q': all_search_terms, 'fq': 'listing_url:[* TO *]', 'start': offset, 'rows': SOLICITATIONS_PER_PAGE, 'fl': columns, 'api_key': API_KEY})
    print r.request.url

    count = r.json().get('numFound')
    pagination = Pagination(page, SOLICITATIONS_PER_PAGE, count)

    results = _get_results(r)

    no_results_msg = 'No results found' if not len(results) > 0 else ''

    for obj in results:
        _parse_obj_dates(obj, 'close_dt', 'open_dt', 'posted_dt')
        _abbreviate_agency(obj)

    return render_template("solicitations.html", search_terms=user_search_terms, pager=pagination, results=results, no_results_msg=no_results_msg)
Exemplo n.º 3
0
def user_list(request):
    page = Pagination(request, len(users))

    return render(
        request,
        'user_list.html',
        {
            "data": users[page.start:page.end],
            # 'total_num': range(page_start, page_end + 1)
            'html_str': page.show_li
        })
Exemplo n.º 4
0
def tag_get(request, method):
    if method == 'GET':
        bid = request.logged_blog.nid
        data_count = web_models.Tag.objects.filter(blog_id=bid,
                                                   is_delete=False).count()
        if data_count:
            current_pg = request.GET.get('p', 1)
            per_pg_count = 10
            list_count = 3
            p = Pagination(current_pg, data_count, per_pg_count, list_count)
            base_url = "{}?t=get".format(reverse('app-backend:backend-tag'))
            pagination = p.gen_pagination(base_url)

            # 因为在模型类中Article和Tag类的delete方法中同时对中间表处理,因此只需查询中间表是否delete即可
            article_count_dic = dict(
                web_models.ArticleM2MTag.objects.filter(
                    article__blog_id=bid,
                    is_delete=False).values_list('tag_id').annotate(
                        article_count=Count('article_id')))

            tag_lst = web_models.Tag.objects.filter(
                blog_id=bid, is_delete=False).values(
                    'nid', 'title').order_by('-nid')[p.start:p.end]

            for item in tag_lst:
                key = item['nid']
                if key in article_count_dic:
                    item['article_count'] = article_count_dic[key]
                else:
                    item['article_count'] = 0
        else:
            pagination = ""
            tag_lst = []
        return render(request, 'backend_tag.html', {
            'tag_lst': tag_lst,
            'pagination': pagination
        })
    return HttpResponseNotFound("说出来你可能不信,该页面被外星人劫持了^_^")
Exemplo n.º 5
0
def category_get(request, method):
    if method == 'GET':
        bid = request.logged_blog.nid
        data_count = web_models.Category.objects.filter(
            blog_id=bid, is_delete=False).count()
        if data_count:
            current_pg = request.GET.get('p', 1)
            per_pg_count = 10
            list_count = 3
            p = Pagination(current_pg, data_count, per_pg_count, list_count)
            base_url = "{}?t=get".format(
                reverse('app-backend:backend-category'))
            pagination = p.gen_pagination(base_url)

            article_count_dic = dict(
                web_models.Article.objects.filter(
                    blog_id=bid, is_delete=False,
                    category__is_delete=False).values_list(
                        'category_id').annotate(article_count=Count('nid')))

            category_lst = web_models.Category.objects.filter(
                blog_id=bid, is_delete=False).values(
                    'nid', 'title').order_by('-nid')[p.start:p.end]

            for item in category_lst:
                key = item['nid']
                if key in article_count_dic:
                    item['article_count'] = article_count_dic[key]
                else:
                    item['article_count'] = 0
        else:
            pagination = ""
            category_lst = []
        return render(request, 'backend_category.html', {
            'category_lst': category_lst,
            'pagination': pagination
        })
    return HttpResponseNotFound("说出来你可能不信,该页面被外星人劫持了^_^")
Exemplo n.º 6
0
def article_get(request, method):
    if method == "GET":
        bid = request.logged_blog.nid
        data_count = web_models.Article.objects.filter(
            blog_id=bid, is_delete=False).count()
        if data_count:
            current_pg = request.GET.get('p', 1)
            per_pg_count = 10
            list_count = 3
            p = Pagination(current_pg, data_count, per_pg_count, list_count)
            pagination = p.gen_pagination("{}?t=get".format(
                reverse('app-backend:backend-article')))
            article_lst = web_models.Article.objects.filter(
                blog_id=bid, is_delete=False).order_by('-nid')[p.start:p.end]
        else:
            pagination = ""
            article_lst = []
        return render(request, 'backend_article.html', {
            'article_lst': article_lst,
            'pagination': pagination
        })
    else:
        return HttpResponseNotFound("说出来你可能不信,该页面被外星人劫持了^_^")
Exemplo n.º 7
0
    def get(self, request):
        # 模糊搜索
        q = self.get_search_contion(['course', 'semester'])

        all_class = models.ClassList.objects.filter(q)

        # 获取路径
        query_params = self.get_query_params()

        # 分页的应用
        page = Pagination(request, len(all_class), request.GET.copy())

        return render(
            request, 'crm/teacher/class_list.html', {
                "all_class": all_class[page.start:page.end],
                'pagination': page.show_li,
                'query_params': query_params
            })
Exemplo n.º 8
0
def customer_list(request):
    """
    展示客户列表
    :param request:
    :return:
    """
    # 拿客户数据
    if request.path_info == reverse('customer'):
        all_customer = models.Customer.objects.filter(consultant__isnull=True)
    else:
        all_customer = models.Customer.objects.filter(consultant=request.user)

    page = Pagination(request, all_customer.count())

    return render(
        request, 'crm/consultant/customer_list.html', {
            "all_customer": all_customer[page.start:page.end],
            'pagination': page.show_li
        })
Exemplo n.º 9
0
    def get(self, request, class_id):
        # 模糊搜索
        q = self.get_search_contion([])

        all_course = models.CourseRecord.objects.filter(q,
                                                        re_class_id=class_id)

        # 获取路径
        query_params = self.get_query_params()

        # 分页的应用
        page = Pagination(request, len(all_course), request.GET.copy())

        return render(
            request, 'crm/teacher/course_list.html', {
                "all_course": all_course[page.start:page.end],
                'pagination': page.show_li,
                'query_params': query_params,
                'class_id': class_id
            })
Exemplo n.º 10
0
Arquivo: news.py Projeto: jie/homegate
 def fetchByShowcasePage(cls, showcase, page, limit=10):
     records = cls.select(lambda r: r.showcase == showcase).order_by(
         lambda r: pony.orm.desc(r.create_at))
     pagination = Pagination(page, limit, records)
     return pagination
Exemplo n.º 11
0
 def fetchReplies(cls, news_id, page=1, limit=20, **kwargs):
     records = cls.select(lambda r: r.news.id == int(news_id)).order_by(
         lambda r: pony.orm.desc(r.create_at))
     pagination = Pagination(page, limit, records)
     return pagination