Esempio n. 1
0
def equips_menu(stylesheet_number) -> str:
    """Method create main EQUIP-page"""
    name = 'Действия с оборудованием'
    menu = [(1, 'Все зарегестрированное оборудование'), (2, 'Поиск по ID')]
    links_list = ['/all-equips', '/find-equip-to-id']
    table = uhtml.universal_table(name, ['№', 'Доступное действие'], menu, True, links_list)
    return web_template.result_page(table, '/', str(stylesheet_number))
Esempio n. 2
0
def equip_to_point_limit(point_id, page_num, stylesheet_number: str) -> str:
    """Method create table contain equips. Use limit view on page"""
    with Database() as base:
        _, cursor = base
        all_equips = select_operations.get_equip_in_point_limit(cursor, point_id, page_num)
        links_list = ['/work/{}'.format(equip[0]) for equip in all_equips]
        data = [[equip[i] for i in range(0, len(equip))] for equip in all_equips]
        for i, row in enumerate(data):
            extended_links = ['<a href="/edit-equip/{0}" title="Редактировать">{1}</a>'.
                              format(row[0], EDIT_CHAR) +
                              '&nbsp;' +
                              ('<a href="/change-point/{0}" title="Переместить ' +
                               'на другой обьект">{1}</a>').
                              format(row[0], REMOVE_CHAR)]
            if row[0] != row[5]:
                extended_links[0] += '&nbsp;' + \
                                     '<a href="/remove-table/{0}" title="' \
                                     'Таблица перемещений">{1}</a>'. \
                                         format(row[0], TABLE_REMOVE_CHAR)
            data[i] = row[1:] + extended_links
        table1 = uhtml.universal_table(table_headers.equips_table_name,
                                       table_headers.equips_table,
                                       data,
                                       True, links_list)
        pages = uhtml.paging_table("/equip/{0}/page".format(point_id),
                                   functions.
                                   list_of_pages(select_operations.
                                                 get_equip_in_point(cursor,
                                                                    str(point_id))),
                                   int(page_num))
        table2 = uhtml.add_new_equip(point_id) if point_id != '0' else ""
        return web_template.result_page(table1 + pages + table2,
                                        '/all-points',
                                        str(stylesheet_number))
Esempio n. 3
0
def main_web_menu(stylesheet_number: str) -> str:
    """Function create main web-page"""
    name = "Доступные действия в базе ремонтов Малахит-Екатеринбург"
    menu = [
        (1, 'Операции с предприятиями'),
        (2, 'Операции с оборудованием'),
        (3, 'Операции с ремонтами'),
        (4, 'Операции с сотрудниками'),
        (5, 'Баг-трекер системы'),
        (6, 'Работа с заявками'),
        (7, 'Изменить тему оформления'),
        (8, 'Изменения в системе'),
    ]
    links_list = [
        '/points',
        '/equips',
        '/works',
        '/workers',
        '/bugs',
        '/orders-and-customers',
        '/next-themes',
        '/changelog-page',
    ]
    table = uhtml.universal_table(name, ['№', 'выполнить:'], menu, True,
                                  links_list)
    return web_template.result_page(table, "", stylesheet_number)
Esempio n. 4
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))
Esempio n. 5
0
def works_menu(stylesheet_number: str) -> str:
    """Return main menu in WORKS section"""
    name = 'Действия с ремонтами и диагностиками'
    menu = [(1, 'Все зарегистрированные работы'), (2, 'Поиск работы по ID')]
    links_list = ['/all-works', '/find-work-to-id']
    table = uhtml.universal_table(name, ['№', 'Доступное действие'], menu,
                                  True, links_list)
    return web_template.result_page(table, '/', str(stylesheet_number))
Esempio n. 6
0
def all_bugs_in_work_table(stylesheet_number: str) -> str:
    """Method create page. contain all unclosed bugs"""
    with Database() as base:
        _, cursor = base
        bugs_list = select_operations.get_all_bugz_in_work_in_bugzilla(cursor)
        table = uhtml.universal_table(table_headers.bugs_table_name,
                                      table_headers.bugs_table, bugs_list)
        return web_template.result_page(table, '/bugs', str(stylesheet_number))
Esempio n. 7
0
def system_status_page(preview_page, stylesheet_number: str) -> str:
    """Function create System-Status Web-page"""
    current_status = system_status.SystemStatus.get_status()
    status_to_list = [[key, current_status[key]] for key in current_status]
    result = uhtml.universal_table(table_headers.all_workers_table_name,
                                   table_headers.system_status_table,
                                   status_to_list)
    return web_template.result_page(result, preview_page,
                                    str(stylesheet_number))
