Exemplo n.º 1
0
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))
Exemplo n.º 2
0
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))
Exemplo n.º 3
0
def find_point_page(find_string: str, page_num: str,
                    stylesheet_number: str) -> str:
    """Create table contain result find from only works points"""
    with Database() as base:
        _, cursor = base
        points = select_operations.get_all_points_list_from_like_str_limit(
            cursor, find_string, int(page_num))
        pages_list = functions.list_of_pages(
            select_operations.get_all_points_list_from_like_str(
                cursor, find_string))
        links_list = ['/equip/' + str(elem[0]) for elem in points]
        result = uhtml.universal_table(table_headers.points_table_name,
                                       table_headers.points_table,
                                       [[point[1], point[2], point[3]]
                                        for point in points], True, links_list)
        pages_table = uhtml.paging_table(
            '/find/point/{0}/page'.format(find_string), pages_list,
            int(page_num))
        return web_template.result_page(result + pages_table, '/find',
                                        str(stylesheet_number))
Exemplo n.º 4
0
def find_equip_page(find_string: str, page_num: str,
                    stylesheet_number: str) -> str:
    """Create table contains result find from equips only"""
    with Database() as base:
        _, cursor = base
        equips = select_operations.get_all_equips_list_from_like_str_limit(
            cursor, find_string, int(page_num))
        pages_list = functions.list_of_pages(
            select_operations.get_all_equips_list_from_like_str(
                cursor, find_string))
        links_list = ['/work/' + str(equip[0]) for equip in equips]
        result = uhtml.universal_table(
            table_headers.equips_table_name, table_headers.equips_table,
            [[equip[i] for i in range(1, len(equip))]
             for equip in equips], True, links_list)
        pages_table = uhtml.paging_table(
            '/find/equip/{0}/page'.format(find_string), pages_list,
            int(page_num))
        return web_template.result_page(result + pages_table, '/find',
                                        str(stylesheet_number))
Exemplo n.º 5
0
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))
Exemplo n.º 6
0
 def test_list_of_pages4(self):
     self.assertListEqual(functions.list_of_pages([i for i in range(config.max_records_in_page + 1)]),
                          [1, 2], 'Not corrected create pages list from [1, 2, ... max_size + 1]')
Exemplo n.º 7
0
 def test_list_of_pages1(self):
     self.assertListEqual(functions.list_of_pages([]),
                          [1], 'Not corrected create pages list from []')