mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
UI Improvements. Incluing result limiting
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user