UI Improvements. Incluing result limiting

This commit is contained in:
Mike Young
2019-11-23 01:05:03 -05:00
parent 205e91a2ba
commit b7c2680e60
12 changed files with 107 additions and 24 deletions

View File

@@ -1,5 +1,6 @@
import os
from django.db import models
from django.shortcuts import HttpResponse, render
from django.utils.text import slugify
@@ -7,7 +8,17 @@ from .models import Books
def index(request):
return render(request, "index.html", {"Books": Books.objects.all()})
return render(request, "index.html", {"Books": book_set()})
# return render(request, "index.html", {"Books": Books.objects.all()})
def book_set(_limit=None, _set=1):
if _limit is None:
_limit = 20 # TODO default from user choice
_set_max = _set * _limit
_set_min = _set_max - _limit
books = Books.objects.all()[_set_min:_set_max]
return books
def download(request, pk):
@@ -22,11 +33,3 @@ def download(request, pk):
def hr_name(book):
return "{0}.{1}".format(slugify(book.title), book.file_name.split(".")[1])
def book_set(_set):
r = 20
x = _set * r
y = x + r
books = Books.objects.all()[x:y]
return books