Beispiel #1
0
 def filter(cls, socket):
     while True:
         choice = menu(
             title="Фильтрация по заказам",
             options=[
                 "По id",
                 "По услуге",
                 "По покупателю",
                 "По количеству",
                 "Вывод",
             ],
         )
         if choice == "1":
             send(socket=socket, data=choice)
             obj = {
                 "min": integer_input("Введите минимальный id"),
                 "max": integer_input("Введите максимальный id"),
             }
             while int(obj["min"]) > int(obj["max"]):
                 print(
                     "Минимальное значение не должно быть больше максимального"
                 )
                 obj = {
                     "min": integer_input("Введите минимальный id"),
                     "max": integer_input("Введите максимальный id"),
                 }
             send(socket=socket, data=obj)
         elif choice == "2":
             send(socket=socket, data=choice)
             clear()
             receive_and_print(socket=socket)
             send(socket=socket, data=integer_input("Введите id услуги"))
         elif choice == "3":
             send(socket=socket, data=choice)
             clear()
             receive_and_print(socket=socket)
             send(socket=socket,
                  data=integer_input("Введите id покупателя"))
         elif choice == "4":
             send(socket=socket, data=choice)
             obj = {
                 "min": integer_input("Введите минимальное количество"),
                 "max": integer_input("Введите максимальное количество"),
             }
             while int(obj["min"]) > int(obj["max"]):
                 print(
                     "Минимальное значение не должно быть больше максимального"
                 )
                 obj = {
                     "min": integer_input("Введите минимальное количество"),
                     "max":
                     integer_input("Введите максимальное количество"),
                 }
             send(socket=socket, data=obj)
         elif choice == "5":
             send(socket=socket, data=choice)
             cls.print(socket=socket)
         elif choice == "6":
             send(socket=socket, data=BREAK)
             break
Beispiel #2
0
 def edit(cls, socket):
     clear()
     receive_and_print(socket=socket)
     id_ = integer_input("Введите id")
     send(socket=socket, data=id_)
     response = receive(socket=socket)
     if response == GOOD:
         while True:
             choice = menu(title="Изменение услуги",
                           options=["Название", "Цену"])
             if choice == "1":
                 send(socket=socket, data=choice)
                 name = string_input("Введите название")
                 send(socket=socket, data=name)
                 print("Успешно изменено")
                 enter_to_continue()
             elif choice == "2":
                 send(socket=socket, data=choice)
                 price = integer_input("Введите цену")
                 send(socket=socket, data=price)
                 print("Успешно изменено")
                 enter_to_continue()
             elif choice == "3":
                 send(socket=socket, data=BREAK)
                 break
     else:
         print("Неверный id")
         enter_to_continue()
Beispiel #3
0
 def add(cls, socket):
     clear()
     send(socket=socket, data=string_input("Введите название"))
     response = receive(socket=socket)
     if response == ERROR:
         print("Компания с таким названием уже существует")
         enter_to_continue()
     else:
         print("Компания добавлен успешно")
         enter_to_continue()
Beispiel #4
0
 def delete(cls, socket):
     clear()
     receive_and_print(socket=socket)
     id_ = integer_input("Введите id")
     send(socket=socket, data=id_)
     response = receive(socket=socket)
     if response == GOOD:
         print("Проблема удалена")
     else:
         print("Неверный id")
     enter_to_continue()
Beispiel #5
0
 def add(cls, socket):
     clear()
     receive_and_print(socket=socket)
     service_id = integer_input("Введите id заказываемой услуги")
     send(socket=socket, data=service_id)
     response = receive(socket=socket)
     if response == ERROR:
         print("Неверный id")
     else:
         quantity = integer_input("Введите количество")
         send(socket=socket, data=quantity)
         print("Заказ добавлен успешно")
     enter_to_continue()
Beispiel #6
0
    def print(cls, socket):
        clear()
        choice = type_of_output_input(
            "1. Проблемы с неоконченным голосованием\n"
            "2. Проблемы с оконченным голосованием")
        if choice == "1":
            send(socket=socket, data=choice)
            clear()
            receive_and_print(socket=socket)
            enter_to_continue()
        elif choice == "2":
            clear()
            send(socket=socket, data=choice)
            clear()
            receive_and_print(socket=socket)
            send(
                socket=socket,
                data=integer_input(
                    "Введите id проблемы для детального просмотра"),
            )
            response = receive(socket=socket)
            if response == ERROR:
                print("Неверный id")
                enter_to_continue()
                return
            receive_and_print(socket=socket)

            enter_to_continue()