Esempio n. 8
0
def all_registered_orders_table(stylesheet_number: str) -> str:
    """Function create page. contain list of all registered orders"""
    with Database() as base:
        _, cursor = base
        table = uhtml.universal_table(table_headers.orders_table_name,
                                      table_headers.orders_table,
                                      select_operations.get_all_orders(cursor))
        return web_template.result_page(table, '/orders-and-customers',
                                        str(stylesheet_number))
Esempio n. 9
0
def bugs_menu(stylesheet_number: str) -> str:
    """Method create main bugs-page"""
    menu = [(1, 'Отобразить все'), (2, 'Отобразить незакрытые'),
            (3, 'Зарегистрировать проблемму')]
    headers = ['№', 'Выполнить']
    links_list = ['/all-bugs', '/all-bugs-in-work', '/add-bug']
    table = uhtml.universal_table('Возможные действия', headers, menu, True,
                                  links_list)
    return web_template.result_page(table, '/bugs', str(stylesheet_number))
Esempio n. 10
0
def orders_main_menu(stylesheet_number: str) -> str:
    """Function create main page in ORDERS section"""
    menu = [(1, 'Все заказчики'), (2, 'Все зарегистрированные заявки')]
    links = ['/all-customers-table', '/all-registred-orders']
    table = uhtml.universal_table('Действия с заявками', ['№', 'Действие'],
                                  menu, True, links)
    preview_page = '/'
    return web_template.result_page(table, preview_page,
                                    str(stylesheet_number))
Esempio n. 11
0
def statistics_page(preview_page, stylesheet_number: str) -> str:
    """Function create STATISTIC web-page"""
    with Database() as base:
        _, cursor = base
        statistics = select_operations.get_statistic(cursor)
        links_list = ['/equip/' + str(elem[0]) for elem in statistics]
        result = uhtml.universal_table(table_headers.statistics_table_name,
                                       table_headers.statistics_table,
                                       [[elem[i] for i in range(1, len(elem))]
                                        for elem in statistics], True,
                                       links_list)
        return web_template.result_page(result, preview_page,
                                        str(stylesheet_number))
Esempio n. 12
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))
Esempio n. 13
0
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))
Esempio n. 14
0
def select_equip_to_id_page(data, method, stylesheet_number: str) -> str:
    """Create page to select EQUIP from EQUIP_ID"""
    pre_adr = '/equips'
    if method == "POST":
        equip_id = data['id']
        if equip_id == '0':
            return redirect('/all-equips')
        with Database() as base:
            _, cursor = base
            equip = select_operations.get_full_equip_information(cursor, str(equip_id))
            links_list = ['/work/' + str(equip_id)]
            table1 = uhtml.universal_table(table_headers.equips_table_name,
                                           table_headers.equips_table, [equip], True,
                                           links_list)
            return web_template.result_page(table1, pre_adr, str(stylesheet_number))
    else:
        return web_template.result_page("Method in Select Equip not corrected!",
                                        pre_adr,
                                        str(stylesheet_number))
Esempio n. 15
0
def remove_table_page(equip_id: str, stylesheet_number: str) -> str:
    """Method create table for all moving equip"""
    result = []
    with Database() as base:
        _, cursor = base
        equip_info = [str(equip_id)] +\
                     select_operations.get_full_equip_information(cursor, str(equip_id))
        result.insert(0, equip_info)
        while str(equip_info[0]) != str(equip_info[5]):
            old_equip_id = str(equip_info[5])
            equip_info = [old_equip_id] +\
                         select_operations.get_full_equip_information(cursor, old_equip_id)
            result.insert(0, equip_info)
    links = ['/work/{0}'.format(elem[0]) for elem in result]
    page = uhtml.universal_table(table_headers.remove_table_name,
                                 table_headers.remove_table,
                                 result,
                                 True,
                                 links)
    return web_template.result_page(page, "/", str(stylesheet_number))
Esempio n. 16
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))
Esempio n. 17
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))
Esempio n. 18
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))
Esempio n. 19
0
def viev_changelog(stylesheet_number: str) -> str:
    """Function create Changelog web-page"""
    table = uhtml.universal_table(table_headers.changelog_table_name,
                                  table_headers.changelog_table, CHANGELOG)
    return web_template.result_page(table, '/', str(stylesheet_number))