当前位置: 首页>>代码示例>>Python>>正文


Python shortcuts.paginate函数代码示例

本文整理汇总了Python中utils.shortcuts.paginate函数的典型用法代码示例。如果您正苦于以下问题:Python paginate函数的具体用法?Python paginate怎么用?Python paginate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了paginate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: questanswer

def questanswer(request, page=None):
    context = RequestContext(request)
    context['title'] = u'Вопрос-ответ'
    if request.method == 'POST':
        context['author_error'] = False
        context['mes_error'] = False

        if not request.POST.get('q_autor', ''):
            context['author_error'] = True
        else:
            context['q_autor'] = request.POST['q_autor']
        
        if not request.POST.get('q_mes', ''):
            context['mes_error'] = True
        else:
            context['q_mes'] = request.POST['q_mes']
        
        if context['author_error'] or context['mes_error']:
            pass
        else:
            qa = QuestAnswer(author = context['q_autor'], question = context['q_mes'])
            qa.save()
            context['ok'] = True
    context['unanswered'] = QuestAnswer.objects.order_by('-date_publication').filter(is_public=False)
    context['tags'] = TagName.objects.all()
    context['alphabet'] = Alphabet.objects.filter(is_action=True).order_by('letter')
    paginate(
        context, 'questanswer', 
        QuestAnswer.objects.order_by('-date_publication').filter(is_public=True),
        count=QA_ON_PAGE, page=page, 
        root=context['current_section'].path
    )
    return render_to_response('qa/questanswer.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:33,代码来源:views.py

示例2: section

def section(request, section, page=None):
    context = RequestContext(request)
    paginate(
        context, 'articles', 
        query=context['section'].article_set.all(),
        count=ARTICLES_ON_PAGE, page=page, 
        root=request.current_section.path+section+'/'
    )
    return render_to_response('articles/section.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:9,代码来源:views.py

示例3: index

def index(request, page=None):
    context = RequestContext(request)
    paginate(
        context, 'articles', 
        Article.objects.order_by('-date_written'),
        count=ARTICLES_ON_PAGE, page=page, 
        root=request.current_section.path
    )
    return render_to_response('articles/index.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:9,代码来源:views.py

示例4: action_list

def action_list(request, page=None):
    context = get_default_context(request)
    context['actions'] = Action.objects.filter(is_active=True)
    paginate(
        context, 'actions', 
        Action.objects.filter(is_active=True).order_by('-id'),
        count=COLLECTIONS_ON_PAGE, page=page, 
        root=context['current_section'].path
    )
    context['disables'] = Action.objects.filter(is_active=False).order_by('-id')
    return render_to_response('action/action.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:11,代码来源:views.py

示例5: tag

def tag(request, tag, page=None):
    context = RequestContext(request)
    groups = Group.objects.all().order_by('id').values()
    context['groups'] = build_tree(groups, 'group_id')
    context['tagview'] = get_object_or_404(Tag, name=tag)
    paginate(
        context, 'articles', 
        query=Article.objects.filter(tags__name__exact=tag).order_by('-date_written'),
        count=ARTICLES_ON_PAGE, page=page, 
        root=request.current_section.path+tag+'/'
    )
    return render_to_response('articles/tag.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:12,代码来源:views.py

示例6: section

def section(request, section, page=None):
    context = RequestContext(request)
    groups = Group.objects.all().order_by('id').values()
    context['groups'] = build_tree(groups, 'group_id')
    context['section'] = get_object_or_404(Group, name=section)
    paginate(
        context, 'articles', 
        query=context['section'].article_set.all(), 
        count=ARTICLES_ON_PAGE, page=page, 
        root=request.current_section.path+section+'/'
    )
    return render_to_response('articles/section.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:12,代码来源:views.py

示例7: index

def index(request, page=None):
    context = RequestContext(request)
    # create_widgets_context(context, 'articles_index', 1, 1)
    groups = Group.objects.all().order_by('id').values()
    context['groups'] = build_tree(groups, 'group_id')
    paginate(
        context, 'articles', 
        Article.objects.order_by('-date_written'),
        count=ARTICLES_ON_PAGE, page=page, 
        root=request.current_section.path
    )
    return render_to_response('articles/index.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:12,代码来源:views.py

示例8: action_item

def action_item(request, slug, page=None):
    context = get_default_context(request)
    context['action'] = get_object_or_404(Action, slug=slug)
    context['crumbs'].append({
      'caption': context['action'].name,
      'path': slug,
    })
    paginate(
        context, 'positions', 
        query=Action.objects.get(slug=slug).products.all().filter(is_enabled=True),
        count=PRODUCTS_ON_PAGE, page=page, 
        root=context['current_section'].path+slug+'/'
    )
    return render_to_response('action/action-item.html', context)
开发者ID:vakhov,项目名称:python-django-projects,代码行数:14,代码来源:views.py

示例9: get

    def get(self, request):
        """
        比赛题目分页json api接口
        ---
        response_serializer: ContestProblemSerializer
        """
        contest_problem_id = request.GET.get("contest_problem_id", None)
        if contest_problem_id:
            try:
                contest_problem = ContestProblem.objects.get(id=contest_problem_id)
                if request.user.admin_type != SUPER_ADMIN and contest_problem.created_by != request.user:
                    return error_response(u"比赛题目不存在")
                return success_response(ContestProblemSerializer(contest_problem).data)
            except ContestProblem.DoesNotExist:
                return error_response(u"比赛题目不存在")

        contest_problems = ContestProblem.objects.all().order_by("sort_index")
        if request.user.admin_type != SUPER_ADMIN:
            contest_problems = contest_problems.filter(created_by=request.user).order_by("sort_index")
        visible = request.GET.get("visible", None)
        if visible:
            contest_problems = contest_problems.filter(visible=(visible == "true"))
        keyword = request.GET.get("keyword", None)
        if keyword:
            contest_problems = contest_problems.filter(Q(title__contains=keyword) |
                                                       Q(description__contains=keyword))
        contest_id = request.GET.get("contest_id", None)
        if contest_id:
            contest_problems = contest_problems.filter(contest__id=contest_id).order_by("sort_index")

        return paginate(request, contest_problems, ContestProblemSerializer)
开发者ID:adamwen829,项目名称:OnlineJudge,代码行数:31,代码来源:views.py

示例10: get

    def get(self, request):
        """
        题目分页json api接口
        ---
        response_serializer: ProblemSerializer
        """
        problem_id = request.GET.get("problem_id", None)
        if problem_id:
            try:
                # 普通管理员只能获取自己创建的题目
                # 超级管理员可以获取全部的题目
                problem = Problem.objects.get(id=problem_id)
                if request.user.admin_type != SUPER_ADMIN and problem.created_by != request.user:
                    return error_response(u"题目不存在")
                return success_response(ProblemSerializer(problem).data)
            except Problem.DoesNotExist:
                return error_response(u"题目不存在")

        # 获取问题列表
        problems = Problem.objects.all().order_by("-create_time")

        if request.user.admin_type != SUPER_ADMIN:
            problems = problems.filter(created_by=request.user)

        visible = request.GET.get("visible", None)
        if visible:
            problems = problems.filter(visible=(visible == "true"))
        keyword = request.GET.get("keyword", None)
        if keyword:
            problems = problems.filter(Q(title__contains=keyword) |
                                       Q(description__contains=keyword))

        return paginate(request, problems, ProblemSerializer)
开发者ID:8cbx,项目名称:OnlineJudge,代码行数:33,代码来源:views.py

示例11: get

 def get(self, request):
     """
     查询小组列表或者单个小组的信息,查询单个小组需要传递group_id参数,否则返回全部
     ---
     response_serializer: GroupSerializer
     """
     group_id = request.GET.get("group_id", None)
     # 根据 id 查询小组信息
     if group_id:
         try:
             group = self.get_group(request, group_id)
             return success_response(GroupSerializer(group).data)
         except Group.DoesNotExist:
             return error_response(u"小组不存在")
     else:
         groups = self.get_groups(request)
         # 搜索小组
         if request.GET.get("keyword", None):
             groups = groups.filter(name__contains=request.GET["keyword"])
         # 只返回我创建的小组 适用于超级管理员
         if request.GET.get("my_group", None):
             groups = groups.filter(admin=request.user)
         # 只返回指定用户的小组 适用于管理员
         elif request.GET.get("admin_id", None):
             groups = groups.filter(admin__id=request.GET["admin_id"])
         return paginate(request, groups, GroupSerializer)
开发者ID:isheng5,项目名称:OnlineJudge,代码行数:26,代码来源:views.py

示例12: get

 def get(self, request):
     """
     查询比赛提交,单个比赛题目提交的adminAPI
     ---
     response_serializer: SubmissionSerializer
     """
     problem_id = request.GET.get("problem_id", None)
     contest_id = request.GET.get("contest_id", None)
     if contest_id:
         try:
             contest = Contest.objects.get(pk=contest_id)
         except Contest.DoesNotExist:
             return error_response(u"比赛不存在!")
         if request.user.admin_type != SUPER_ADMIN and contest.created_by != request.user:
             return error_response(u"您无权查看该信息!")
         submissions = Submission.objects.filter(contest_id=contest_id).order_by("-create_time")
     else:
         if problem_id:
             try:
                 contest_problem = ContestProblem.objects.get(pk=problem_id)
             except ContestProblem.DoesNotExist:
                 return error_response(u"问题不存在!")
             if request.user.admin_type != SUPER_ADMIN and contest_problem.contest.created_by != request.user:
                 return error_response(u"您无权查看该信息!")
             submissions = Submission.objects.filter(contest_id=contest_problem.contest_id).order_by("-create_time")
         else:
             return error_response(u"参数错误!")
     if problem_id:
         submissions = submissions.filter(problem_id=problem_id)
     return paginate(request, submissions, SubmissionSerializer)
开发者ID:hujingguang,项目名称:OnlineJudge,代码行数:30,代码来源:views.py

示例13: get

 def get(self, request):
     """
     公告分页json api接口
     ---
     response_serializer: AnnouncementSerializer
     """
     announcement = Announcement.objects.all().order_by("-create_time")
     visible = request.GET.get("visible", None)
     if visible:
         announcement = announcement.filter(visible=(visible == "true"))
     return paginate(request, announcement, AnnouncementSerializer)
开发者ID:ArchFeh,项目名称:OnlineJudge,代码行数:11,代码来源:views.py

示例14: get

 def get(self, request):
     """
     公告分页json api接口
     ---
     response_serializer: AnnouncementSerializer
     """
     if request.user.admin_type == SUPER_ADMIN:
         announcement = Announcement.objects.all().order_by("-last_update_time")
     else:
         announcement = Announcement.objects.filter(created_by=request.user)
     visible = request.GET.get("visible", None)
     if visible:
         announcement = announcement.filter(visible=(visible == "true"))
     return paginate(request, announcement, AnnouncementSerializer)
开发者ID:uestcxl,项目名称:OnlineJudge,代码行数:14,代码来源:views.py

示例15: get

    def get(self, request):
        """
        查询小组成员的api,需要传递group_id参数
        ---
        response_serializer: GroupMemberSerializer
        """
        group_id = request.GET.get("group_id", None)
        if not group_id:
            return error_response(u"参数错误")
        try:
            group = self.get_group(request, group_id)
        except Group.DoesNotExist:
            return error_response(u"小组不存在")

        return paginate(request, UserGroupRelation.objects.filter(group=group), GroupMemberSerializer)
开发者ID:localfunction,项目名称:OnlineJudge,代码行数:15,代码来源:views.py


注:本文中的utils.shortcuts.paginate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。