Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 46c6c84963 | |||
| 6666e79178 | |||
| c349fe475b | |||
| d5cd05c0e5 | |||
| b8c1df5ff8 | |||
| 8877de2cef | |||
| bd5c142bcf | |||
| e0ed3c7059 | |||
| a53e7100da | |||
| 2902c6a58c |
+5
-2
@@ -7,7 +7,8 @@ services:
|
||||
environment:
|
||||
PYTHONPATH: /opt/ezgg-lan-manager
|
||||
ports:
|
||||
- "7321:7321"
|
||||
- "8000:8000"
|
||||
- "8001:8001"
|
||||
volumes:
|
||||
- ./:/opt/ezgg-lan-manager
|
||||
entrypoint: ["/bin/sh", "-c", "cd /opt/ezgg-lan-manager/src && python3 /opt/ezgg-lan-manager/src/EzggLanManager.py"]
|
||||
@@ -20,7 +21,7 @@ services:
|
||||
MARIADB_USER: ezgg_lan_manager
|
||||
MARIADB_PASSWORD: Alkohol1
|
||||
healthcheck:
|
||||
test: ["CMD", "mariadb-admin", "ping", "-h", "localhost"]
|
||||
test: ["CMD", "mariadb-admin", "ping", "-h", "localhost", "-pAlkohol1"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
@@ -29,6 +30,8 @@ services:
|
||||
volumes:
|
||||
- database:/var/lib/mysql
|
||||
- ./sql/create_database.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
- ./sql:/sql
|
||||
- ./tournament_data:/opt/ezgg-lan-manager/tournament_data
|
||||
|
||||
|
||||
volumes:
|
||||
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
+26
-13
@@ -1,14 +1,14 @@
|
||||
import logging
|
||||
from uuid import uuid4
|
||||
|
||||
import sys
|
||||
|
||||
from pathlib import Path
|
||||
from uuid import uuid4
|
||||
|
||||
from rio import App, Theme, Color, Font, ComponentPage, Session
|
||||
from from_root import from_root
|
||||
|
||||
from src.ezgg_lan_manager import pages, init_services, LocalDataService
|
||||
from src.ezgg_lan_manager import pages, init_services, LocalDataService, RefreshService
|
||||
from src.ezgg_lan_manager.helpers.LoggedInGuard import logged_in_guard, not_logged_in_guard, team_guard
|
||||
from src.ezgg_lan_manager.services.LocalDataService import LocalData
|
||||
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||
@@ -18,10 +18,10 @@ logger = logging.getLogger("EzggLanManager")
|
||||
if __name__ == "__main__":
|
||||
theme = Theme.from_colors(
|
||||
primary_color=Color.from_hex("ffffff"),
|
||||
secondary_color=Color.from_hex("015454"),
|
||||
secondary_color=Color.from_hex("018786"),
|
||||
neutral_color=Color.from_hex("1e1e1e"),
|
||||
background_color=Color.from_hex("121212"),
|
||||
hud_color=Color.from_hex("02a797"),
|
||||
hud_color=Color.from_hex("02dac5"),
|
||||
text_color=Color.from_hex("018786"),
|
||||
mode="dark",
|
||||
corner_radius_small=0,
|
||||
@@ -36,12 +36,13 @@ if __name__ == "__main__":
|
||||
|
||||
async def on_session_start(session: Session) -> None:
|
||||
# Use this line to fake being any user without having to log in
|
||||
# session.attach(UserSession(id=uuid4(), user_id=30, is_team_member=True))
|
||||
session.attach(UserSession(id=uuid4(), user_id=30, is_team_member=True))
|
||||
await session.set_title(lan_info.name)
|
||||
if session[LocalData].stored_session_token:
|
||||
user_session = session[LocalDataService].verify_token(session[LocalData].stored_session_token)
|
||||
if user_session is not None:
|
||||
session.attach(user_session)
|
||||
session.attach(RefreshService())
|
||||
# if session[LocalData].stored_session_token:
|
||||
# user_session = session[LocalDataService].verify_token(session[LocalData].stored_session_token)
|
||||
# if user_session is not None:
|
||||
# session.attach(user_session)
|
||||
|
||||
async def on_app_start(a: App) -> None:
|
||||
init_result = await a.default_attachments[4].init_db_pool()
|
||||
@@ -177,6 +178,11 @@ if __name__ == "__main__":
|
||||
url_segment="tournament",
|
||||
build=pages.TournamentDetailsPage,
|
||||
),
|
||||
ComponentPage(
|
||||
name="TournamentTreePage",
|
||||
url_segment="tournament-tree",
|
||||
build=pages.TournamentTreePage,
|
||||
),
|
||||
ComponentPage(
|
||||
name="TournamentRulesPage",
|
||||
url_segment="tournament-rules",
|
||||
@@ -216,7 +222,14 @@ if __name__ == "__main__":
|
||||
}
|
||||
)
|
||||
|
||||
sys.exit(app.run_as_web_server(
|
||||
host="0.0.0.0",
|
||||
port=7321,
|
||||
))
|
||||
try:
|
||||
app.run_as_web_server(
|
||||
host="0.0.0.0",
|
||||
port=8000,
|
||||
)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
logger.info("EZGG LAN Manager was shut down.")
|
||||
sys.exit(0)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
sys.exit(1)
|
||||
|
||||
@@ -20,7 +20,7 @@ from src.ezgg_lan_manager.services.UserService import UserService
|
||||
from src.ezgg_lan_manager.types import *
|
||||
|
||||
# Inits services in the correct order
|
||||
def init_services() -> tuple[AccountingService, CateringService, ConfigurationService, DatabaseService, MailingService, NewsService, SeatingService, TicketingService, UserService, LocalDataService, ReceiptPrintingService, TournamentService, TeamService, RefreshService]:
|
||||
def init_services() -> tuple[AccountingService, CateringService, ConfigurationService, DatabaseService, MailingService, NewsService, SeatingService, TicketingService, UserService, LocalDataService, ReceiptPrintingService, TournamentService, TeamService]:
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
configuration_service = ConfigurationService(from_root("config.toml"))
|
||||
db_service = DatabaseService(configuration_service.get_database_configuration())
|
||||
@@ -37,4 +37,4 @@ def init_services() -> tuple[AccountingService, CateringService, ConfigurationSe
|
||||
team_service = TeamService(db_service)
|
||||
refresh_service = RefreshService()
|
||||
|
||||
return accounting_service, catering_service, configuration_service, db_service, mailing_service, news_service, seating_service, ticketing_service, user_service, local_data_service, receipt_printing_service, tournament_service, team_service, refresh_service
|
||||
return accounting_service, catering_service, configuration_service, db_service, mailing_service, news_service, seating_service, ticketing_service, user_service, local_data_service, receipt_printing_service, tournament_service, team_service
|
||||
|
||||
@@ -27,7 +27,7 @@ class DesktopNavigation(Component):
|
||||
navigation = [
|
||||
DesktopNavigationButton("News", "./news"),
|
||||
Spacer(min_height=0.7),
|
||||
DesktopNavigationButton(f"Über {lan_info.name}", "./overview"),
|
||||
DesktopNavigationButton(f"Über {lan_info.name} {lan_info.iteration}", "./overview"),
|
||||
DesktopNavigationButton("Ticket kaufen", "./buy_ticket"),
|
||||
DesktopNavigationButton("Sitzplan", "./seating"),
|
||||
DesktopNavigationButton("Catering", "./catering"),
|
||||
@@ -48,7 +48,7 @@ class DesktopNavigation(Component):
|
||||
return Card(
|
||||
Column(
|
||||
Text(lan_info.name, align_x=0.5, margin_top=0.3, style=TextStyle(fill=self.session.theme.hud_color, font_size=1.9)),
|
||||
Text(f"Edition {lan_info.iteration}", align_x=0.5, style=TextStyle(fill=self.session.theme.hud_color, font_size=0.9), margin_top=0.3, margin_bottom=2),
|
||||
Text(f"Edition {lan_info.iteration}", align_x=0.5, style=TextStyle(fill=self.session.theme.hud_color, font_size=1.2), margin_top=0.3, margin_bottom=2),
|
||||
user_info_and_login_box,
|
||||
*navigation,
|
||||
Text("Unsere Sponsoren", align_x=0.5, style=TextStyle(fill=self.session.theme.hud_color, font_size=0.9), margin_bottom=0.5, margin_top=1),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from rio import Component, TextStyle, Color, Link, Button, Text
|
||||
|
||||
class DesktopNavigationButton(Component):
|
||||
STYLE = TextStyle(fill=Color.from_hex("02a797"), font_size=0.9)
|
||||
TEAM_STYLE = TextStyle(fill=Color.from_hex("02a797"), font_size=0.9)
|
||||
STYLE = TextStyle(fill=Color.from_hex("02dac5"), font_size=0.9)
|
||||
TEAM_STYLE = TextStyle(fill=Color.from_hex("F0EADE"), font_size=0.9)
|
||||
label: str
|
||||
target_url: str
|
||||
is_team_navigation: bool = False
|
||||
|
||||
@@ -61,7 +61,7 @@ class LoginBox(Component):
|
||||
is_valid=self.password_input_is_valid
|
||||
)
|
||||
login_button = Button(
|
||||
Text("LOGIN", fill=Color.from_hex("02a797"), style=TextStyle(font_size=0.9), justify="center"),
|
||||
Text("LOGIN", fill=Color.from_hex("02dac5"), style=TextStyle(font_size=0.9), justify="center"),
|
||||
shape="rectangle",
|
||||
style="minor",
|
||||
color="secondary",
|
||||
@@ -69,14 +69,14 @@ class LoginBox(Component):
|
||||
on_press=self._on_login_pressed
|
||||
)
|
||||
register_button = Button(
|
||||
Text("REG", fill=Color.from_hex("02a797"), style=TextStyle(font_size=0.9), justify="center"),
|
||||
Text("REG", fill=Color.from_hex("02dac5"), style=TextStyle(font_size=0.9), justify="center"),
|
||||
shape="rectangle",
|
||||
style="minor",
|
||||
color="secondary",
|
||||
on_press=lambda: self.session.navigate_to("./register")
|
||||
)
|
||||
forgot_password_button = Button(
|
||||
Text("LST PWD", fill=Color.from_hex("02a797"), style=TextStyle(font_size=0.9), justify="center"),
|
||||
Text("LST PWD", fill=Color.from_hex("02dac5"), style=TextStyle(font_size=0.9), justify="center"),
|
||||
shape="rectangle",
|
||||
style="minor",
|
||||
color="secondary",
|
||||
|
||||
@@ -5,7 +5,7 @@ from rio import Component, Rectangle, Grid, Column, Row, Text, TextStyle, Color,
|
||||
from src.ezgg_lan_manager.components.SeatingPlanPixels import SeatPixel, WallPixel, InvisiblePixel, TextPixel
|
||||
from src.ezgg_lan_manager.types.Seat import Seat
|
||||
|
||||
MAX_GRID_WIDTH_PIXELS = 34
|
||||
MAX_GRID_WIDTH_PIXELS = 60
|
||||
MAX_GRID_HEIGHT_PIXELS = 60
|
||||
|
||||
class SeatingPlanLegend(Component):
|
||||
@@ -14,6 +14,14 @@ class SeatingPlanLegend(Component):
|
||||
Text("Legende", style=TextStyle(fill=self.session.theme.neutral_color), justify="center", margin=1),
|
||||
Row(
|
||||
Spacer(),
|
||||
Rectangle(
|
||||
content=Text("Normaler Platz", style=TextStyle(fill=self.session.theme.neutral_color, font_size=0.7), margin=0.2, justify="center"),
|
||||
fill=Color.TRANSPARENT,
|
||||
stroke_width=0.2,
|
||||
stroke_color=Color.from_hex("003300"),
|
||||
min_width=20,
|
||||
margin_right=1
|
||||
),
|
||||
Rectangle(
|
||||
content=Text("Deluxe Platz", style=TextStyle(fill=self.session.theme.neutral_color, font_size=0.7), margin=0.2, justify="center"),
|
||||
fill=Color.TRANSPARENT,
|
||||
@@ -99,76 +107,161 @@ class SeatingPlan(Component):
|
||||
for x in range(0, MAX_GRID_WIDTH_PIXELS):
|
||||
grid.add(WallPixel(), row=MAX_GRID_HEIGHT_PIXELS, column=x)
|
||||
|
||||
for y in range(0, 39):
|
||||
grid.add(WallPixel(), row=y, column=MAX_GRID_WIDTH_PIXELS)
|
||||
for x in range(0, 31):
|
||||
grid.add(WallPixel(), row=15, column=x)
|
||||
|
||||
for y in range(43, MAX_GRID_HEIGHT_PIXELS + 1):
|
||||
grid.add(WallPixel(), row=y, column=MAX_GRID_WIDTH_PIXELS)
|
||||
for x in range(41, MAX_GRID_WIDTH_PIXELS):
|
||||
grid.add(WallPixel(), row=32, column=x)
|
||||
|
||||
for x in range(19, MAX_GRID_WIDTH_PIXELS):
|
||||
grid.add(WallPixel(), row=37, column=x)
|
||||
for x in range(31, 34):
|
||||
grid.add(WallPixel(), row=32, column=x)
|
||||
grid.add(WallPixel(), row=19, column=x)
|
||||
|
||||
for x in range(42, MAX_GRID_WIDTH_PIXELS):
|
||||
grid.add(WallPixel(), row=11, column=x)
|
||||
grid.add(WallPixel(), row=22, column=x)
|
||||
|
||||
for x in range(22, 30):
|
||||
grid.add(WallPixel(), row=5, column=x)
|
||||
grid.add(WallPixel(), row=10, column=x)
|
||||
|
||||
for y in range(5, 11):
|
||||
grid.add(WallPixel(), row=y, column=21)
|
||||
grid.add(WallPixel(), row=y, column=30)
|
||||
|
||||
|
||||
for x in range(19, MAX_GRID_WIDTH_PIXELS):
|
||||
grid.add(WallPixel(), row=46, column=x)
|
||||
for x in range(1, 15):
|
||||
grid.add(WallPixel(), row=46, column=x)
|
||||
for y in range(40, MAX_GRID_HEIGHT_PIXELS):
|
||||
grid.add(WallPixel(), row=y, column=30)
|
||||
|
||||
# Gaderobe
|
||||
for y in range(32, 36):
|
||||
grid.add(WallPixel(), row=y, column=30)
|
||||
|
||||
for y in range(19, 33):
|
||||
grid.add(WallPixel(), row=y, column=34)
|
||||
|
||||
for y in range(16, 20):
|
||||
grid.add(WallPixel(), row=y, column=30)
|
||||
|
||||
for y in range(0, 5):
|
||||
grid.add(WallPixel(), row=y, column=41)
|
||||
|
||||
for y in range(9, 15):
|
||||
grid.add(WallPixel(), row=y, column=41)
|
||||
|
||||
for y in range(19, 33):
|
||||
grid.add(WallPixel(), row=y, column=41)
|
||||
|
||||
|
||||
# Block A
|
||||
grid.add(SeatPixel("A01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A01"), seat_orientation="bottom"), row=57, column=1, width=5, height=2)
|
||||
grid.add(SeatPixel("A02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A02"), seat_orientation="bottom"), row=57, column=6, width=5, height=2)
|
||||
grid.add(SeatPixel("A03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A03"), seat_orientation="bottom"), row=57, column=11, width=5, height=2)
|
||||
grid.add(SeatPixel("A04", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A04"), seat_orientation="bottom"), row=57, column=16, width=5, height=2)
|
||||
grid.add(SeatPixel("A05", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A05"), seat_orientation="bottom"), row=57, column=21, width=5, height=2)
|
||||
|
||||
grid.add(SeatPixel("A10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A10"), seat_orientation="top"), row=55, column=1, width=5, height=2)
|
||||
grid.add(SeatPixel("A11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A11"), seat_orientation="top"), row=55, column=6, width=5, height=2)
|
||||
grid.add(SeatPixel("A12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A12"), seat_orientation="top"), row=55, column=11, width=5, height=2)
|
||||
grid.add(SeatPixel("A13", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A13"), seat_orientation="top"), row=55, column=16, width=5, height=2)
|
||||
grid.add(SeatPixel("A14", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A14"), seat_orientation="top"), row=55, column=21, width=5, height=2)
|
||||
|
||||
# Block B
|
||||
grid.add(SeatPixel("B01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B01"), seat_orientation="bottom"), row=50, column=1, width=3, height=2)
|
||||
grid.add(SeatPixel("B02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B02"), seat_orientation="bottom"), row=50, column=4, width=3, height=2)
|
||||
grid.add(SeatPixel("B03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B03"), seat_orientation="bottom"), row=50, column=7, width=3, height=2)
|
||||
grid.add(SeatPixel("B04", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B04"), seat_orientation="bottom"), row=50, column=10, width=3, height=2)
|
||||
grid.add(SeatPixel("B05", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B05"), seat_orientation="bottom"), row=50, column=13, width=3, height=2)
|
||||
grid.add(SeatPixel("B06", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B06"), seat_orientation="bottom"), row=50, column=16, width=3, height=2)
|
||||
|
||||
grid.add(SeatPixel("B10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B10"), seat_orientation="top"), row=48, column=1, width=3, height=2)
|
||||
grid.add(SeatPixel("B11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B11"), seat_orientation="top"), row=48, column=4, width=3, height=2)
|
||||
grid.add(SeatPixel("B12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B12"), seat_orientation="top"), row=48, column=7, width=3, height=2)
|
||||
grid.add(SeatPixel("B13", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B13"), seat_orientation="top"), row=48, column=10, width=3, height=2)
|
||||
grid.add(SeatPixel("B14", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B14"), seat_orientation="top"), row=48, column=13, width=3, height=2)
|
||||
grid.add(SeatPixel("B15", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B15"), seat_orientation="top"), row=48, column=16, width=3, height=2)
|
||||
|
||||
# Block C
|
||||
grid.add(SeatPixel("C01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C01"), seat_orientation="bottom"), row=43, column=1, width=3, height=2)
|
||||
grid.add(SeatPixel("C02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C02"), seat_orientation="bottom"), row=43, column=4, width=3, height=2)
|
||||
grid.add(SeatPixel("C03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C03"), seat_orientation="bottom"), row=43, column=7, width=3, height=2)
|
||||
grid.add(SeatPixel("C04", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C04"), seat_orientation="bottom"), row=43, column=10, width=3, height=2)
|
||||
grid.add(SeatPixel("C05", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C05"), seat_orientation="bottom"), row=43, column=13, width=3, height=2)
|
||||
grid.add(SeatPixel("C06", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C06"), seat_orientation="bottom"), row=43, column=16, width=3, height=2)
|
||||
|
||||
grid.add(SeatPixel("C10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C10"), seat_orientation="top"), row=41, column=1, width=3, height=2)
|
||||
grid.add(SeatPixel("C11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C11"), seat_orientation="top"), row=41, column=4, width=3, height=2)
|
||||
grid.add(SeatPixel("C12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C12"), seat_orientation="top"), row=41, column=7, width=3, height=2)
|
||||
grid.add(SeatPixel("C13", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C13"), seat_orientation="top"), row=41, column=10, width=3, height=2)
|
||||
grid.add(SeatPixel("C14", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C14"), seat_orientation="top"), row=41, column=13, width=3, height=2)
|
||||
grid.add(SeatPixel("C15", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C15"), seat_orientation="top"), row=41, column=16, width=3, height=2)
|
||||
|
||||
# Block D
|
||||
grid.add(SeatPixel("D01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D01"), seat_orientation="bottom"), row=34, column=1, width=5, height=2)
|
||||
grid.add(SeatPixel("D02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D02"), seat_orientation="bottom"), row=34, column=6, width=5, height=2)
|
||||
grid.add(SeatPixel("D03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D03"), seat_orientation="bottom"), row=34, column=11, width=5, height=2)
|
||||
grid.add(SeatPixel("D04", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D04"), seat_orientation="bottom"), row=34, column=16, width=5, height=2)
|
||||
grid.add(SeatPixel("D05", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D05"), seat_orientation="bottom"), row=34, column=21, width=5, height=2)
|
||||
|
||||
grid.add(SeatPixel("D10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D10"), seat_orientation="top"), row=32, column=1, width=5, height=2)
|
||||
grid.add(SeatPixel("D11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D11"), seat_orientation="top"), row=32, column=6, width=5, height=2)
|
||||
grid.add(SeatPixel("D12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D12"), seat_orientation="top"), row=32, column=11, width=5, height=2)
|
||||
grid.add(SeatPixel("D13", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D13"), seat_orientation="top"), row=32, column=16, width=5, height=2)
|
||||
grid.add(SeatPixel("D14", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D14"), seat_orientation="top"), row=32, column=21, width=5, height=2)
|
||||
|
||||
# Block E
|
||||
grid.add(SeatPixel("E01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E01"), seat_orientation="bottom"), row=27, column=1, width=5, height=2)
|
||||
grid.add(SeatPixel("E02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E02"), seat_orientation="bottom"), row=27, column=6, width=5, height=2)
|
||||
grid.add(SeatPixel("E03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E03"), seat_orientation="bottom"), row=27, column=11, width=5, height=2)
|
||||
grid.add(SeatPixel("E04", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E04"), seat_orientation="bottom"), row=27, column=16, width=5, height=2)
|
||||
grid.add(SeatPixel("E05", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E05"), seat_orientation="bottom"), row=27, column=21, width=5, height=2)
|
||||
|
||||
grid.add(SeatPixel("E10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E10"), seat_orientation="top"), row=25, column=1, width=5, height=2)
|
||||
grid.add(SeatPixel("E11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E11"), seat_orientation="top"), row=25, column=6, width=5, height=2)
|
||||
grid.add(SeatPixel("E12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E12"), seat_orientation="top"), row=25, column=11, width=5, height=2)
|
||||
grid.add(SeatPixel("E13", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E13"), seat_orientation="top"), row=25, column=16, width=5, height=2)
|
||||
grid.add(SeatPixel("E14", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E14"), seat_orientation="top"), row=25, column=21, width=5, height=2)
|
||||
|
||||
# Stage
|
||||
grid.add(PointerEventListener(
|
||||
TextPixel(text="Gaderobe"),
|
||||
on_press=lambda _: self.info_clicked_cb("Gaderobe")
|
||||
), row=44, column=19, width=15, height=2)
|
||||
TextPixel(text="Bühne"),
|
||||
on_press=lambda _: self.info_clicked_cb("Hier darf ab Freitag 20 Uhr ebenfalls geschlafen werden.")
|
||||
), row=16, column=1, width=29, height=4)
|
||||
|
||||
for x in range(19, MAX_GRID_WIDTH_PIXELS):
|
||||
grid.add(WallPixel(), row=28, column=x)
|
||||
for x in range(1, 15):
|
||||
grid.add(WallPixel(), row=28, column=x)
|
||||
# Drinks
|
||||
grid.add(PointerEventListener(
|
||||
TextPixel(text="G\ne\nt\nr\nä\nn\nk\ne"),
|
||||
on_press=lambda _: self.info_clicked_cb("Ich mag Bier, B - I - R")
|
||||
), row=20, column=30, width=4, height=12)
|
||||
|
||||
# # Toilet
|
||||
# Main Entrance
|
||||
grid.add(PointerEventListener(
|
||||
TextPixel(text="H\na\nl\nl\ne\nn\n\ne\ni\nn\ng\na\nn\ng"),
|
||||
on_press=lambda _: self.info_clicked_cb("Hallo, ich bin ein Haupteingang")
|
||||
), row=33, column=56, width=4, height=27)
|
||||
|
||||
# Sleeping
|
||||
grid.add(PointerEventListener(
|
||||
TextPixel(icon_name="material/bed"),
|
||||
on_press=lambda _: self.info_clicked_cb("In diesem Raum kann geschlafen werden.\nAchtung: Hier werden nicht alle Teilnehmer Platz finden.")
|
||||
), row=1, column=1, width=20, height=14)
|
||||
|
||||
# Toilet
|
||||
grid.add(PointerEventListener(
|
||||
TextPixel(icon_name="material/wc"),
|
||||
on_press=lambda _: self.info_clicked_cb("Toilette")
|
||||
), row=29, column=1, width=14, height=17)
|
||||
|
||||
on_press=lambda _: self.info_clicked_cb("Damen Toilette")
|
||||
), row=1, column=42, width=19, height=10)
|
||||
grid.add(PointerEventListener(
|
||||
TextPixel(text="Orga & Technik"),
|
||||
on_press=lambda _: self.info_clicked_cb("Hier bauen wir die Technik auf.")
|
||||
), row=29, column=19, width=15, height=8)
|
||||
TextPixel(icon_name="material/wc"),
|
||||
on_press=lambda _: self.info_clicked_cb("Herren Toilette")
|
||||
), row=12, column=42, width=19, height=10)
|
||||
|
||||
# Entry/Helpdesk
|
||||
grid.add(PointerEventListener(
|
||||
TextPixel(text="Bar & Schnarchbereich"),
|
||||
on_press=lambda _: self.info_clicked_cb("Bier.")
|
||||
), row=47, column=1, width=MAX_GRID_WIDTH_PIXELS-1, height=13)
|
||||
TextPixel(text="Einlass\n &Orga"),
|
||||
on_press=lambda _: self.info_clicked_cb("Für alle Anliegen findest du hier rund um die Uhr jemanden vom Team.")
|
||||
), row=40, column=22, width=8, height=12)
|
||||
|
||||
# # Block A
|
||||
grid.add(SeatPixel("A\n0\n1", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A01"), seat_orientation="left"), row=2, column=5, width=2, height=4)
|
||||
grid.add(SeatPixel("A\n0\n2", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A02"), seat_orientation="left"), row=6, column=5, width=2, height=4)
|
||||
grid.add(SeatPixel("A\n0\n3", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A03"), seat_orientation="left"), row=10, column=5, width=2, height=4)
|
||||
grid.add(SeatPixel("A\n0\n4", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A04"), seat_orientation="left"), row=15, column=5, width=2, height=4)
|
||||
grid.add(SeatPixel("A\n0\n5", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A05"), seat_orientation="left"), row=19, column=5, width=2, height=4)
|
||||
grid.add(SeatPixel("A\n0\n6", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A06"), seat_orientation="left"), row=23, column=5, width=2, height=4)
|
||||
|
||||
grid.add(SeatPixel("A\n1\n0", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A10"), seat_orientation="left"), row=2, column=7, width=2, height=4)
|
||||
grid.add(SeatPixel("A\n1\n1", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A11"), seat_orientation="left"), row=6, column=7, width=2, height=4)
|
||||
grid.add(SeatPixel("A\n1\n2", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A12"), seat_orientation="left"), row=10, column=7, width=2, height=4)
|
||||
grid.add(SeatPixel("A\n1\n3", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A13"), seat_orientation="left"), row=15, column=7, width=2, height=4)
|
||||
grid.add(SeatPixel("A\n1\n4", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A14"), seat_orientation="left"), row=19, column=7, width=2, height=4)
|
||||
grid.add(SeatPixel("A\n1\n5", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A15"), seat_orientation="left"), row=23, column=7, width=2, height=4)
|
||||
|
||||
grid.add(SeatPixel("B\n0\n1", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B01"), seat_orientation="left"), row=2, column=26, width=2, height=4)
|
||||
grid.add(SeatPixel("B\n0\n2", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B02"), seat_orientation="left"), row=6, column=26, width=2, height=4)
|
||||
grid.add(SeatPixel("B\n0\n3", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B03"), seat_orientation="left"), row=10, column=26, width=2, height=4)
|
||||
grid.add(SeatPixel("B\n0\n4", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B04"), seat_orientation="left"), row=15, column=26, width=2, height=4)
|
||||
grid.add(SeatPixel("B\n0\n5", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B05"), seat_orientation="left"), row=19, column=26, width=2, height=4)
|
||||
grid.add(SeatPixel("B\n0\n6", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B06"), seat_orientation="left"), row=23, column=26, width=2, height=4)
|
||||
|
||||
grid.add(SeatPixel("B\n1\n0", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B10"), seat_orientation="left"), row=2, column=28, width=2, height=4)
|
||||
grid.add(SeatPixel("B\n1\n1", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B11"), seat_orientation="left"), row=6, column=28, width=2, height=4)
|
||||
grid.add(SeatPixel("B\n1\n2", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B12"), seat_orientation="left"), row=10, column=28, width=2, height=4)
|
||||
grid.add(SeatPixel("B\n1\n3", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B13"), seat_orientation="left"), row=15, column=28, width=2, height=4)
|
||||
grid.add(SeatPixel("B\n1\n4", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B14"), seat_orientation="left"), row=19, column=28, width=2, height=4)
|
||||
grid.add(SeatPixel("B\n1\n5", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B15"), seat_orientation="left"), row=23, column=28, width=2, height=4)
|
||||
return Rectangle(
|
||||
content=grid,
|
||||
grow_x=True,
|
||||
|
||||
@@ -11,7 +11,7 @@ class SeatPixel(Component):
|
||||
seat_id: str
|
||||
on_press_cb: Callable
|
||||
seat: Seat
|
||||
seat_orientation: Literal["top", "bottom", "left", "right"]
|
||||
seat_orientation: Literal["top", "bottom"]
|
||||
|
||||
def determine_color(self) -> Color:
|
||||
try:
|
||||
|
||||
@@ -60,15 +60,18 @@ class UserInfoBox(Component):
|
||||
self.session[LocalDataService].del_session(self.session[LocalData].stored_session_token)
|
||||
self.session[LocalData].stored_session_token = None
|
||||
self.session.attach(self.session[LocalData])
|
||||
await self.status_change_cb()
|
||||
if self.status_change_cb is not None:
|
||||
await self.status_change_cb()
|
||||
await self.session[RefreshService].trigger_refresh()
|
||||
self.session.navigate_to("")
|
||||
|
||||
@event.on_populate
|
||||
async def async_init(self) -> None:
|
||||
self.user = await self.session[UserService].get_user(self.user_id)
|
||||
self.user_balance = await self.session[AccountingService].get_balance(self.user.user_id)
|
||||
self.user_ticket = await self.session[TicketingService].get_user_ticket(self.user.user_id)
|
||||
self.user_seat = await self.session[SeatingService].get_user_seat(self.user.user_id)
|
||||
if self.user is not None:
|
||||
self.user_balance = await self.session[AccountingService].get_balance(self.user.user_id)
|
||||
self.user_ticket = await self.session[TicketingService].get_user_ticket(self.user.user_id)
|
||||
self.user_seat = await self.session[SeatingService].get_user_seat(self.user.user_id)
|
||||
self.session[AccountingService].add_update_hook(self.update)
|
||||
|
||||
async def update(self) -> None:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from decimal import Decimal
|
||||
from typing import Optional
|
||||
|
||||
from rio import Column, Component, event, Text, TextStyle, Button, Color, Revealer, Row, ProgressCircle, Link
|
||||
from rio import Column, Component, event, Text, TextStyle, Button, Color, Revealer, Row, ProgressCircle, Link, Image
|
||||
|
||||
from src.ezgg_lan_manager import ConfigurationService, UserService, AccountingService
|
||||
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||
@@ -14,6 +14,7 @@ class AccountPage(Component):
|
||||
user: Optional[User] = None
|
||||
balance: Optional[Decimal] = None
|
||||
transaction_history: list[Transaction] = list()
|
||||
payment_qr_image: bytes = None
|
||||
banking_info_revealer_open: bool = False
|
||||
paypal_info_revealer_open: bool = False
|
||||
|
||||
@@ -28,6 +29,11 @@ class AccountPage(Component):
|
||||
self.user = await self.session[UserService].get_user(user_id)
|
||||
self.balance = await self.session[AccountingService].get_balance(user_id)
|
||||
self.transaction_history = await self.session[AccountingService].get_transaction_history(user_id)
|
||||
self.payment_qr_image = self.session[AccountingService].make_payment_qr_image(
|
||||
"Einfach Zocken Gaming Gesellschaft",
|
||||
"GENODE51BIK",
|
||||
"DE47517624340019856607",
|
||||
f"AUFLADUNG - {self.user.user_id} - {self.user.user_name}")
|
||||
|
||||
async def _on_banking_info_press(self) -> None:
|
||||
self.banking_info_revealer_open = not self.banking_info_revealer_open
|
||||
@@ -36,7 +42,7 @@ class AccountPage(Component):
|
||||
self.paypal_info_revealer_open = not self.paypal_info_revealer_open
|
||||
|
||||
def build(self) -> Component:
|
||||
if not self.user and not self.balance:
|
||||
if not self.user or not self.payment_qr_image:
|
||||
return Column(
|
||||
MainViewContentBox(
|
||||
ProgressCircle(
|
||||
@@ -85,6 +91,10 @@ class AccountPage(Component):
|
||||
margin=0,
|
||||
margin_bottom=1,
|
||||
align_x=0.5
|
||||
),
|
||||
Image(self.payment_qr_image,
|
||||
min_width=20,
|
||||
min_height=20
|
||||
)
|
||||
),
|
||||
margin=2,
|
||||
@@ -223,19 +233,20 @@ class AccountPage(Component):
|
||||
on_press=self._on_paypal_info_press
|
||||
),
|
||||
paypal_info_revealer,
|
||||
Link(
|
||||
content=Button(
|
||||
content=Text("PAYPAL (3% Gebühr - Gewerblich)", style=TextStyle(fill=Color.from_hex("121212"), font_size=0.8), justify="center"),
|
||||
shape="rectangle",
|
||||
style="major",
|
||||
color="secondary",
|
||||
grow_x=True,
|
||||
margin=2,
|
||||
margin_top=0
|
||||
),
|
||||
target_url="https://www.paypal.com/ncp/payment/89YMGVZ4S33RS",
|
||||
open_in_new_tab=True
|
||||
)
|
||||
# Disabled because people did not understand the fee's and kept charging 24.03 € to their accounts
|
||||
# Link(
|
||||
# content=Button(
|
||||
# content=Text("PAYPAL (3% Gebühr - Gewerblich)", style=TextStyle(fill=Color.from_hex("121212"), font_size=0.8), justify="center"),
|
||||
# shape="rectangle",
|
||||
# style="major",
|
||||
# color="secondary",
|
||||
# grow_x=True,
|
||||
# margin=2,
|
||||
# margin_top=0
|
||||
# ),
|
||||
# target_url="https://www.paypal.com/ncp/payment/89YMGVZ4S33RS",
|
||||
# open_in_new_tab=True
|
||||
# )
|
||||
)
|
||||
),
|
||||
MainViewContentBox(
|
||||
|
||||
@@ -18,7 +18,6 @@ class CateringPage(Component):
|
||||
|
||||
@event.on_populate
|
||||
async def on_populate(self) -> None:
|
||||
self.session[RefreshService].subscribe(self.on_populate)
|
||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Catering")
|
||||
self.all_menu_items = await self.session[CateringService].get_menu()
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBo
|
||||
from src.ezgg_lan_manager.types.DateUtil import weekday_to_display_text
|
||||
from src.ezgg_lan_manager.types.Participant import Participant
|
||||
from src.ezgg_lan_manager.types.Tournament import Tournament
|
||||
from src.ezgg_lan_manager.types.TournamentBase import TournamentStatus
|
||||
from src.ezgg_lan_manager.types.TournamentBase import TournamentStatus, TournamentError
|
||||
|
||||
logger = logging.getLogger(__name__.split(".")[-1])
|
||||
|
||||
@@ -29,7 +29,10 @@ class ManageTournamentsPage(Component):
|
||||
|
||||
async def on_start_pressed(self, tournament_id: int) -> None:
|
||||
logger.info(f"Starting tournament with ID {tournament_id}")
|
||||
await self.session[TournamentService].start_tournament(tournament_id)
|
||||
try:
|
||||
await self.session[TournamentService].start_tournament(tournament_id)
|
||||
except TournamentError as e:
|
||||
logger.error(f"Error trying to start tournament: {e}")
|
||||
|
||||
async def on_cancel_pressed(self, tournament_id: int) -> None:
|
||||
logger.info(f"Canceling tournament with ID {tournament_id}")
|
||||
@@ -92,9 +95,17 @@ class ManageTournamentsPage(Component):
|
||||
font_size=1.2
|
||||
),
|
||||
margin_top=2,
|
||||
margin_bottom=2,
|
||||
margin_bottom=1,
|
||||
align_x=0.5
|
||||
),
|
||||
Button(
|
||||
content="Cache erneuern",
|
||||
shape="rectangle",
|
||||
style="colored-text",
|
||||
margin_bottom=2,
|
||||
align_x=0.5,
|
||||
on_press=self.session[TournamentService].queue_cache_renewal
|
||||
),
|
||||
*tournament_rows
|
||||
)
|
||||
),
|
||||
|
||||
@@ -31,13 +31,13 @@ class OverviewPage(Component):
|
||||
Row(
|
||||
Text("Wo?", fill=self.session.theme.neutral_color, margin_left=1),
|
||||
Spacer(),
|
||||
Link(Text(f"Hasenheim Bottenhorn", fill=self.session.theme.secondary_color, margin_right=1), target_url="https://maps.app.goo.gl/9Gtykc3FEqWSWy9b6", open_in_new_tab=True),
|
||||
Link(Text(f"DGH Donsbach", fill=self.session.theme.secondary_color, margin_right=1), target_url="https://maps.app.goo.gl/3Zyue776A22jdoxz5", open_in_new_tab=True),
|
||||
margin_bottom=0.3
|
||||
),
|
||||
Row(
|
||||
Text("Einlass", fill=self.session.theme.neutral_color, margin_left=1),
|
||||
Spacer(),
|
||||
Text(lan_info.date_from.strftime("Samstag %H:%M Uhr"), fill=self.session.theme.neutral_color, margin_right=1),
|
||||
Text(lan_info.date_from.strftime("Freitag %H:%M Uhr"), fill=self.session.theme.neutral_color, margin_right=1),
|
||||
margin_bottom=0.3
|
||||
),
|
||||
Row(
|
||||
@@ -75,19 +75,19 @@ class OverviewPage(Component):
|
||||
Row(
|
||||
Text("Internet", fill=self.session.theme.neutral_color, margin_left=1),
|
||||
Spacer(),
|
||||
Text(f"Wenn's gut läuft, ja", fill=self.session.theme.neutral_color, margin_right=1),
|
||||
Text(f"100/50 Mbit/s (down/up)", fill=self.session.theme.neutral_color, margin_right=1),
|
||||
margin_bottom=0.3
|
||||
),
|
||||
Row(
|
||||
Text("Routing", fill=self.session.theme.neutral_color, margin_left=1),
|
||||
Spacer(),
|
||||
Text(f"Hoffentlich", fill=self.session.theme.neutral_color, margin_right=1),
|
||||
Text(f"Flaches Netz", fill=self.session.theme.neutral_color, margin_right=1),
|
||||
margin_bottom=0.3
|
||||
),
|
||||
Row(
|
||||
Text("WLAN", fill=self.session.theme.neutral_color, margin_left=1),
|
||||
Spacer(),
|
||||
Text(f"nö", fill=self.session.theme.neutral_color, margin_right=1),
|
||||
Text(f"vorhanden", fill=self.session.theme.neutral_color, margin_right=1),
|
||||
margin_bottom=0.3
|
||||
)
|
||||
)
|
||||
@@ -102,7 +102,7 @@ class OverviewPage(Component):
|
||||
margin_bottom=0.3
|
||||
),
|
||||
Row(
|
||||
Text("Für ein paar Luftmatratzen ist Platz. Die Bottenhorner Vereinsmitglieder überlassen sich auch die ein oder andere Couch.", font_size=0.7,
|
||||
Text("Es steht ein Schlafsaal zur Verfügung. Nach der Eröffnung steht auch die Bühne als Schlafbereich zur Verfügung.", font_size=0.7,
|
||||
fill=self.session.theme.neutral_color, margin_left=1, overflow="wrap"),
|
||||
margin_bottom=0.3
|
||||
),
|
||||
@@ -111,7 +111,15 @@ class OverviewPage(Component):
|
||||
margin_bottom=0.3
|
||||
),
|
||||
Row(
|
||||
Text("Jeder bringt einfach mit was er mag.", font_size=0.7, fill=self.session.theme.neutral_color, margin_left=1, overflow="wrap"),
|
||||
Text("Wir sorgen für euer leibliches Wohl, ihr dürft aber auch eure eigenen Speißen und Getränke mitbringen.", font_size=0.7, fill=self.session.theme.neutral_color, margin_left=1, overflow="wrap"),
|
||||
margin_bottom=0.3
|
||||
),
|
||||
Row(
|
||||
Text("Parken", fill=self.session.theme.neutral_color, margin_left=1, justify="center"),
|
||||
margin_bottom=0.3
|
||||
),
|
||||
Row(
|
||||
Text("Vor der Halle sind ausreichend Parkplätze vorhanden.", font_size=0.7, fill=self.session.theme.neutral_color, margin_left=1, overflow="wrap"),
|
||||
margin_bottom=0.3
|
||||
)
|
||||
)
|
||||
|
||||
@@ -51,7 +51,6 @@ class SeatingPlanPage(Component):
|
||||
self.is_booking_blocked = True
|
||||
|
||||
async def on_seat_clicked(self, seat_id: str, _: PressEvent) -> None:
|
||||
seat_id = seat_id.replace("\n", "")
|
||||
self.seating_info_text = ""
|
||||
self.show_info_box = True
|
||||
self.show_purchase_box = False
|
||||
|
||||
@@ -7,13 +7,13 @@ from from_root import from_root
|
||||
from rio import Column, Component, event, TextStyle, Text, Row, Image, Spacer, ProgressCircle, Button, Checkbox, ThemeContextSwitcher, Link, Revealer, PointerEventListener, \
|
||||
PointerEvent, Rectangle, Color, Popup, Dropdown
|
||||
|
||||
from src.ezgg_lan_manager import ConfigurationService, TournamentService, UserService, TicketingService, TeamService
|
||||
from src.ezgg_lan_manager import ConfigurationService, TournamentService, UserService, TicketingService, TeamService, RefreshService
|
||||
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||
from src.ezgg_lan_manager.components.TournamentDetailsInfoRow import TournamentDetailsInfoRow
|
||||
from src.ezgg_lan_manager.types.DateUtil import weekday_to_display_text
|
||||
from src.ezgg_lan_manager.types.Team import Team, TeamStatus
|
||||
from src.ezgg_lan_manager.types.Tournament import Tournament
|
||||
from src.ezgg_lan_manager.types.TournamentBase import TournamentStatus, tournament_status_to_display_text, tournament_format_to_display_texts, ParticipantType
|
||||
from src.ezgg_lan_manager.types.TournamentBase import TournamentStatus, tournament_status_to_display_text, tournament_format_to_display_texts, ParticipantType, TournamentFormat
|
||||
from src.ezgg_lan_manager.types.User import User
|
||||
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||
|
||||
@@ -44,7 +44,7 @@ class TournamentDetailsPage(Component):
|
||||
tournament_id = None
|
||||
if tournament_id is not None:
|
||||
self.tournament = await self.session[TournamentService].get_tournament_by_id(tournament_id)
|
||||
if self.tournament is not None:
|
||||
if isinstance(self.tournament, Tournament):
|
||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - {self.tournament.name}")
|
||||
if self.tournament.participant_type == ParticipantType.PLAYER:
|
||||
self.current_tournament_user_or_team_list = await self.session[TournamentService].get_users_from_participant_list(self.tournament.participants)
|
||||
@@ -61,6 +61,8 @@ class TournamentDetailsPage(Component):
|
||||
self.user = None
|
||||
self.user_teams = []
|
||||
|
||||
self.session[RefreshService].subscribe(self.on_populate)
|
||||
|
||||
self.loading_done()
|
||||
|
||||
@staticmethod
|
||||
@@ -68,13 +70,14 @@ class TournamentDetailsPage(Component):
|
||||
await sleep(0.8) # https://medium.com/design-bootcamp/ux-psychology-of-artificial-waiting-enhancing-user-experiences-through-deliberate-delays-d7822faf3930
|
||||
|
||||
async def update(self) -> None:
|
||||
self.tournament = await self.session[TournamentService].get_tournament_by_id(self.tournament.id)
|
||||
if self.tournament is None:
|
||||
return
|
||||
if self.tournament.participant_type == ParticipantType.PLAYER:
|
||||
self.current_tournament_user_or_team_list = await self.session[TournamentService].get_users_from_participant_list(self.tournament.participants)
|
||||
elif self.tournament.participant_type == ParticipantType.TEAM:
|
||||
self.current_tournament_user_or_team_list = await self.session[TournamentService].get_teams_from_participant_list(self.tournament.participants)
|
||||
if isinstance(self.tournament, Tournament):
|
||||
self.tournament = await self.session[TournamentService].get_tournament_by_id(self.tournament.id)
|
||||
if self.tournament is None or isinstance(self.tournament, str):
|
||||
return
|
||||
if self.tournament.participant_type == ParticipantType.PLAYER:
|
||||
self.current_tournament_user_or_team_list = await self.session[TournamentService].get_users_from_participant_list(self.tournament.participants)
|
||||
elif self.tournament.participant_type == ParticipantType.TEAM:
|
||||
self.current_tournament_user_or_team_list = await self.session[TournamentService].get_teams_from_participant_list(self.tournament.participants)
|
||||
|
||||
def open_close_participant_revealer(self, _: PointerEvent) -> None:
|
||||
self.participant_revealer_open = not self.participant_revealer_open
|
||||
@@ -88,6 +91,9 @@ class TournamentDetailsPage(Component):
|
||||
if user_ticket is None:
|
||||
self.is_success = False
|
||||
self.message = "Turnieranmeldung nur mit Ticket"
|
||||
elif not isinstance(self.tournament, Tournament):
|
||||
self.is_success = False
|
||||
self.message = "Fehler bei der Anmeldung"
|
||||
else:
|
||||
# Register single player
|
||||
if self.tournament.participant_type == ParticipantType.PLAYER:
|
||||
@@ -125,12 +131,15 @@ class TournamentDetailsPage(Component):
|
||||
await self.on_team_register_canceled()
|
||||
return
|
||||
try:
|
||||
await self.session[TournamentService].register_team_for_tournament(self.team_selected_for_register.id, self.tournament.id)
|
||||
await self.artificial_delay()
|
||||
self.is_success = True
|
||||
self.message = f"Erfolgreich angemeldet!"
|
||||
self.team_dialog_open = False
|
||||
self.team_selected_for_register = None
|
||||
if isinstance(self.tournament, Tournament):
|
||||
await self.session[TournamentService].register_team_for_tournament(self.team_selected_for_register.id, self.tournament.id)
|
||||
await self.artificial_delay()
|
||||
self.is_success = True
|
||||
self.message = f"Erfolgreich angemeldet!"
|
||||
self.team_dialog_open = False
|
||||
self.team_selected_for_register = None
|
||||
else:
|
||||
raise ValueError("Turnier nicht gefunden")
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
self.message = f"Fehler: {e}"
|
||||
@@ -149,9 +158,9 @@ class TournamentDetailsPage(Component):
|
||||
return
|
||||
|
||||
try:
|
||||
if self.tournament.participant_type == ParticipantType.PLAYER:
|
||||
if isinstance(self.tournament, Tournament) and self.tournament.participant_type == ParticipantType.PLAYER:
|
||||
await self.session[TournamentService].unregister_user_from_tournament(self.user.user_id, self.tournament.id)
|
||||
elif self.tournament.participant_type == ParticipantType.TEAM:
|
||||
elif isinstance(self.tournament, Tournament) and self.tournament.participant_type == ParticipantType.TEAM:
|
||||
if team.members[self.user] == TeamStatus.OFFICER or team.members[self.user] == TeamStatus.LEADER:
|
||||
await self.session[TournamentService].unregister_team_from_tournament(team.id, self.tournament.id)
|
||||
else:
|
||||
@@ -166,7 +175,8 @@ class TournamentDetailsPage(Component):
|
||||
self.loading = False
|
||||
|
||||
async def tree_button_clicked(self) -> None:
|
||||
pass # ToDo: Implement tournament tree view
|
||||
if isinstance(self.tournament, Tournament):
|
||||
self.session.navigate_to(f"tournament-tree?id={self.tournament.id}")
|
||||
|
||||
def loading_done(self) -> None:
|
||||
if self.tournament is None:
|
||||
@@ -205,16 +215,17 @@ class TournamentDetailsPage(Component):
|
||||
tournament_status_color = self.session.theme.danger_color
|
||||
elif self.tournament.status == TournamentStatus.ONGOING or self.tournament.status == TournamentStatus.COMPLETED:
|
||||
tournament_status_color = self.session.theme.warning_color
|
||||
tree_button = Button(
|
||||
content="Turnierbaum anzeigen",
|
||||
shape="rectangle",
|
||||
style="minor",
|
||||
color="hud",
|
||||
margin_left=4,
|
||||
margin_right=4,
|
||||
margin_top=1,
|
||||
on_press=self.tree_button_clicked
|
||||
)
|
||||
if self.tournament.format != TournamentFormat.FFA:
|
||||
tree_button = Button(
|
||||
content="Turnierbaum anzeigen",
|
||||
shape="rectangle",
|
||||
style="minor",
|
||||
color="hud",
|
||||
margin_left=4,
|
||||
margin_right=4,
|
||||
margin_top=1,
|
||||
on_press=self.tree_button_clicked
|
||||
)
|
||||
|
||||
ids_of_participants = [p.id for p in self.tournament.participants]
|
||||
color_key: Literal["hud", "danger"] = "hud"
|
||||
@@ -349,7 +360,7 @@ class TournamentDetailsPage(Component):
|
||||
button
|
||||
)
|
||||
|
||||
if self.tournament and self.tournament.participant_type == ParticipantType.TEAM:
|
||||
if isinstance(self.tournament, Tournament) and self.tournament.participant_type == ParticipantType.TEAM:
|
||||
content = Popup(
|
||||
anchor=content,
|
||||
content=Rectangle(
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
import json
|
||||
import logging
|
||||
from typing import Optional, Union
|
||||
|
||||
from from_root import from_root
|
||||
from rio import Column, Component, event, TextStyle, Text, Row, Spacer, ProgressCircle, Rectangle, Stack
|
||||
|
||||
from src.ezgg_lan_manager import ConfigurationService, TournamentService, UserService, TeamService, RefreshService, SeatingService
|
||||
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||
from src.ezgg_lan_manager.types.Team import Team, TeamStatus
|
||||
from src.ezgg_lan_manager.types.Tournament import Tournament
|
||||
from src.ezgg_lan_manager.types.TournamentBase import ParticipantType, TournamentFormat
|
||||
from src.ezgg_lan_manager.types.User import User
|
||||
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||
|
||||
logger = logging.getLogger(__name__.split(".")[-1])
|
||||
|
||||
class MatchInfo(Component):
|
||||
opponent_1: str = ""
|
||||
opponent_2: str = ""
|
||||
opponent_1_seat: str = ""
|
||||
opponent_2_seat: str = ""
|
||||
winner: str = ""
|
||||
|
||||
def build(self) -> Component:
|
||||
return Rectangle(
|
||||
content=Column(
|
||||
Stack(
|
||||
Row(
|
||||
Row(
|
||||
Text(
|
||||
text=self.opponent_1,
|
||||
style=TextStyle(fill=self.session.theme.success_color if self.winner == self.opponent_1 else self.session.theme.background_color),
|
||||
justify="left",
|
||||
margin_right=0.6,
|
||||
font_size=0.9
|
||||
),
|
||||
Text(
|
||||
text=f"({self.opponent_1_seat})" if self.opponent_1_seat else "Freilos",
|
||||
style=TextStyle(fill=self.session.theme.background_color),
|
||||
justify="left",
|
||||
font_size=0.9
|
||||
)
|
||||
),
|
||||
Spacer(),
|
||||
Row(
|
||||
Text(
|
||||
text=self.opponent_2,
|
||||
style=TextStyle(fill=self.session.theme.success_color if self.winner == self.opponent_2 else self.session.theme.background_color),
|
||||
justify="right",
|
||||
margin_right=0.6,
|
||||
font_size=0.9
|
||||
),
|
||||
Text(
|
||||
text=f"({self.opponent_2_seat})" if self.opponent_2_seat else "Freilos",
|
||||
style=TextStyle(fill=self.session.theme.background_color),
|
||||
justify="right",
|
||||
font_size=0.9
|
||||
)
|
||||
),
|
||||
margin=0.3
|
||||
),
|
||||
Row(
|
||||
Text(
|
||||
text=f"vs.",
|
||||
style=TextStyle(fill=self.session.theme.background_color),
|
||||
justify="center"
|
||||
),
|
||||
margin=0.3
|
||||
)
|
||||
)
|
||||
),
|
||||
margin=1,
|
||||
stroke_width=0.2,
|
||||
stroke_color=self.session.theme.background_color,
|
||||
fill=self.session.theme.hud_color,
|
||||
)
|
||||
|
||||
class TournamentTreePage(Component):
|
||||
tournament: Optional[Union[Tournament, str]] = None
|
||||
user: Optional[User] = None
|
||||
teams: list[Team] = []
|
||||
id_to_username_map: dict[int, str] = {}
|
||||
id_to_seat_map: dict[int, str] = {}
|
||||
is_fully_loaded: bool = False
|
||||
|
||||
@event.on_populate
|
||||
async def on_populate(self) -> None:
|
||||
try:
|
||||
tournament_id = int(self.session.active_page_url.query_string.split("id=")[-1])
|
||||
except (ValueError, AttributeError, TypeError):
|
||||
tournament_id = None
|
||||
if tournament_id is not None:
|
||||
self.tournament = await self.session[TournamentService].get_tournament_by_id(tournament_id)
|
||||
if isinstance(self.tournament, Tournament):
|
||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - {self.tournament.name}")
|
||||
else:
|
||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Turniere")
|
||||
|
||||
try:
|
||||
user_id = self.session[UserSession].user_id
|
||||
self.user = await self.session[UserService].get_user(user_id)
|
||||
except KeyError:
|
||||
self.user = None
|
||||
|
||||
self.teams = await self.session[TeamService].get_all_teams()
|
||||
|
||||
all_users = await self.session[UserService].get_all_users()
|
||||
id_to_username_map = {}
|
||||
id_to_seat_map = {}
|
||||
for user in all_users:
|
||||
id_to_username_map[user.user_id] = user.user_name
|
||||
seat = await self.session[SeatingService].get_user_seat(user.user_id)
|
||||
if seat is not None:
|
||||
id_to_seat_map[user.user_id] = seat.seat_id
|
||||
|
||||
self.id_to_username_map = id_to_username_map
|
||||
self.id_to_seat_map = id_to_seat_map
|
||||
self.session[RefreshService].subscribe(self.on_populate)
|
||||
self.is_fully_loaded = True
|
||||
|
||||
def _get_seat_for_team(self, team: Team) -> str:
|
||||
# Retrieves seat id for leader of a team
|
||||
leader = list(team.members.keys())[0]
|
||||
for member, rank in team.members.items():
|
||||
if rank == TeamStatus.LEADER:
|
||||
leader = member
|
||||
break
|
||||
|
||||
return self.id_to_seat_map[leader.user_id]
|
||||
|
||||
|
||||
def build(self) -> Component:
|
||||
if self.tournament is None or not self.is_fully_loaded:
|
||||
return Column(
|
||||
MainViewContentBox(
|
||||
Column(
|
||||
Spacer(min_height=1),
|
||||
Column(
|
||||
ProgressCircle(
|
||||
color="secondary",
|
||||
align_x=0.5,
|
||||
margin_top=0,
|
||||
margin_bottom=0
|
||||
),
|
||||
min_height=10
|
||||
),
|
||||
Spacer(min_height=1)
|
||||
)
|
||||
),
|
||||
align_y=0
|
||||
)
|
||||
elif isinstance(self.tournament, str):
|
||||
content = Row(
|
||||
Text(
|
||||
text=self.tournament,
|
||||
style=TextStyle(
|
||||
fill=self.session.theme.background_color,
|
||||
font_size=1
|
||||
),
|
||||
margin_top=2,
|
||||
margin_bottom=2,
|
||||
align_x=0.5
|
||||
)
|
||||
)
|
||||
else:
|
||||
if self.tournament.format == TournamentFormat.FFA:
|
||||
content = Column(
|
||||
Text(
|
||||
text=f"Dieses Turnier hat keinen Turnierbaum.",
|
||||
style=TextStyle(fill=self.session.theme.background_color),
|
||||
margin_top=1,
|
||||
margin_bottom=1,
|
||||
align_x=0.5,
|
||||
overflow="wrap",
|
||||
min_width=30,
|
||||
justify="center"
|
||||
)
|
||||
)
|
||||
else:
|
||||
try:
|
||||
file_name = self.tournament.name.replace(" ", "_") + ".json"
|
||||
games_per_matchup = int(self.tournament.format.name[-1])
|
||||
logger.info(f"Trying to read tournament data from {file_name}")
|
||||
with open(from_root("tournament_data", file_name), "r") as f:
|
||||
json_data = json.load(f)
|
||||
|
||||
last_valid_round = None
|
||||
round_num = 0
|
||||
for round_ in json_data["rounds"]:
|
||||
if all(
|
||||
match["opponent_1_id"] is not None or match["opponent_2_id"] is not None
|
||||
for match in round_
|
||||
):
|
||||
last_valid_round = round_
|
||||
round_num += 1
|
||||
|
||||
if last_valid_round is None:
|
||||
last_valid_round = json_data["rounds"][0]
|
||||
|
||||
match_infos = []
|
||||
if self.tournament.participant_type == ParticipantType.PLAYER:
|
||||
match_infos = [MatchInfo(
|
||||
opponent_1=self.id_to_username_map.get(match["opponent_1_id"], ""),
|
||||
opponent_2=self.id_to_username_map.get(match["opponent_2_id"], ""),
|
||||
winner=self.id_to_username_map.get(match["winner"], ""),
|
||||
opponent_1_seat=self.id_to_seat_map.get(match["opponent_1_id"], ""),
|
||||
opponent_2_seat=self.id_to_seat_map.get(match["opponent_2_id"], ""),
|
||||
) for match in last_valid_round]
|
||||
elif self.tournament.participant_type == ParticipantType.TEAM:
|
||||
for match in last_valid_round:
|
||||
team_1: Optional[Team] = next(filter(lambda t: t.id == match["opponent_1_id"], self.teams), None)
|
||||
team_2: Optional[Team] = next(filter(lambda t: t.id == match["opponent_2_id"], self.teams), None)
|
||||
winner: Union[str, Team] = next(filter(lambda t: t.id == match["winner"], self.teams), "")
|
||||
match_infos.append(
|
||||
MatchInfo(
|
||||
opponent_1=team_1.name if team_1 is not None else "",
|
||||
opponent_2=team_2.name if team_2 is not None else "",
|
||||
winner=winner if isinstance(winner, str) else winner.name,
|
||||
opponent_1_seat=self._get_seat_for_team(team_1) if team_1 is not None else "",
|
||||
opponent_2_seat=self._get_seat_for_team(team_2) if team_2 is not None else "",
|
||||
)
|
||||
)
|
||||
else:
|
||||
raise ValueError("Unknown participant type")
|
||||
|
||||
|
||||
|
||||
content = Column(
|
||||
Text(
|
||||
text=f"{self.tournament.name}",
|
||||
style=TextStyle(fill=self.session.theme.background_color),
|
||||
justify="center",
|
||||
font_size=1.2
|
||||
),
|
||||
Text(
|
||||
text="Finale" if len(json_data["rounds"]) == round_num else f"Runde {round_num}",
|
||||
style=TextStyle(fill=self.session.theme.background_color),
|
||||
justify="center",
|
||||
font_size=0.9,
|
||||
margin_bottom=1
|
||||
),
|
||||
Text(
|
||||
text=f"Spiele pro Matchup: {games_per_matchup}",
|
||||
style=TextStyle(fill=self.session.theme.background_color),
|
||||
justify="center",
|
||||
font_size=0.8
|
||||
),
|
||||
Text(
|
||||
text=f"Melde als Verlierer deinen Matchausgang\nim Discord oder an der Orga-Ecke",
|
||||
style=TextStyle(fill=self.session.theme.background_color),
|
||||
justify="center",
|
||||
font_size=0.8
|
||||
),
|
||||
*match_infos
|
||||
)
|
||||
except (FileNotFoundError, ValueError, AttributeError):
|
||||
content = Column(
|
||||
Text(
|
||||
text=f"Der Turnierbaum für dieses Turnier steht leider nicht zur Verfügung.\n\nBitte melde sich beim Orga-Team.",
|
||||
style=TextStyle(fill=self.session.theme.background_color),
|
||||
margin_top=1,
|
||||
margin_bottom=1,
|
||||
align_x=0.5,
|
||||
overflow="wrap",
|
||||
min_width=30,
|
||||
justify="center"
|
||||
)
|
||||
)
|
||||
|
||||
return Column(
|
||||
MainViewContentBox(
|
||||
Column(
|
||||
Spacer(min_height=1),
|
||||
content,
|
||||
Spacer(min_height=1)
|
||||
)
|
||||
),
|
||||
align_y=0
|
||||
)
|
||||
@@ -25,3 +25,4 @@ from .TournamentRulesPage import TournamentRulesPage
|
||||
from .ConwayPage import ConwayPage
|
||||
from .TeamsPage import TeamsPage
|
||||
from .AdminNavigationPage import AdminNavigationPage
|
||||
from .TournamentTreePage import TournamentTreePage
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import io
|
||||
import logging
|
||||
import qrcode
|
||||
from collections.abc import Callable
|
||||
from datetime import datetime
|
||||
from decimal import Decimal, ROUND_DOWN
|
||||
@@ -74,3 +76,29 @@ class AccountingService:
|
||||
return "0.00 €"
|
||||
rounded_decimal = str(euros.quantize(Decimal(".01"), rounding=ROUND_DOWN))
|
||||
return f"{rounded_decimal} €"
|
||||
|
||||
@staticmethod
|
||||
def make_payment_qr_image(beneficiary_name, beneficiary_bic, beneficiary_iban, text, amount_euros=None) -> bytes:
|
||||
text = text.replace("\n",";")
|
||||
amount_formatted = "EUR{:.2f}".format(amount_euros) if amount_euros else ""
|
||||
epc_text = f"""BCD
|
||||
002
|
||||
1
|
||||
SCT
|
||||
{beneficiary_bic}
|
||||
{beneficiary_name}
|
||||
{beneficiary_iban}
|
||||
{amount_formatted}
|
||||
|
||||
|
||||
{text}
|
||||
"""
|
||||
qr = qrcode.QRCode(
|
||||
version=6,
|
||||
error_correction=qrcode.constants.ERROR_CORRECT_M,
|
||||
)
|
||||
qr.add_data(epc_text)
|
||||
img = qr.make_image()
|
||||
img_bytes = io.BytesIO()
|
||||
img.save(img_bytes)
|
||||
return img_bytes.getvalue()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import logging
|
||||
|
||||
from datetime import date, datetime
|
||||
from datetime import date, datetime, UTC
|
||||
from typing import Optional
|
||||
from decimal import Decimal
|
||||
|
||||
@@ -16,7 +16,7 @@ from src.ezgg_lan_manager.types.Seat import Seat
|
||||
from src.ezgg_lan_manager.types.Team import TeamStatus, Team
|
||||
from src.ezgg_lan_manager.types.Ticket import Ticket
|
||||
from src.ezgg_lan_manager.types.Tournament import Tournament
|
||||
from src.ezgg_lan_manager.types.TournamentBase import GameTitle, TournamentFormat, TournamentStatus, ParticipantType
|
||||
from src.ezgg_lan_manager.types.TournamentBase import GameTitle, TournamentFormat, TournamentStatus, ParticipantType, MatchStatus
|
||||
from src.ezgg_lan_manager.types.Transaction import Transaction
|
||||
from src.ezgg_lan_manager.types.User import User
|
||||
|
||||
@@ -1185,3 +1185,18 @@ class DatabaseService:
|
||||
if not pool_init_result:
|
||||
raise NoDatabaseConnectionError
|
||||
return await self.remove_user_from_team(team, user)
|
||||
|
||||
async def change_tournament_status(self, tournament_id: int, status: TournamentStatus) -> None:
|
||||
async with self._connection_pool.acquire() as conn:
|
||||
async with conn.cursor(aiomysql.Cursor) as cursor:
|
||||
try:
|
||||
await cursor.execute(
|
||||
"UPDATE tournaments SET status = %s WHERE (id = %s)",
|
||||
(status.name, tournament_id)
|
||||
)
|
||||
await conn.commit()
|
||||
except aiomysql.InterfaceError:
|
||||
pool_init_result = await self.init_db_pool()
|
||||
if not pool_init_result:
|
||||
raise NoDatabaseConnectionError
|
||||
return await self.change_tournament_status(tournament_id, status)
|
||||
|
||||
@@ -21,5 +21,6 @@ class LocalDataService:
|
||||
self._session[key] = session
|
||||
return key
|
||||
|
||||
def del_session(self, token: str) -> None:
|
||||
self._session.pop(token, None)
|
||||
def del_session(self, token: Optional[str]) -> None:
|
||||
if token is not None:
|
||||
self._session.pop(token, None)
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
from typing import Callable
|
||||
from typing import Callable, Optional
|
||||
|
||||
|
||||
class RefreshService:
|
||||
"""
|
||||
rio.Components can subscribe to this service with their on_populate method.
|
||||
Those methods get called whenever a overall refresh is needed. Usually when the user logs in or out.
|
||||
The active rio.Components can subscribe to this service with their on_populate method.
|
||||
This methods get called whenever a overall refresh is needed. Usually when the user logs in or out.
|
||||
"""
|
||||
def __init__(self) -> None:
|
||||
self.subscribers: set[Callable] = set()
|
||||
self.subscriber: Optional[Callable] = None
|
||||
|
||||
def subscribe(self, refresh_cb: Callable) -> None:
|
||||
self.subscribers.add(refresh_cb)
|
||||
self.subscriber = refresh_cb
|
||||
|
||||
async def trigger_refresh(self) -> None:
|
||||
for refresh_cb in self.subscribers:
|
||||
await refresh_cb()
|
||||
if self.subscriber is not None:
|
||||
await self.subscriber()
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import json
|
||||
from pprint import pprint
|
||||
from typing import Optional
|
||||
|
||||
from from_root import from_root
|
||||
|
||||
from src.ezgg_lan_manager.services.DatabaseService import DatabaseService
|
||||
from src.ezgg_lan_manager.services.UserService import UserService
|
||||
from src.ezgg_lan_manager.types.Participant import Participant
|
||||
@@ -18,6 +22,10 @@ class TournamentService:
|
||||
self._cache: dict[int, Tournament] = {}
|
||||
self._cache_dirty: bool = True # Setting this flag invokes cache update on next read
|
||||
|
||||
async def queue_cache_renewal(self) -> None:
|
||||
# Used in admin UI to provoke cache renewal after direct database access
|
||||
self._cache_dirty = True
|
||||
|
||||
async def _update_cache(self) -> None:
|
||||
tournaments = await self._db_service.get_all_tournaments()
|
||||
for tournament in tournaments:
|
||||
@@ -90,12 +98,47 @@ class TournamentService:
|
||||
tournament = await self.get_tournament_by_id(tournament_id)
|
||||
if tournament:
|
||||
tournament.start()
|
||||
# ToDo: Write matches/round to database
|
||||
await self._generate_initial_json_file(tournament)
|
||||
await self._db_service.change_tournament_status(tournament_id, tournament.status)
|
||||
self._cache_dirty = True
|
||||
|
||||
async def cancel_tournament(self, tournament_id: int):
|
||||
tournament = await self.get_tournament_by_id(tournament_id)
|
||||
if tournament:
|
||||
tournament.cancel()
|
||||
# ToDo: Update to database
|
||||
await self._db_service.change_tournament_status(tournament_id, tournament.status)
|
||||
self._cache_dirty = True
|
||||
|
||||
async def _generate_initial_json_file(self, tournament: Tournament) -> None:
|
||||
"""
|
||||
Generates the initial JSON file for the tournament. Won't generate a new one if one already exists.
|
||||
ToDo: Remove this method when final tournament system is completed.
|
||||
"""
|
||||
p = tournament.participants
|
||||
pairs = [
|
||||
(p[i], p[i + 1]) if i + 1 < len(p) else (p[i], None)
|
||||
for i in range(0, len(p), 2)
|
||||
]
|
||||
data = {
|
||||
"rounds": [
|
||||
[
|
||||
{
|
||||
"opponent_1_id": pair[0].id if pair[0] is not None else None,
|
||||
"opponent_2_id": pair[1].id if pair[1] is not None else None,
|
||||
"winner": None
|
||||
} for pair in pairs
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
# Resolve byes
|
||||
for match in data["rounds"][0]:
|
||||
if match["opponent_2_id"] is None:
|
||||
match["winner"] = match["opponent_1_id"]
|
||||
|
||||
file_name = tournament.name.replace(" ", "_") + ".json"
|
||||
try:
|
||||
with open(from_root("tournament_data", file_name), "x") as f:
|
||||
json.dump(data, f, indent=4)
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
@@ -49,6 +49,14 @@ class Match:
|
||||
games.append(Game(game_id, self._match_id, game_number, None, None, False))
|
||||
return tuple(games)
|
||||
|
||||
@property
|
||||
def round_number(self) -> int:
|
||||
return self._round_number
|
||||
|
||||
@property
|
||||
def best_of(self) -> int:
|
||||
return self._best_of
|
||||
|
||||
@property
|
||||
def status(self) -> MatchStatus:
|
||||
if self._status == MatchStatus.COMPLETED:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
@@ -7,6 +8,7 @@ from src.ezgg_lan_manager.types.Match import Match, FFAMatch
|
||||
from src.ezgg_lan_manager.types.Participant import Participant
|
||||
from src.ezgg_lan_manager.types.TournamentBase import GameTitle, TournamentFormat, TournamentStatus, TournamentError, Bracket, MatchStatus, ParticipantType
|
||||
|
||||
logger = logging.getLogger(__name__.split(".")[-1])
|
||||
|
||||
class Tournament:
|
||||
def __init__(self,
|
||||
@@ -353,6 +355,7 @@ class Tournament:
|
||||
raise TournamentError(f"Unknown bracket type: {bracket_type}")
|
||||
|
||||
self._status = TournamentStatus.ONGOING
|
||||
logger.info(f"New tournament status for {self._name}: {self._status}")
|
||||
for match in self._matches:
|
||||
match.check_completion()
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from dataclasses import dataclass
|
||||
from uuid import UUID
|
||||
|
||||
from rio import Dataclass
|
||||
|
||||
@dataclass
|
||||
class UserSession:
|
||||
|
||||
class UserSession(Dataclass):
|
||||
id: UUID
|
||||
user_id: int
|
||||
is_team_member: bool
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
*.json
|
||||
@@ -0,0 +1,43 @@
|
||||
# Tournament data
|
||||
|
||||
This directory contains JSON files for tournament trees.
|
||||
|
||||
This is a temporary solution until the automatic tournament tree generation is completed.
|
||||
|
||||
# Structure
|
||||
|
||||
## Naming
|
||||
|
||||
Tournament name with `_` as separators and `.json` suffix.
|
||||
|
||||
## JSON structure
|
||||
|
||||
```json
|
||||
{
|
||||
"rounds": [
|
||||
[
|
||||
{
|
||||
"opponent_1_id": 1,
|
||||
"opponent_2_id": 2,
|
||||
"winner": 1
|
||||
},
|
||||
{
|
||||
"opponent_1_id": 3,
|
||||
"opponent_2_id": 4,
|
||||
"winner": null
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"opponent_1_id": 1,
|
||||
"opponent_2_id": null,
|
||||
"winner": null
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## ToDo
|
||||
|
||||
- Make start button in UI generate initial `.json` file for started tournament
|
||||
Reference in New Issue
Block a user