Skip to content

Commit

Permalink
paging: set complete item count for folders
Browse files Browse the repository at this point in the history
allows proper paging for yamaha AVRs
  • Loading branch information
milaq committed Aug 17, 2019
1 parent b1dca83 commit 533d4a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ycast/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def get_directories_page(subdir, directories, requestargs):
return page
for directory in get_paged_elements(directories, requestargs):
page.add(vtuner.Directory(directory, url_for(subdir, _external=True, directory=directory)))
page.set_count(len(directories))
return page


Expand All @@ -49,6 +50,7 @@ def get_stations_page(stations, requestargs):
return page
for station in get_paged_elements(stations, requestargs):
page.add(station.to_vtuner())
page.set_count(len(stations))
return page


Expand Down
6 changes: 4 additions & 2 deletions ycast/vtuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ def add_bogus_parameter(url):
class Page:
def __init__(self):
self.items = []
self.count = 0
self.count = -1

def add(self, item):
self.items.append(item)
self.count = len(self.items)

def set_count(self, count):
self.count = count

def to_xml(self):
xml = etree.Element('ListOfItems')
Expand Down

0 comments on commit 533d4a0

Please sign in to comment.