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)
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)
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)
def book_random_api(request): return HttpResponse( Book.return_json_selialize(), mimetype='text/plain')
def test_random_n(self): self.book.set_for_random() books = Book.get_random_n(5) self.assertEqual(len(books), 5)
def index(request): return render( request, 'keyword.html', Book.return_keyword_dict())