Esempio n. 1
0
 def test_paginator_url(self):
     per_page = 15
     obj_number = 1
     page_var = "page"
     url = "/path/"
     first_page = url + '#c' + str(obj_number)
     self.assertEqual(paginator.get_url(url, obj_number, per_page, page_var), first_page)
     obj_number = 16
     expected = '%(url)s?%(page_var)s=%(page_num)s#c%(obj_number)s' % {'url': url,
                                                                      'page_var': page_var,
                                                                      'page_num': 2,
                                                                      'obj_number': obj_number}
     self.assertEqual(paginator.get_url(url, obj_number, per_page, page_var), expected)
Esempio n. 2
0
 def test_paginator_url(self):
     per_page = 15
     obj_number = 1
     page_var = "page"
     url = "/path/"
     first_page = url + "#c" + str(obj_number)
     self.assertEqual(paginator.get_url(url, obj_number, per_page, page_var), first_page)
     obj_number = 16
     expected = "%(url)s?%(page_var)s=%(page_num)s#c%(obj_number)s" % {
         "url": url,
         "page_var": page_var,
         "page_num": 2,
         "obj_number": obj_number,
     }
     self.assertEqual(paginator.get_url(url, obj_number, per_page, page_var), expected)
Esempio n. 3
0
def comment_find(request, pk):
    comment = get_object_or_404(Comment, pk=pk)
    comment_number = Comment.objects.filter(topic=comment.topic, date__lte=comment.date).count()
    url = paginator.get_url(comment.topic.get_absolute_url(),
                            comment_number,
                            settings.ST_COMMENTS_PER_PAGE,
                            settings.ST_COMMENTS_PAGE_VAR)
    return redirect(url)
Esempio n. 4
0
 def test_paginator_url(self):
     per_page = 15
     obj_number = 1
     page_var = "page"
     url = "/path/"
     first_page = url + '#c' + str(obj_number)
     self.assertEqual(
         paginator.get_url(url, obj_number, per_page, page_var), first_page)
     obj_number = 16
     expected = '%(url)s?%(page_var)s=%(page_num)s#c%(obj_number)s' % {
         'url': url,
         'page_var': page_var,
         'page_num': 2,
         'obj_number': obj_number
     }
     self.assertEqual(
         paginator.get_url(url, obj_number, per_page, page_var), expected)
Esempio n. 5
0
def comment_find(request, pk):
    comment = get_object_or_404(Comment, pk=pk)
    comment_number = Comment.objects.filter(topic=comment.topic,
                                            date__lte=comment.date).count()
    url = paginator.get_url(comment.topic.get_absolute_url(), comment_number,
                            settings.ST_COMMENTS_PER_PAGE,
                            settings.ST_COMMENTS_PAGE_VAR)
    return redirect(url)