def find_work_like_date_paging(find_string: str, data_start: str, data_stop: str, page_num: str, stylesheet_number: str) -> str: """Create table contain result find from works and data""" with Database() as base: _, cursor = base date_start_correct = data_start.replace('T', ' ') date_stop_correct = data_stop.replace('T', ' ') pages_list = functions.list_of_pages( select_operations.get_all_works_like_word_and_date( cursor, find_string, date_start_correct, date_stop_correct)) works = select_operations.get_all_works_like_word_and_date_limit( cursor, find_string, date_start_correct, date_stop_correct, int(page_num)) works = functions.works_table_add_new_performer(works) result = uhtml.universal_table(table_headers.works_table_name, table_headers.works_table, [list(work) for work in works]) pages_table = uhtml.paging_table( '/find/work/{0}/{1}/{2}/page'.format(find_string, date_start_correct, date_stop_correct), pages_list, int(page_num)) return web_template.result_page(result + pages_table, '/find', str(stylesheet_number))
def find_work_paging(find_string: str, page_num: str, stylesheet_number: str) -> str: """Create table contain result find from only works""" with Database() as base: _, cursor = base works = select_operations.get_all_works_like_word_limit( cursor, find_string, int(page_num)) works = functions.works_table_add_new_performer(works) pages_list = functions.list_of_pages( select_operations.get_all_works_like_word(cursor, find_string)) result = uhtml.universal_table(table_headers.works_table_name, table_headers.works_table, [list(work) for work in works]) pages_table = uhtml.paging_table( '/find/work/{0}/page'.format(find_string), pages_list, int(page_num)) return web_template.result_page(result + pages_table, '/find', str(stylesheet_number))
def select_work_to_id_method(data, method, stylesheet_number: str) -> str: """Method return page, contain work likes WORK_ID""" pre_adr = '/works' if method == "POST": work_id = data['id'] if work_id == '0': return redirect('/all-works') with Database() as base: _, cursor = base work = select_operations.get_full_information_to_work( cursor, str(work_id)) work = functions.works_table_add_new_performer([work]) table1 = uhtml.universal_table(table_headers.works_table_name, table_headers.works_table, work) return web_template.result_page(table1, pre_adr, str(stylesheet_number)) else: return web_template.result_page("Method in Select Work not corrected!", pre_adr, str(stylesheet_number))
def work_to_equip_paging(equip_id, page_id, stylesheet_number: str) -> str: """Return page, contain works from current equip""" with Database() as base: _, cursor = base pre_adr = ('/equip/' + str(select_operations. get_point_id_from_equip_id(cursor, equip_id))) \ if str(equip_id) != '0' \ else '/works' full_works = select_operations.get_works_from_equip_id_limit( cursor, equip_id, page_id) full_works = functions.works_table_add_new_performer(full_works) table1 = uhtml.universal_table(table_headers.works_table_name, table_headers.works_table, full_works) table2 = uhtml.add_new_work(equip_id) if str(equip_id) != 0 else "" table_paging = uhtml.paging_table( "/work/{0}/page".format(equip_id), functions.list_of_pages( select_operations.get_works_from_equip_id(cursor, equip_id)), int(page_id)) return web_template.result_page(table1 + table_paging + table2, pre_adr, str(stylesheet_number))
def test_works_table_add_new_performer4(self): self.assertListEqual(functions.works_table_add_new_performer([[1, 2, 3], [4, 5, 6]]), [['1', '2', '3<a href="/add-performer-to-work/1">+</a>'], ['4', '5', '6<a href="/add-performer-to-work/4">+</a>']], 'Not corrected convertation [[1, 2, 3], [4, 5, 6]] in add new performer')
def test_works_table_add_new_performer3(self): self.assertListEqual(functions.works_table_add_new_performer([[1, 2]]), [['1', '2<a href="/add-performer-to-work/1">+</a>']], 'Not corrected convertation [[1, 2]] in add new performer')
def test_works_table_add_new_performer2(self): self.assertListEqual(functions.works_table_add_new_performer([[]]), [[]], 'Not corrected convertation [[]] in add new performer')