Loading opds_catalog/feeds.py +4 −4 Original line number Diff line number Diff line Loading @@ -222,11 +222,11 @@ class CatalogsFeed(AuthFeed): op = OPDS_Paginator(catalogs_count, books_count, page_num, settings.MAXITEMS) items = [] for row in catalogs_list[op.d1_first_pos:op.d1_last_pos]: for row in catalogs_list[op.d1_first_pos:op.d1_last_pos+1]: p = {'is_catalog':1, 'title': row.cat_name,'id': row.id, 'cat_type':row.cat_type, 'parent_id':row.parent_id} items.append(p) for row in books_list[op.d2_first_pos:op.d2_last_pos]: for row in books_list[op.d2_first_pos:op.d2_last_pos+1]: p = {'is_catalog':0, 'lang_code': row.lang_code, 'filename': row.filename, 'path': row.path, \ 'registerdate': row.registerdate, 'id': row.id, 'annotation': row.annotation, \ 'docdate': row.docdate, 'format': row.format, 'title': row.title, 'filesize': row.filesize//1000, Loading Loading @@ -447,7 +447,7 @@ class SearchBooksFeed(AuthFeed): start = op.d1_first_pos if ((op.d1_first_pos==0) or (not summary_DOUBLES_HIDE)) else op.d1_first_pos-1 finish = op.d1_last_pos for row in books[start:finish]: for row in books[start:finish+1]: p = {'doubles':0, 'lang_code': row.lang_code, 'filename': row.filename, 'path': row.path, \ 'registerdate': row.registerdate, 'id': row.id, 'annotation': row.annotation, \ 'docdate': row.docdate, 'format': row.format, 'title': row.title, 'filesize': row.filesize//1000, Loading @@ -467,7 +467,7 @@ class SearchBooksFeed(AuthFeed): # "вытягиваем" дубликаты книг со следующей страницы и удаляем первый элемент который с предыдущей страницы и "вытягивал" дубликаты с текущей if summary_DOUBLES_HIDE: double_flag = True while (finish<books_count) and double_flag: while ((finish+1)<books_count) and double_flag: finish += 1 if books[finish].title==prev_title and {a['id'] for a in books[finish].authors.values()}==prev_authors_set: items[-1]['doubles']+=1 Loading opds_catalog/opds_paginator.py +6 −6 Original line number Diff line number Diff line Loading @@ -8,26 +8,26 @@ class Paginator: def __init__(self, d1_count, d2_count, page_num=1, maxitems=60, half_pages_link = 3): self.d1_count = d1_count self.d2_count = d2_count self.count = self.d1_count + self.d2_count self.MAXITEMS = maxitems self.HALF_PAGES_LINK = half_pages_link self.page_num = page_num self.calc_data() pass def calc_data(self): d1_MAXITEMS = self.MAXITEMS self.d1_first_pos = d1_MAXITEMS*(self.page_num-1); self.d1_first_pos = self.d1_first_pos if self.d1_first_pos<self.d1_count else self.d1_count self.d1_first_pos = self.d1_first_pos if self.d1_first_pos<self.d1_count else self.d1_count-1 self.d1_last_pos = d1_MAXITEMS*self.page_num - 1; self.d1_last_pos = self.d1_last_pos if self.d1_last_pos<self.d1_count else self.d1_count self.d1_last_pos = self.d1_last_pos if self.d1_last_pos<self.d1_count else self.d1_count-1 d2_MAXITEMS = self.MAXITEMS - self.d1_last_pos + self.d1_first_pos self.d2_first_pos = d2_MAXITEMS*(self.page_num-1); self.d2_first_pos = self.d2_first_pos if self.d2_first_pos<self.d2_count else self.d2_count self.d2_first_pos = self.d2_first_pos if self.d2_first_pos<self.d2_count else self.d2_count-1 self.d2_last_pos = d2_MAXITEMS*self.page_num - 1; self.d2_last_pos = self.d2_last_pos if self.d2_last_pos<self.d2_count else self.d2_count self.d2_last_pos = self.d2_last_pos if self.d2_last_pos<self.d2_count else self.d2_count-1 self.num_pages = int((self.d1_count+self.d2_count)/self.MAXITEMS)+1 self.num_pages = self.count//self.MAXITEMS + 1 if self.count%self.MAXITEMS else 0 self.firstpage = self.page_num - self.HALF_PAGES_LINK self.lastpage = self.page_num + self.HALF_PAGES_LINK if self.firstpage<1: Loading sopds_web_backend/views.py +4 −4 Original line number Diff line number Diff line Loading @@ -186,7 +186,7 @@ def SearchBooksView(request): start = op.d1_first_pos if ((op.d1_first_pos==0) or (not summary_DOUBLES_HIDE)) else op.d1_first_pos-1 finish = op.d1_last_pos for row in books[start:finish]: for row in books[start:finish+1]: p = {'doubles':0, 'lang_code': row.lang_code, 'filename': row.filename, 'path': row.path, \ 'registerdate': row.registerdate, 'id': row.id, 'annotation': row.annotation, \ 'docdate': row.docdate, 'format': row.format, 'title': row.title, 'filesize': row.filesize//1000, Loading @@ -206,7 +206,7 @@ def SearchBooksView(request): # "вытягиваем" дубликаты книг со следующей страницы и удаляем первый элемент который с предыдущей страницы и "вытягивал" дубликаты с текущей if summary_DOUBLES_HIDE: double_flag = True while (finish<books_count) and double_flag: while ((finish+1)<books_count) and double_flag: finish += 1 if books[finish].title==prev_title and {a['id'] for a in books[finish].authors.values()}==prev_authors_set: items[-1]['doubles']+=1 Loading Loading @@ -334,11 +334,11 @@ def CatalogsView(request): op = OPDS_Paginator(catalogs_count, books_count, page_num, MAXITEMS, HALF_PAGES_LINKS) items = [] for row in catalogs_list[op.d1_first_pos:op.d1_last_pos]: for row in catalogs_list[op.d1_first_pos:op.d1_last_pos+1]: p = {'is_catalog':1, 'title': row.cat_name,'id': row.id, 'cat_type':row.cat_type, 'parent_id':row.parent_id} items.append(p) for row in books_list[op.d2_first_pos:op.d2_last_pos]: for row in books_list[op.d2_first_pos:op.d2_last_pos+1]: p = {'is_catalog':0, 'lang_code': row.lang_code, 'filename': row.filename, 'path': row.path, \ 'registerdate': row.registerdate, 'id': row.id, 'annotation': row.annotation, \ 'docdate': row.docdate, 'format': row.format, 'title': row.title, 'filesize': row.filesize//1000, Loading Loading
opds_catalog/feeds.py +4 −4 Original line number Diff line number Diff line Loading @@ -222,11 +222,11 @@ class CatalogsFeed(AuthFeed): op = OPDS_Paginator(catalogs_count, books_count, page_num, settings.MAXITEMS) items = [] for row in catalogs_list[op.d1_first_pos:op.d1_last_pos]: for row in catalogs_list[op.d1_first_pos:op.d1_last_pos+1]: p = {'is_catalog':1, 'title': row.cat_name,'id': row.id, 'cat_type':row.cat_type, 'parent_id':row.parent_id} items.append(p) for row in books_list[op.d2_first_pos:op.d2_last_pos]: for row in books_list[op.d2_first_pos:op.d2_last_pos+1]: p = {'is_catalog':0, 'lang_code': row.lang_code, 'filename': row.filename, 'path': row.path, \ 'registerdate': row.registerdate, 'id': row.id, 'annotation': row.annotation, \ 'docdate': row.docdate, 'format': row.format, 'title': row.title, 'filesize': row.filesize//1000, Loading Loading @@ -447,7 +447,7 @@ class SearchBooksFeed(AuthFeed): start = op.d1_first_pos if ((op.d1_first_pos==0) or (not summary_DOUBLES_HIDE)) else op.d1_first_pos-1 finish = op.d1_last_pos for row in books[start:finish]: for row in books[start:finish+1]: p = {'doubles':0, 'lang_code': row.lang_code, 'filename': row.filename, 'path': row.path, \ 'registerdate': row.registerdate, 'id': row.id, 'annotation': row.annotation, \ 'docdate': row.docdate, 'format': row.format, 'title': row.title, 'filesize': row.filesize//1000, Loading @@ -467,7 +467,7 @@ class SearchBooksFeed(AuthFeed): # "вытягиваем" дубликаты книг со следующей страницы и удаляем первый элемент который с предыдущей страницы и "вытягивал" дубликаты с текущей if summary_DOUBLES_HIDE: double_flag = True while (finish<books_count) and double_flag: while ((finish+1)<books_count) and double_flag: finish += 1 if books[finish].title==prev_title and {a['id'] for a in books[finish].authors.values()}==prev_authors_set: items[-1]['doubles']+=1 Loading
opds_catalog/opds_paginator.py +6 −6 Original line number Diff line number Diff line Loading @@ -8,26 +8,26 @@ class Paginator: def __init__(self, d1_count, d2_count, page_num=1, maxitems=60, half_pages_link = 3): self.d1_count = d1_count self.d2_count = d2_count self.count = self.d1_count + self.d2_count self.MAXITEMS = maxitems self.HALF_PAGES_LINK = half_pages_link self.page_num = page_num self.calc_data() pass def calc_data(self): d1_MAXITEMS = self.MAXITEMS self.d1_first_pos = d1_MAXITEMS*(self.page_num-1); self.d1_first_pos = self.d1_first_pos if self.d1_first_pos<self.d1_count else self.d1_count self.d1_first_pos = self.d1_first_pos if self.d1_first_pos<self.d1_count else self.d1_count-1 self.d1_last_pos = d1_MAXITEMS*self.page_num - 1; self.d1_last_pos = self.d1_last_pos if self.d1_last_pos<self.d1_count else self.d1_count self.d1_last_pos = self.d1_last_pos if self.d1_last_pos<self.d1_count else self.d1_count-1 d2_MAXITEMS = self.MAXITEMS - self.d1_last_pos + self.d1_first_pos self.d2_first_pos = d2_MAXITEMS*(self.page_num-1); self.d2_first_pos = self.d2_first_pos if self.d2_first_pos<self.d2_count else self.d2_count self.d2_first_pos = self.d2_first_pos if self.d2_first_pos<self.d2_count else self.d2_count-1 self.d2_last_pos = d2_MAXITEMS*self.page_num - 1; self.d2_last_pos = self.d2_last_pos if self.d2_last_pos<self.d2_count else self.d2_count self.d2_last_pos = self.d2_last_pos if self.d2_last_pos<self.d2_count else self.d2_count-1 self.num_pages = int((self.d1_count+self.d2_count)/self.MAXITEMS)+1 self.num_pages = self.count//self.MAXITEMS + 1 if self.count%self.MAXITEMS else 0 self.firstpage = self.page_num - self.HALF_PAGES_LINK self.lastpage = self.page_num + self.HALF_PAGES_LINK if self.firstpage<1: Loading
sopds_web_backend/views.py +4 −4 Original line number Diff line number Diff line Loading @@ -186,7 +186,7 @@ def SearchBooksView(request): start = op.d1_first_pos if ((op.d1_first_pos==0) or (not summary_DOUBLES_HIDE)) else op.d1_first_pos-1 finish = op.d1_last_pos for row in books[start:finish]: for row in books[start:finish+1]: p = {'doubles':0, 'lang_code': row.lang_code, 'filename': row.filename, 'path': row.path, \ 'registerdate': row.registerdate, 'id': row.id, 'annotation': row.annotation, \ 'docdate': row.docdate, 'format': row.format, 'title': row.title, 'filesize': row.filesize//1000, Loading @@ -206,7 +206,7 @@ def SearchBooksView(request): # "вытягиваем" дубликаты книг со следующей страницы и удаляем первый элемент который с предыдущей страницы и "вытягивал" дубликаты с текущей if summary_DOUBLES_HIDE: double_flag = True while (finish<books_count) and double_flag: while ((finish+1)<books_count) and double_flag: finish += 1 if books[finish].title==prev_title and {a['id'] for a in books[finish].authors.values()}==prev_authors_set: items[-1]['doubles']+=1 Loading Loading @@ -334,11 +334,11 @@ def CatalogsView(request): op = OPDS_Paginator(catalogs_count, books_count, page_num, MAXITEMS, HALF_PAGES_LINKS) items = [] for row in catalogs_list[op.d1_first_pos:op.d1_last_pos]: for row in catalogs_list[op.d1_first_pos:op.d1_last_pos+1]: p = {'is_catalog':1, 'title': row.cat_name,'id': row.id, 'cat_type':row.cat_type, 'parent_id':row.parent_id} items.append(p) for row in books_list[op.d2_first_pos:op.d2_last_pos]: for row in books_list[op.d2_first_pos:op.d2_last_pos+1]: p = {'is_catalog':0, 'lang_code': row.lang_code, 'filename': row.filename, 'path': row.path, \ 'registerdate': row.registerdate, 'id': row.id, 'annotation': row.annotation, \ 'docdate': row.docdate, 'format': row.format, 'title': row.title, 'filesize': row.filesize//1000, Loading