Skip to content

Commit

Permalink
feat: add input of started participants (#473)
Browse files Browse the repository at this point in the history
Co-authored-by: v.filatov <[email protected]>
  • Loading branch information
FilatovVladimir239 and v.filatov authored Jan 13, 2025
1 parent d69a0e8 commit a051451
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 17 deletions.
15 changes: 12 additions & 3 deletions languages/ru_RU/LC_MESSAGES/sportorg.po
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,17 @@ msgstr "Включить"
msgid "URL not valid"
msgstr "URL недействителен"

msgid "Not started numbers"
msgstr "Не стартовавшие участники"
msgid "Set started numbers"
msgstr "Ввод стартовавших участников"

msgid "Set not started numbers"
msgstr "Ввод нестартовавших участников"

msgid "Count started numbers less half"
msgstr "Операция неприменима, количество стартовавших меньше половины"

msgid "Label status not started"
msgstr "Cтатус для нестартовавших"

msgid "Dialog"
msgstr "Диалог"
Expand Down Expand Up @@ -982,7 +991,7 @@ msgid "Change status"
msgstr "Изменить статус"

msgid "Set DNS numbers"
msgstr "Ввести номера со статусом DNS"
msgstr "Ввести Шахматку"

msgid "Service"
msgstr "Сервис"
Expand Down
65 changes: 53 additions & 12 deletions sportorg/gui/dialogs/not_start_dialog.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import logging

from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QDialog, QDialogButtonBox, QFormLayout, QLabel, QTextEdit
from PySide6.QtWidgets import (
QDialog,
QDialogButtonBox,
QFormLayout,
QLabel,
QTextEdit,
QMessageBox,
)

from sportorg import config
from sportorg.gui.global_access import GlobalAccess
Expand All @@ -14,26 +21,35 @@
from sportorg.modules.teamwork.teamwork import Teamwork


class NotStartDialog(QDialog):
class InputStartNumbersDialog(QDialog):
def __init__(self):
super().__init__(GlobalAccess().get_main_window())
self.STARTED_NUMBERS = translate("Set started numbers")
self.NOT_STARTED_NUMBERS = translate("Set not started numbers")

def exec_(self):
self.init_ui()
return super().exec_()

def init_ui(self):
self.setWindowTitle(translate("Not started numbers"))
self.setWindowTitle(translate("Set DNS numbers"))
self.setWindowIcon(QIcon(config.ICON))
self.setSizeGripEnabled(False)
self.setModal(True)

self.layout = QFormLayout(self)

self.input_start_list = AdvComboBox()
self.input_start_list.addItems([self.STARTED_NUMBERS, self.NOT_STARTED_NUMBERS])

self.layout.addRow(self.input_start_list)

self.item_status_comment = AdvComboBox()
self.item_status_comment.addItems(StatusComments().get_all())

self.layout.addRow(self.item_status_comment)
self.layout.addRow(
translate("Label status not started"), self.item_status_comment
)

self.label_controls = QLabel("\n\n1 4 15 25\n58 32\n33\n34\n...\n150")
self.item_numbers = QTextEdit()
Expand Down Expand Up @@ -63,17 +79,33 @@ def apply_changes():
self.show()

def apply_changes_impl(self):
if self.input_start_list.currentText() == self.NOT_STARTED_NUMBERS:
not_started_numbers = self.parse_input_numbers()
self.apply_not_started_list_changes_impl(not_started_numbers)
else:
self.apply_started_list_changes_impl()

def apply_started_list_changes_impl(self):
started_numbers = self.parse_input_numbers()
all_numbers = set(race().person_index_bib.keys())
not_started_numbers = set(all_numbers)
for number in started_numbers:
not_started_numbers.remove(number)

if len(not_started_numbers) <= len(all_numbers) / 2:
self.apply_not_started_list_changes_impl(not_started_numbers)
else:
QMessageBox.warning(
self,
translate("Set started numbers"),
translate("Count started numbers less half"),
)

def apply_not_started_list_changes_impl(self, not_started_numbers):
status_comment = StatusComments().remove_hint(
self.item_status_comment.currentText()
)
text = self.item_numbers.toPlainText()
numbers = []
for item in text.split("\n"):
if not len(item):
continue
for n_item in item.split():
if n_item.isdigit():
numbers.append(int(n_item))
numbers = not_started_numbers
old_numbers = []
obj = race()
for number in numbers:
Expand All @@ -91,3 +123,12 @@ def apply_changes_impl(self):
logging.info("{} not found".format(number))
old_numbers.append(number)
ResultCalculation(race()).process_results()

def parse_input_numbers(self):
text = self.item_numbers.toPlainText()
numbers = []
for item in filter(None, text.splitlines()):
for n_item in item.split():
if n_item.isdigit():
numbers.append(int(n_item))
return numbers
4 changes: 2 additions & 2 deletions sportorg/gui/menu/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from sportorg.gui.dialogs.live_dialog import LiveDialog
from sportorg.gui.dialogs.marked_route_dialog import MarkedRouteDialog
from sportorg.gui.dialogs.merge_results import MergeResultsDialog
from sportorg.gui.dialogs.not_start_dialog import NotStartDialog
from sportorg.gui.dialogs.not_start_dialog import InputStartNumbersDialog
from sportorg.gui.dialogs.number_change import NumberChangeDialog
from sportorg.gui.dialogs.organization_mass_edit import OrganizationMassEditDialog
from sportorg.gui.dialogs.print_properties import PrintPropertiesDialog
Expand Down Expand Up @@ -705,7 +705,7 @@ def execute(self):

class SetDNSNumbersAction(Action, metaclass=ActionFactory):
def execute(self):
NotStartDialog().exec_()
InputStartNumbersDialog().exec_()
self.app.refresh()


Expand Down

0 comments on commit a051451

Please sign in to comment.