mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Fixed bug where previous searches, and orders were not respected by
paging
This commit is contained in:
4
src/interface/static/js/pyshelf_ux.js
vendored
4
src/interface/static/js/pyshelf_ux.js
vendored
@@ -81,10 +81,8 @@ $(document).ready(function(){
|
||||
window.location.href="/"+valueSelected
|
||||
});
|
||||
$('#btn-home').on("click", function(){
|
||||
console.log('Home Pressed');
|
||||
_location = $(this).attr('data-location');
|
||||
$('#_order').val(null);
|
||||
$('#_search').val(null);
|
||||
window.location.href=_location;
|
||||
});
|
||||
$('#search_string').html("<i> "+$('#_search').val().substr(0,15)+"</i>")
|
||||
});
|
||||
|
||||
8
src/interface/templates/index.html
vendored
8
src/interface/templates/index.html
vendored
@@ -39,7 +39,7 @@
|
||||
<h1 class="app_hdr" id="hdr_branding">pyShelf {{Version}}</h1>
|
||||
<div class="hdr_nav" id="hdr_nav_center">
|
||||
<ul id="tab_nav_menu">
|
||||
<li class="nav_menu_tab active_tab" id="btn-home" data-location="/?query=0"><i class="fas fa-home"></i> Home</li>
|
||||
<li class="nav_menu_tab active_tab" id="btn-home" data-location="/home"><i class="fas fa-home"></i> Home</li>
|
||||
<li class="nav_menu_tab"><i class="fas fa-layer-group"></i> Collections</li>
|
||||
<li class="nav_menu_tab"><i class="fas fa-star"></i> Favorites</li>
|
||||
<li class="nav_menu_tab"><i class="fas fa-bug"></i> Bug report</li>
|
||||
@@ -48,7 +48,7 @@
|
||||
</div>
|
||||
<div id="horiz_nav_main">
|
||||
<div id="horiz_nav_left">
|
||||
<i class="fas fa-arrow-circle-left nav_icon prev_page" onclick="window.location.href = '/prev_page/{{ Set }}'"></i>
|
||||
<i class="fas fa-arrow-circle-left nav_icon prev_page" onclick="window.location.href = '/prev_page/{{ Set }}/{{ Order }}'"></i>
|
||||
sort <i class="fas fa-sort nav_icon"></i>
|
||||
<select id = "sortlist">
|
||||
<option valie = "" id="empty-sort"></option>
|
||||
@@ -62,11 +62,11 @@
|
||||
<i class="fas fa-sort-alpha-down nav_icon"></i>
|
||||
<i class="fas fa-sort-alpha-up nav_icon"></i>
|
||||
<input class="nav_search input_box" type="text" size="40" value="search by Title, Author, Tags, or Collections">
|
||||
<i class="fas fa-search search_submit search_button" onclick="window.location.href = '/prev_page/{{ Set }}'">search</i>
|
||||
<i class="fas fa-search search_submit search_button" id="search_string" onclick="window.location.href = '/prev_page/{{ Set }}'"></i>
|
||||
</div>
|
||||
<div class="horiz_nav_stats">
|
||||
<i class="fas fa-book nav_icon"></i> {{ NowShowing }} of {{ BookStats }}
|
||||
<i class="fas fa-arrow-circle-right nav_icon next_page" onclick="window.location.href = '/next_page/{{ Set }}'"></i>
|
||||
<i class="fas fa-arrow-circle-right nav_icon next_page" onclick="window.location.href = '/next_page/{{ Set }}/{{ Order }}'"></i>
|
||||
</div>
|
||||
</div>
|
||||
</ul>
|
||||
|
||||
@@ -28,6 +28,16 @@ def index(request, query=None, _set=1, _limit=None, _order='title'):
|
||||
_payload
|
||||
)
|
||||
|
||||
def home(request, query=None, _set=1, _limit=None, _order='title'):
|
||||
"""
|
||||
Reset Search Queries & Return Home
|
||||
"""
|
||||
_payload = payload(request, query, _set, _limit, _order, reset='1')
|
||||
return render(
|
||||
request,
|
||||
"index.html",
|
||||
_payload
|
||||
)
|
||||
def show_collection(request, _collection, _colset):
|
||||
try:
|
||||
_set = int(_colset) + 1
|
||||
@@ -225,7 +235,6 @@ def menu(which, _set=1, parent=None):
|
||||
return _collections
|
||||
elif which == "nav_lvl_0":
|
||||
navigation_list = Navigation.objects.all()
|
||||
breakpoint()
|
||||
return navigation_list
|
||||
|
||||
def collections_list():
|
||||
@@ -235,39 +244,49 @@ def collections_list():
|
||||
collection_key.append(i.collection)
|
||||
return json.dumps(list(set(collection_key)))
|
||||
|
||||
def payload(request, query, _set, _limit, _order):
|
||||
def payload(request, query, _set, _limit, _order, **kwargs):
|
||||
"""
|
||||
Return formatted data to template
|
||||
"""
|
||||
breakpoint()
|
||||
_set = int(_set)
|
||||
if _set < 1: _set = 1
|
||||
if _limit is None: _limit = 20
|
||||
_set_max = int(_set) * _limit
|
||||
_set_min = _set_max - _limit
|
||||
_now_showing = "%s-%s"%(_set_min, _set_max)
|
||||
if query:
|
||||
if query != request.session.get('cached_query'):
|
||||
try:
|
||||
if kwargs['reset']:
|
||||
request.session['cached_query'] = query
|
||||
_results = Books().generic_search(query)
|
||||
_r, _r_len = \
|
||||
_results[_set_min:_set_max],\
|
||||
_results.count()
|
||||
elif query == request.session.get('cached_query'):
|
||||
_results = Books().generic_search(query)
|
||||
_r, _r_len = \
|
||||
_results.order_by(_order)[_set_min:_set_max],\
|
||||
_results.count()
|
||||
|
||||
else:
|
||||
try:
|
||||
query = request.session['cached_query']
|
||||
_results = Books().generic_search(query)
|
||||
_r, _r_len = \
|
||||
_results.order_by(_order)[_set_min:_set_max],\
|
||||
_results.count()
|
||||
except KeyError:
|
||||
if _set < 1: _set = 1
|
||||
if _limit is None: _limit = 20
|
||||
_set_max = int(_set) * _limit
|
||||
_set_min = _set_max - _limit
|
||||
_now_showing = "%s-%s"%(_set_min, _set_max)
|
||||
_r, _r_len, _search = book_set(_order, _limit, _set), None, None
|
||||
except KeyError:
|
||||
_set = int(_set)
|
||||
if _set < 1: _set = 1
|
||||
if _limit is None: _limit = 20
|
||||
_set_max = int(_set) * _limit
|
||||
_set_min = _set_max - _limit
|
||||
_now_showing = "%s-%s"%(_set_min, _set_max)
|
||||
if query:
|
||||
if query != request.session.get('cached_query'):
|
||||
request.session['cached_query'] = query
|
||||
_results = Books().generic_search(query)
|
||||
_r, _r_len = \
|
||||
_results[_set_min:_set_max],\
|
||||
_results.count()
|
||||
elif query == request.session.get('cached_query'):
|
||||
_results = Books().generic_search(query)
|
||||
_r, _r_len = \
|
||||
_results.order_by(_order)[_set_min:_set_max],\
|
||||
_results.count()
|
||||
|
||||
else:
|
||||
try:
|
||||
query = request.session['cached_query']
|
||||
if query == None: raise KeyError
|
||||
_results = Books().generic_search(query)
|
||||
_r, _r_len = \
|
||||
_results.order_by(_order)[_set_min:_set_max],\
|
||||
_results.count()
|
||||
except KeyError:
|
||||
_r, _r_len, _search = book_set(_order, _limit, _set), None, None
|
||||
|
||||
_bookstats, _collectionstats, _collectionobject = \
|
||||
Books.objects.all().count, Collections.objects.all().count, \
|
||||
|
||||
Reference in New Issue
Block a user