示例#1
0
def index(request):
    page = request.GET.get('page', 1)
    d = Book.return_has_review_dict(page=int(page) - 1)
    d['return_url'] = 'latest?page=%d' % (int(page) + 1)
    return render(
        request,
        'review.html',
        d)
示例#2
0
def index(request):
    page = request.GET.get('page', '1')

    cache_key = 'ideahelp_cache_dict_page_%s' % page
    cache_time = 300

    d = cache.get(cache_key)
    if not d:
        d = Book.return_idea_dict()
        cache.set(cache_key, d, cache_time)

    d['return_url'] += '?page=%s' % str(int(page) + 1)
    return render(
        request,
        'keyword.html',
        d)
示例#3
0
文件: index.py 项目: esehara/bookable
def index(request):
    page = request.GET.get('page', '1')
    
    cache_key = 'index_cache_dict_page_%s' % page
    cache_time = 180
    d = cache.get(cache_key)

    if not d:
        d = Book.return_page_dict()
        cache.set(cache_key, d, cache_time)

    d['return_url'] = '?page=%s' % str(int(page) + 1)
    return render(
        request,
        'index.html',
        d)
示例#4
0
文件: api.py 项目: esehara/bookable
def book_random_api(request):
    return HttpResponse(
        Book.return_json_selialize(),
        mimetype='text/plain')
示例#5
0
文件: tests.py 项目: esehara/bookable
 def test_random_n(self):
     self.book.set_for_random()
     books = Book.get_random_n(5)
     self.assertEqual(len(books), 5)
示例#6
0
def index(request):
    return render(
        request,
        'keyword.html',
        Book.return_keyword_dict())