Beispiel #7
0
    def vote(cls, socket):
        clear()
        receive_and_print(socket=socket)
        id_ = integer_input("Введите id")

        send(socket=socket, data=id_)
        decisions = receive(socket=socket)
        if decisions == ERROR:
            print("Неверный id")
            enter_to_continue()
            return
        clear()
        decisions = loads(decisions)
        for id in decisions:
            assessment = max_min_10_input(
                f"Введите оценку решению от одного до 10\n {decisions[id]}")
            decisions[id] = int(assessment)
            clear()
        send(socket=socket, data=decisions)
        print("Спасибо, ваши голоса будут учитаны")
        enter_to_continue()
Beispiel #8
0
 def add(cls, socket):
     clear()
     send(socket=socket, data=string_input("Введите название"))
     response = receive(socket=socket)
     if response == ERROR:
         print("Услуга с таким названием уже существует")
         enter_to_continue()
     else:
         clear()
         send(socket=socket, data=string_input("Введите название компании"))
         response = receive(socket=socket)
         if response == ERROR:
             print("Компании с таким именем не существует")
             enter_to_continue()
         else:
             clear()
             send(socket=socket,
                  data=string_input("Введите описание услуги"))
             receive(socket=socket)
             send(socket=socket, data=integer_input("Введите цену"))
             print("Услуга добавлена успешно")
             enter_to_continue()
Beispiel #9
0
 def print_voted(cls, socket):
     clear()
     receive_and_print(socket=socket)
     enter_to_continue()
Beispiel #10
0
    def add(cls, socket):
        user = {}
        while True:
            role_choice = menu(
                title="Добавление пользователя",
                options=["Администратор", "Покупатель", "Эксперт"],
            )
            if role_choice == "1":
                send(socket=socket, data=role_choice)
                user["permissions"] = "admin"
                user["login"] = login_input()
                send(socket=socket, data=user["login"])
                response = receive(socket=socket)
                if response == GOOD:
                    user["password"] = password_input()
                    send(socket=socket, data=user)
                    print("Пользователь добавлен успешно")
                    enter_to_continue()
                else:
                    print("Такой логин уже существует")
                    enter_to_continue()
            elif role_choice == "2":
                send(socket=socket, data=role_choice)
                user["permissions"] = "default"
                user["login"] = login_input()
                send(socket=socket, data=user["login"])
                response = receive(socket=socket)
                if response == GOOD:
                    user["password"] = password_input()
                    send(socket=socket, data=user)
                    print("Пользователь добавлен успешно")
                    enter_to_continue()
                else:
                    print("Такой логин уже существует")
                    enter_to_continue()
            elif role_choice == "3":
                send(socket=socket, data=role_choice)
                user["permissions"] = "expert"
                user["login"] = login_input()
                send(socket=socket, data=user["login"])
                response = receive(socket=socket)
                if response == GOOD:
                    clear()
                    pos_mess = ("Выберете должнсть\n"
                                f"1. {Position.engineer.value}\n"
                                f"2. {Position.head_laboratory.value}\n"
                                f"3. {Position.complex_manager.value}\n"
                                f"4. {Position.director.value}\n")

                    send(socket=socket, data=select_position(pos_mess))
                    receive(socket=socket)
                    clear()
                    academic_degree_mess = (
                        "Выберете ученую степень\n"
                        f"1. {AcademicDegree.no_degree.value}\n"
                        f"2. {AcademicDegree.candidate.value}\n"
                        f"3. {AcademicDegree.phd.value}\n"
                        f"4. {AcademicDegree.academic.value}\n")
                    send(socket=socket,
                         data=select_academic_degree(academic_degree_mess))
                    receive(socket=socket)

                    user["password"] = password_input()
                    send(socket=socket, data=user)
                    print("Пользователь добавлен успешно")
                    enter_to_continue()
                else:
                    print("Такой логин уже существует")
                    enter_to_continue()
            elif role_choice == "4":
                send(socket=socket, data=BREAK)
                break