Compare commits
60 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4541d3763f | |||
| ce45c389ef | |||
| edf1d70b54 | |||
| 8b02390bee | |||
| b47eefe615 | |||
| 57c578a44b | |||
| d57f4baedd | |||
| f4db57b2ff | |||
| d83182dd7b | |||
| d7df5161d4 | |||
| d5b677ab68 | |||
| 5b6c5d2076 | |||
| a390e4bd10 | |||
| 82fc0e87a8 | |||
| deec60347b | |||
| 908bee1e7b | |||
| 27d1f60e2c | |||
| d238153a22 | |||
| 914dd4eaa8 | |||
| e79118a0f4 | |||
| 124e1a1a06 | |||
| 00019a8c0d | |||
| 4e0139fef1 | |||
| 9e86a7655e | |||
| aa3691a59f | |||
| f713443c20 | |||
| 2f4c3a15b7 | |||
| 54df84a7da | |||
| ff5d715a4e | |||
| b505191156 | |||
| 43559fcf30 | |||
| af8cf19dc8 | |||
| 29caadaca2 | |||
| 6e598b577f | |||
| 1091179492 | |||
| 530efcd286 | |||
| 4018502a63 | |||
| 3f06015cb8 | |||
| 336bd0e108 | |||
| fa90e16fdf | |||
| b987623d9d | |||
| f58a7872ef | |||
| 23e903a207 | |||
| 8aee3af9d7 | |||
| dd8b79c254 | |||
| 2f6e2b15aa | |||
| b4da6b9729 | |||
| a430c81624 | |||
| 1d21fbae5a | |||
| db8ada283b | |||
| d3aadcf697 | |||
| bbb4e8f1d1 | |||
| 51b07baa36 | |||
| ea9a805483 | |||
| d43dd96fbb | |||
| a61ee8e775 | |||
| 328bea32d7 | |||
| 49d89feda3 | |||
| 26994d4536 | |||
| ee6f35b771 |
@@ -0,0 +1,22 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>EZGG LAN Manager - Wartungsmodus</title>
|
||||||
|
<style>
|
||||||
|
body { text-align: center; padding: 150px; }
|
||||||
|
h1 { font-size: 50px; }
|
||||||
|
body { font: 20px Helvetica, sans-serif; color: #333; }
|
||||||
|
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
|
||||||
|
a { color: #dc8100; text-decoration: none; }
|
||||||
|
a:hover { color: #333; text-decoration: none; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<article>
|
||||||
|
<h1>Wir sind bald wieder da!</h1>
|
||||||
|
<div>
|
||||||
|
<p>Wir führen zurzeit Wartungsarbeiten durch und sind in kürze wieder für euch da.</p>
|
||||||
|
<p>— Euer EZGG LAN Team</p>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
FROM python:3.12-bookworm
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt install dumb-init
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
EXPOSE 8001
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
||||||
@@ -1,13 +1,49 @@
|
|||||||
# EZ LAN Manager
|
# EZGG LAN Manager
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
This repository contains the code for the EZ LAN Manager.
|
This repository contains the code for the EZGG LAN Manager.
|
||||||
|
|
||||||
## How to install [prod]
|
## Development Setup
|
||||||
|
|
||||||
TBD
|
### Prerequisites
|
||||||
|
|
||||||
## How to install [dev]
|
- Working Installation of MariaDB Server (version `10.6.25` or later)
|
||||||
|
+ MySQL should work too, but there are no guarantees.
|
||||||
|
- Python 3.9 or higher
|
||||||
|
- PyCharm or similar IDE (optional)
|
||||||
|
|
||||||
TBD
|
### Step 1: Preparing Database
|
||||||
|
|
||||||
|
To prepare the database, apply the SQL file located in `sql/create_database.sql` to your database server. This is easily accomplished with the MYSQL Workbench, but it can be also done by piping the file into the mariadb-server executable.
|
||||||
|
|
||||||
|
After creating the database, apply all patches found in `sql/*_patch.sql` in their numeric order.
|
||||||
|
|
||||||
|
Optionally, you can now execute the script `create_demo_database_content.py`, found in `src/ezgg_lan_manager/helpers`. Be aware that it can be buggy sometimes, especially if you overwrite existing data.
|
||||||
|
|
||||||
|
### Step 2: Preparing configuration
|
||||||
|
|
||||||
|
Use the example configuration at `config/config.example.toml` to create a `config.toml` at the base of the repository. Most of the parameters do not matter to get the development setup done, but the database credentials need to be correct.
|
||||||
|
|
||||||
|
### Step 3: Install dependecies
|
||||||
|
|
||||||
|
Use `pip install -r requirements.txt` to install the requirements. The usage of a venv is recommended.
|
||||||
|
|
||||||
|
### Step 4: Running the application
|
||||||
|
|
||||||
|
Run the application by executing the file `EzggLanManager.py` found at `src/ezgg_lan_manager`. Check the STDOUT for information regarding the port on which the application is now served.
|
||||||
|
|
||||||
|
## Docker Deployment
|
||||||
|
|
||||||
|
To get the docker compose setup running, you need to manually complete the following steps:
|
||||||
|
|
||||||
|
1. Create a valid `config.toml` in the project root, so it gets copied over into the container.
|
||||||
|
2. Create the database user:
|
||||||
|
```sql
|
||||||
|
CREATE USER 'ezgg_lan_manager'@'%' IDENTIFIED BY 'PASSWORD';
|
||||||
|
GRANT ALL PRIVILEGES ON ezgg_lan_manager.* TO 'ezgg_lan_manager'@'%';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
3. Make sure to **NOT** use the default passwords!
|
||||||
|
4. Apply the `create_database.sql` when starting the MariaDB container for the first time.
|
||||||
|
5. Apply the patches (`sql/*_patch.sql`) when starting the MariaDB container for the first time.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[lan]
|
[lan]
|
||||||
name="EZ LAN"
|
name="EZGG LAN"
|
||||||
iteration="0.5"
|
iteration="0.5"
|
||||||
date_from="2024-10-30 15:00:00"
|
date_from="2024-10-30 15:00:00"
|
||||||
date_till="2024-11-01 12:00:00"
|
date_till="2024-11-01 12:00:00"
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
db_password="demo_password"
|
db_password="demo_password"
|
||||||
db_host="127.0.0.1"
|
db_host="127.0.0.1"
|
||||||
db_port=3306
|
db_port=3306
|
||||||
db_name="ez_lan_manager"
|
db_name="ezgg_lan_manager"
|
||||||
|
|
||||||
[mailing]
|
[mailing]
|
||||||
smtp_server=""
|
smtp_server=""
|
||||||
@@ -19,12 +19,6 @@
|
|||||||
username=""
|
username=""
|
||||||
password=""
|
password=""
|
||||||
|
|
||||||
[seating]
|
|
||||||
# SeatID -> Category
|
|
||||||
A01 = "NORMAL"
|
|
||||||
A02 = "NORMAL"
|
|
||||||
C01 = "LUXUS"
|
|
||||||
|
|
||||||
[tickets]
|
[tickets]
|
||||||
[tickets."NORMAL"]
|
[tickets."NORMAL"]
|
||||||
total_tickets=30
|
total_tickets=30
|
||||||
@@ -40,5 +34,11 @@
|
|||||||
additional_info="Berechtigt zur Nutzung eines verbesserten Platzes. Dieser ist mit einer höheren Internet-Bandbreite und einem Sitzkissen ausgestattet."
|
additional_info="Berechtigt zur Nutzung eines verbesserten Platzes. Dieser ist mit einer höheren Internet-Bandbreite und einem Sitzkissen ausgestattet."
|
||||||
is_default=false
|
is_default=false
|
||||||
|
|
||||||
|
[receipt_printing]
|
||||||
|
host="127.0.0.1"
|
||||||
|
port="5000"
|
||||||
|
order_print_endpoint="print_order"
|
||||||
|
password="Alkohol1"
|
||||||
|
|
||||||
[misc]
|
[misc]
|
||||||
dev_mode_active=true # Supresses E-Mail sending
|
dev_mode_active=true # Supresses E-Mail sending
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
services:
|
||||||
|
lan_manager:
|
||||||
|
build: .
|
||||||
|
depends_on:
|
||||||
|
db:
|
||||||
|
condition: service_healthy
|
||||||
|
environment:
|
||||||
|
PYTHONPATH: /opt/ezgg-lan-manager
|
||||||
|
ports:
|
||||||
|
- "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"]
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: mariadb:latest
|
||||||
|
environment:
|
||||||
|
MARIADB_ROOT_PASSWORD: Alkohol1
|
||||||
|
MARIADB_DATABASE: ezgg_lan_manager
|
||||||
|
MARIADB_USER: ezgg_lan_manager
|
||||||
|
MARIADB_PASSWORD: Alkohol1
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "mariadb-admin", "ping", "-h", "localhost"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 3s
|
||||||
|
retries: 5
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:3306:3306"
|
||||||
|
volumes:
|
||||||
|
- database:/var/lib/mysql
|
||||||
|
- ./sql/create_database.sql:/docker-entrypoint-initdb.d/init.sql
|
||||||
|
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
database:
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
-- Apply this patch after using create_database.sql to extend the schema to support tournaments from version 0.2.0
|
||||||
|
-- WARNING: Executing this on a post 0.2.0 database will delete all data related to tournaments !!!
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `game_titles`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `game_titles` (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
name VARCHAR(255) NOT NULL,
|
||||||
|
description TEXT NOT NULL,
|
||||||
|
web_link VARCHAR(512) NOT NULL,
|
||||||
|
image_name VARCHAR(255) NOT NULL,
|
||||||
|
UNIQUE KEY uq_game_title_name (name)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `tournaments`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `tournaments` (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
name VARCHAR(255) NOT NULL,
|
||||||
|
description TEXT NOT NULL,
|
||||||
|
game_title_id INT NOT NULL,
|
||||||
|
format VARCHAR(20) NOT NULL, -- SE_BO1, DE_BO3, ...
|
||||||
|
start_time DATETIME NOT NULL,
|
||||||
|
status VARCHAR(20) NOT NULL, -- OPEN, CLOSED, ONGOING, ...
|
||||||
|
max_participants INT NOT NULL,
|
||||||
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
CONSTRAINT fk_tournament_game
|
||||||
|
FOREIGN KEY (game_title_id)
|
||||||
|
REFERENCES game_titles(id)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
CREATE INDEX idx_tournaments_game_title
|
||||||
|
ON tournaments(game_title_id);
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `tournament_participants`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `tournament_participants` (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tournament_id INT NOT NULL,
|
||||||
|
user_id INT NOT NULL,
|
||||||
|
participant_type VARCHAR(10) NOT NULL DEFAULT 'PLAYER',
|
||||||
|
seed INT NULL,
|
||||||
|
joined_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
UNIQUE KEY uq_tournament_user (tournament_id, user_id),
|
||||||
|
|
||||||
|
CONSTRAINT fk_tp_tournament
|
||||||
|
FOREIGN KEY (tournament_id)
|
||||||
|
REFERENCES tournaments(id)
|
||||||
|
ON DELETE CASCADE,
|
||||||
|
|
||||||
|
CONSTRAINT fk_tp_user
|
||||||
|
FOREIGN KEY (user_id)
|
||||||
|
REFERENCES users(user_id)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
CREATE INDEX idx_tp_tournament
|
||||||
|
ON tournament_participants(tournament_id);
|
||||||
|
CREATE INDEX idx_tp_user
|
||||||
|
ON tournament_participants(user_id);
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `tournament_rounds`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `tournament_rounds` (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tournament_id INT NOT NULL,
|
||||||
|
bracket VARCHAR(10) NOT NULL, -- UPPER, LOWER, FINAL
|
||||||
|
round_index INT NOT NULL,
|
||||||
|
|
||||||
|
UNIQUE KEY uq_round (tournament_id, bracket, round_index),
|
||||||
|
|
||||||
|
CONSTRAINT fk_round_tournament
|
||||||
|
FOREIGN KEY (tournament_id)
|
||||||
|
REFERENCES tournaments(id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
CREATE INDEX idx_rounds_tournament
|
||||||
|
ON tournament_rounds(tournament_id);
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `matches`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `matches` (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tournament_id INT NOT NULL,
|
||||||
|
round_id INT NOT NULL,
|
||||||
|
match_index INT NOT NULL,
|
||||||
|
status VARCHAR(15) NOT NULL, -- WAITING, PENDING, COMPLETED, ...
|
||||||
|
best_of INT NOT NULL, -- 1, 3, 5
|
||||||
|
scheduled_time DATETIME NULL,
|
||||||
|
completed_at DATETIME NULL,
|
||||||
|
|
||||||
|
UNIQUE KEY uq_match (round_id, match_index),
|
||||||
|
|
||||||
|
CONSTRAINT fk_match_tournament
|
||||||
|
FOREIGN KEY (tournament_id)
|
||||||
|
REFERENCES tournaments(id)
|
||||||
|
ON DELETE CASCADE,
|
||||||
|
|
||||||
|
CONSTRAINT fk_match_round
|
||||||
|
FOREIGN KEY (round_id)
|
||||||
|
REFERENCES tournament_rounds(id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
CREATE INDEX idx_matches_tournament
|
||||||
|
ON matches(tournament_id);
|
||||||
|
|
||||||
|
CREATE INDEX idx_matches_round
|
||||||
|
ON matches(round_id);
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `match_participants`;
|
||||||
|
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||||
|
/*!40101 SET character_set_client = utf8 */;
|
||||||
|
CREATE TABLE `match_participants` (
|
||||||
|
match_id INT NOT NULL,
|
||||||
|
participant_id INT NOT NULL,
|
||||||
|
score INT NULL,
|
||||||
|
is_winner TINYINT(1) NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY (match_id, participant_id),
|
||||||
|
|
||||||
|
CONSTRAINT fk_mp_match
|
||||||
|
FOREIGN KEY (match_id)
|
||||||
|
REFERENCES matches(id)
|
||||||
|
ON DELETE CASCADE,
|
||||||
|
|
||||||
|
CONSTRAINT fk_mp_participant
|
||||||
|
FOREIGN KEY (participant_id)
|
||||||
|
REFERENCES tournament_participants(id)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||||
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
-- =====================================================
|
||||||
|
-- Teams
|
||||||
|
-- =====================================================
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `team_members`;
|
||||||
|
DROP TABLE IF EXISTS `teams`;
|
||||||
|
|
||||||
|
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
-- Teams table
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
CREATE TABLE `teams` (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
name VARCHAR(100) NOT NULL,
|
||||||
|
abbreviation VARCHAR(10) NOT NULL,
|
||||||
|
join_password VARCHAR(255) NOT NULL,
|
||||||
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
UNIQUE KEY uq_team_name (name),
|
||||||
|
UNIQUE KEY uq_team_abbr (abbreviation)
|
||||||
|
|
||||||
|
) ENGINE=InnoDB
|
||||||
|
DEFAULT CHARSET=utf8mb4
|
||||||
|
COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
-- Team Members (Junction Table)
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
CREATE TABLE `team_members` (
|
||||||
|
team_id INT NOT NULL,
|
||||||
|
user_id INT NOT NULL,
|
||||||
|
|
||||||
|
status ENUM('MEMBER','OFFICER','LEADER')
|
||||||
|
NOT NULL DEFAULT 'MEMBER',
|
||||||
|
|
||||||
|
joined_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
PRIMARY KEY (team_id, user_id),
|
||||||
|
|
||||||
|
CONSTRAINT fk_tm_team
|
||||||
|
FOREIGN KEY (team_id)
|
||||||
|
REFERENCES teams(id)
|
||||||
|
ON DELETE CASCADE,
|
||||||
|
|
||||||
|
CONSTRAINT fk_tm_user
|
||||||
|
FOREIGN KEY (user_id)
|
||||||
|
REFERENCES users(user_id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
|
||||||
|
) ENGINE=InnoDB
|
||||||
|
DEFAULT CHARSET=utf8mb4
|
||||||
|
COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
-- Indexes
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
CREATE INDEX idx_tm_user
|
||||||
|
ON team_members(user_id);
|
||||||
|
|
||||||
|
CREATE INDEX idx_tm_team_status
|
||||||
|
ON team_members(team_id, status);
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
-- =====================================================
|
||||||
|
-- Adds type of participant to tournament
|
||||||
|
-- =====================================================
|
||||||
|
|
||||||
|
ALTER TABLE `tournaments` ADD COLUMN `participant_type` ENUM('PLAYER','TEAM') NOT NULL DEFAULT 'PLAYER' AFTER `created_at`;
|
||||||
|
|
||||||
|
ALTER TABLE `tournament_participants`
|
||||||
|
CHANGE COLUMN `user_id` `user_id` INT(11) NULL AFTER `tournament_id`,
|
||||||
|
ADD COLUMN `team_id` INT(11) NULL AFTER `user_id`,
|
||||||
|
ADD CONSTRAINT `fk_tp_team` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
-- Apply this patch after using create_database.sql to extend the schema to support fallback passwords
|
||||||
|
|
||||||
|
ALTER TABLE users
|
||||||
|
ADD COLUMN user_fallback_password VARCHAR(255) DEFAULT NULL
|
||||||
|
AFTER user_password;
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
INSERT INTO `catering_menu_items` VALUES
|
||||||
|
(1,'Schnitzel Wiener Art','mit Pommes Frites und Salat',20.50,'MAIN_COURSE',1),
|
||||||
|
(2,'Jäger Schnitzel mit Champignonrahm Sauce','mit Spätzlen und Salat',22.50,'MAIN_COURSE',1),
|
||||||
|
(3,'Rumpsteak 250g','mit Pommes Frites und Salat',35.50,'MAIN_COURSE',1),
|
||||||
|
(4,'Rindergeschnetzeltes','mit Spätzlen und Salat',22.50,'MAIN_COURSE',1),
|
||||||
|
(5,'Galloway Burger','mit Amazing Fries',20.00,'MAIN_COURSE',1),
|
||||||
|
(6,'Käsespätzle mit Röstzwiebel','mit Salat',20.00,'MAIN_COURSE',1),
|
||||||
|
(11,'Käse Schinken Wrap','',5.00,'SNACK',1),
|
||||||
|
(12,'Puten Paprika Wrap','',7.00,'SNACK',1),
|
||||||
|
(13,'Tomate Mozzarella Wrap','',6.00,'SNACK',1),
|
||||||
|
(14,'Portion Pommes','',4.00,'SNACK',1),
|
||||||
|
(15,'Rinds-Currywurst','',4.50,'SNACK',1),
|
||||||
|
(16,'Rinds-Currywurst mit Pommes','',6.50,'SNACK',1),
|
||||||
|
(17,'Nudelsalat','',4.50,'SNACK',1),
|
||||||
|
(18,'Nudelsalat mit Bockwurst','',6.00,'SNACK',1),
|
||||||
|
(19,'Kartoffelsalat','',4.50,'SNACK',1),
|
||||||
|
(20,'Kartoffelsalat mit Bockwurst','',6.00,'SNACK',1),
|
||||||
|
(21,'Sandwichtoast - Schinken','',1.80,'SNACK',1),
|
||||||
|
(22,'Sandwichtoast - Käse','',1.80,'SNACK',1),
|
||||||
|
(23,'Sandwichtoast - Schinken/Käse','',2.10,'SNACK',1),
|
||||||
|
(24,'Sandwichtoast - Salami','',1.80,'SNACK',1),
|
||||||
|
(25,'Sandwichtoast - Salami/Käse','',2.10,'SNACK',1),
|
||||||
|
(26,'Chips - Western Style','',1.50,'SNACK',1),
|
||||||
|
(27,'Nachos - Salted','',1.50,'SNACK',1),
|
||||||
|
(28,'Panna Cotta mit Erdbeersauce','',7.00,'DESSERT',1),
|
||||||
|
(29,'Panna Cotta mit Blaubeersauce','',7.00,'DESSERT',1),
|
||||||
|
(30,'Mousse au Chocolat','',7.00,'DESSERT',1),
|
||||||
|
(31,'Fruit Loops','',1.50,'BREAKFAST',1),
|
||||||
|
(32,'Smacks','',1.50,'BREAKFAST',1),
|
||||||
|
(33,'Knuspermüsli','Schoko',2.00,'BREAKFAST',1),
|
||||||
|
(34,'Cini Minis','',1.50,'BREAKFAST',1),
|
||||||
|
(35,'Brötchen - Schinken','mit Margarine',1.20,'BREAKFAST',1),
|
||||||
|
(36,'Brötchen - Käse','mit Margarine',1.20,'BREAKFAST',1),
|
||||||
|
(37,'Brötchen - Schinken/Käse','mit Margarine',1.40,'BREAKFAST',1),
|
||||||
|
(38,'Brötchen - Salami','mit Margarine',1.20,'BREAKFAST',1),
|
||||||
|
(39,'Brötchen - Salami/Käse','mit Margarine',1.40,'BREAKFAST',1),
|
||||||
|
(40,'Brötchen - Nutella','mit Margarine',1.20,'BREAKFAST',1),
|
||||||
|
(41,'Wasser - Still','1L Flasche',2.00,'BEVERAGE_NON_ALCOHOLIC',1),
|
||||||
|
(42,'Wasser - Medium','1L Flasche',2.00,'BEVERAGE_NON_ALCOHOLIC',1),
|
||||||
|
(43,'Wasser - Spritzig','1L Flasche',2.00,'BEVERAGE_NON_ALCOHOLIC',1),
|
||||||
|
(44,'Coca-Cola','1L Flasche',2.00,'BEVERAGE_NON_ALCOHOLIC',1),
|
||||||
|
(45,'Coca-Cola Zero','1L Flasche',2.00,'BEVERAGE_NON_ALCOHOLIC',1),
|
||||||
|
(46,'Fanta','1L Flasche',2.00,'BEVERAGE_NON_ALCOHOLIC',1),
|
||||||
|
(47,'Sprite','1L Flasche',2.00,'BEVERAGE_NON_ALCOHOLIC',1),
|
||||||
|
(48,'Spezi','von Paulaner, 0,5L Flasche',1.50,'BEVERAGE_NON_ALCOHOLIC',1),
|
||||||
|
(49,'Red Bull','',2.00,'BEVERAGE_NON_ALCOHOLIC',1),
|
||||||
|
(50,'Energy','Hausmarke',1.50,'BEVERAGE_NON_ALCOHOLIC',1),
|
||||||
|
(51,'Pils','0,33L Flasche',1.90,'BEVERAGE_ALCOHOLIC',1),
|
||||||
|
(52,'Radler','0,33L Flasche',1.90,'BEVERAGE_ALCOHOLIC',1),
|
||||||
|
(53,'Diesel','0,33L Flasche',1.90,'BEVERAGE_ALCOHOLIC',1),
|
||||||
|
(54,'Apfelwein Pur','0,33L Flasche',1.90,'BEVERAGE_ALCOHOLIC',1),
|
||||||
|
(55,'Apfelwein Sauer','0,33L Flasche',1.90,'BEVERAGE_ALCOHOLIC',1),
|
||||||
|
(56,'Apfelwein Cola','0,33L Flasche',1.90,'BEVERAGE_ALCOHOLIC',1),
|
||||||
|
(57,'Vodka Energy','',4.00,'BEVERAGE_COCKTAIL',1),
|
||||||
|
(58,'Vodka O-Saft','',4.00,'BEVERAGE_COCKTAIL',1),
|
||||||
|
(59,'Whiskey Cola','mit Bourbon',4.00,'BEVERAGE_COCKTAIL',1),
|
||||||
|
(60,'Jägermeister Energy','',4.00,'BEVERAGE_COCKTAIL',1),
|
||||||
|
(61,'Sex on the Beach','',5.50,'BEVERAGE_COCKTAIL',1),
|
||||||
|
(62,'Long Island Ice Tea','',5.50,'BEVERAGE_COCKTAIL',1),
|
||||||
|
(63,'Caipirinha','',5.50,'BEVERAGE_COCKTAIL',1),
|
||||||
|
(64,'Jägermeister','',2.00,'BEVERAGE_SHOT',1),
|
||||||
|
(65,'Tequila','',2.00,'BEVERAGE_SHOT',1),
|
||||||
|
(66,'Pfeffi','Pfefferminz-Schnaps',1.50,'BEVERAGE_SHOT',1),
|
||||||
|
(67,'Zigaretten','Elixyr',8.00,'NON_FOOD',1),
|
||||||
|
(68,'Mentholfilter','passend für Elixyr',1.20,'NON_FOOD',1);
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
CREATE DATABASE IF NOT EXISTS `ez_lan_manager` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */;
|
CREATE DATABASE IF NOT EXISTS `ezgg_lan_manager` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */;
|
||||||
USE `ez_lan_manager`;
|
USE `ezgg_lan_manager`;
|
||||||
-- MySQL dump 10.13 Distrib 5.7.24, for Linux (x86_64)
|
-- MySQL dump 10.13 Distrib 5.7.24, for Linux (x86_64)
|
||||||
--
|
--
|
||||||
-- Host: 127.0.0.1 Database: ez_lan_manager
|
-- Host: 127.0.0.1 Database: ezgg_lan_manager
|
||||||
-- ------------------------------------------------------
|
-- ------------------------------------------------------
|
||||||
-- Server version 5.5.5-10.11.8-MariaDB-0ubuntu0.24.04.1
|
-- Server version 5.5.5-10.11.8-MariaDB-0ubuntu0.24.04.1
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
INSERT INTO `seats` (`seat_id`, `is_blocked`, `seat_category`) VALUES
|
||||||
|
('A01', '0', 'NORMAL'),
|
||||||
|
('A02', '0', 'NORMAL'),
|
||||||
|
('A03', '0', 'NORMAL'),
|
||||||
|
('A04', '0', 'NORMAL'),
|
||||||
|
('A05', '0', 'NORMAL'),
|
||||||
|
('A06', '0', 'NORMAL'),
|
||||||
|
('A10', '0', 'NORMAL'),
|
||||||
|
('A11', '0', 'NORMAL'),
|
||||||
|
('A12', '0', 'NORMAL'),
|
||||||
|
('A13', '0', 'NORMAL'),
|
||||||
|
('A14', '0', 'NORMAL'),
|
||||||
|
('A15', '0', 'NORMAL'),
|
||||||
|
|
||||||
|
('B01', '0', 'NORMAL'),
|
||||||
|
('B02', '0', 'NORMAL'),
|
||||||
|
('B03', '0', 'NORMAL'),
|
||||||
|
('B04', '0', 'NORMAL'),
|
||||||
|
('B05', '0', 'NORMAL'),
|
||||||
|
('B10', '0', 'NORMAL'),
|
||||||
|
('B11', '0', 'NORMAL'),
|
||||||
|
('B12', '0', 'NORMAL'),
|
||||||
|
('B13', '0', 'NORMAL'),
|
||||||
|
('B14', '0', 'NORMAL'),
|
||||||
|
|
||||||
|
('C01', '0', 'NORMAL'),
|
||||||
|
('C02', '0', 'NORMAL'),
|
||||||
|
('C03', '0', 'NORMAL'),
|
||||||
|
('C04', '0', 'NORMAL'),
|
||||||
|
('C05', '0', 'NORMAL'),
|
||||||
|
('C10', '0', 'NORMAL'),
|
||||||
|
('C11', '0', 'NORMAL'),
|
||||||
|
('C12', '0', 'NORMAL'),
|
||||||
|
('C13', '0', 'NORMAL'),
|
||||||
|
('C14', '0', 'NORMAL'),
|
||||||
|
|
||||||
|
('D01', '0', 'NORMAL'),
|
||||||
|
('D02', '0', 'NORMAL'),
|
||||||
|
('D03', '0', 'NORMAL'),
|
||||||
|
('D04', '0', 'NORMAL'),
|
||||||
|
('D05', '0', 'NORMAL'),
|
||||||
|
('D06', '0', 'NORMAL'),
|
||||||
|
('D10', '0', 'NORMAL'),
|
||||||
|
('D11', '0', 'NORMAL'),
|
||||||
|
('D12', '0', 'NORMAL'),
|
||||||
|
('D13', '0', 'NORMAL'),
|
||||||
|
('D14', '0', 'NORMAL'),
|
||||||
|
('D15', '0', 'NORMAL'),
|
||||||
|
|
||||||
|
('E01', '0', 'NORMAL'),
|
||||||
|
('E02', '0', 'NORMAL'),
|
||||||
|
('E03', '0', 'NORMAL'),
|
||||||
|
('E04', '0', 'NORMAL'),
|
||||||
|
('E05', '0', 'NORMAL'),
|
||||||
|
('E06', '0', 'NORMAL'),
|
||||||
|
('E10', '0', 'NORMAL'),
|
||||||
|
('E11', '0', 'NORMAL'),
|
||||||
|
('E12', '0', 'NORMAL'),
|
||||||
|
('E13', '0', 'NORMAL'),
|
||||||
|
('E14', '0', 'NORMAL'),
|
||||||
|
('E15', '0', 'NORMAL');
|
||||||
@@ -1,20 +1,19 @@
|
|||||||
import logging
|
import logging
|
||||||
from asyncio import get_event_loop
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from uuid import uuid4
|
||||||
|
|
||||||
from rio import App, Theme, Color, Font, ComponentPage, Session
|
from rio import App, Theme, Color, Font, ComponentPage, Session
|
||||||
from from_root import from_root
|
from from_root import from_root
|
||||||
|
|
||||||
from src.ez_lan_manager import pages, init_services
|
from src.ezgg_lan_manager import pages, init_services, LocalDataService
|
||||||
from src.ez_lan_manager.helpers.LoggedInGuard import logged_in_guard, not_logged_in_guard, team_guard
|
from src.ezgg_lan_manager.helpers.LoggedInGuard import logged_in_guard, not_logged_in_guard, team_guard
|
||||||
from src.ez_lan_manager.services.DatabaseService import NoDatabaseConnectionError
|
from src.ezgg_lan_manager.services.LocalDataService import LocalData
|
||||||
from src.ez_lan_manager.services.LocalDataService import LocalData
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
|
||||||
|
|
||||||
logger = logging.getLogger("EzLanManager")
|
logger = logging.getLogger("EzggLanManager")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
theme = Theme.from_colors(
|
theme = Theme.from_colors(
|
||||||
@@ -28,16 +27,21 @@ if __name__ == "__main__":
|
|||||||
corner_radius_small=0,
|
corner_radius_small=0,
|
||||||
corner_radius_medium=0,
|
corner_radius_medium=0,
|
||||||
corner_radius_large=0,
|
corner_radius_large=0,
|
||||||
font=Font(from_root("src/ez_lan_manager/assets/fonts/joystix.otf"))
|
font=Font(from_root("src/ezgg_lan_manager/assets/fonts/joystix.otf"))
|
||||||
)
|
)
|
||||||
default_attachments = [LocalData()]
|
default_attachments: list = [LocalData(stored_session_token=None)]
|
||||||
default_attachments.extend(init_services())
|
default_attachments.extend(init_services())
|
||||||
|
|
||||||
lan_info = default_attachments[3].get_lan_info()
|
lan_info = default_attachments[3].get_lan_info()
|
||||||
|
|
||||||
async def on_session_start(session: Session) -> None:
|
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))
|
||||||
await session.set_title(lan_info.name)
|
await session.set_title(lan_info.name)
|
||||||
session.attach(SessionStorage())
|
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:
|
async def on_app_start(a: App) -> None:
|
||||||
init_result = await a.default_attachments[4].init_db_pool()
|
init_result = await a.default_attachments[4].init_db_pool()
|
||||||
@@ -46,7 +50,7 @@ if __name__ == "__main__":
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
app = App(
|
app = App(
|
||||||
name="EZ LAN Manager",
|
name="EZGG LAN Manager",
|
||||||
build=pages.BasePage,
|
build=pages.BasePage,
|
||||||
pages=[
|
pages=[
|
||||||
ComponentPage(
|
ComponentPage(
|
||||||
@@ -62,7 +66,7 @@ if __name__ == "__main__":
|
|||||||
ComponentPage(
|
ComponentPage(
|
||||||
name="Overview",
|
name="Overview",
|
||||||
url_segment="overview",
|
url_segment="overview",
|
||||||
build=lambda: pages.PlaceholderPage(placeholder_name="LAN Übersicht"),
|
build=pages.OverviewPage,
|
||||||
),
|
),
|
||||||
ComponentPage(
|
ComponentPage(
|
||||||
name="BuyTicket",
|
name="BuyTicket",
|
||||||
@@ -157,10 +161,36 @@ if __name__ == "__main__":
|
|||||||
build=pages.ManageTournamentsPage,
|
build=pages.ManageTournamentsPage,
|
||||||
guard=team_guard
|
guard=team_guard
|
||||||
),
|
),
|
||||||
|
ComponentPage(
|
||||||
|
name="AdminNavigationPage",
|
||||||
|
url_segment="admin",
|
||||||
|
build=pages.AdminNavigationPage,
|
||||||
|
guard=team_guard
|
||||||
|
),
|
||||||
ComponentPage(
|
ComponentPage(
|
||||||
name="DbErrorPage",
|
name="DbErrorPage",
|
||||||
url_segment="db-error",
|
url_segment="db-error",
|
||||||
build=pages.DbErrorPage,
|
build=pages.DbErrorPage,
|
||||||
|
),
|
||||||
|
ComponentPage(
|
||||||
|
name="TournamentDetailsPage",
|
||||||
|
url_segment="tournament",
|
||||||
|
build=pages.TournamentDetailsPage,
|
||||||
|
),
|
||||||
|
ComponentPage(
|
||||||
|
name="TournamentRulesPage",
|
||||||
|
url_segment="tournament-rules",
|
||||||
|
build=pages.TournamentRulesPage,
|
||||||
|
),
|
||||||
|
ComponentPage(
|
||||||
|
name="Teams",
|
||||||
|
url_segment="teams",
|
||||||
|
build=pages.TeamsPage,
|
||||||
|
),
|
||||||
|
ComponentPage(
|
||||||
|
name="ConwaysGameOfLife",
|
||||||
|
url_segment="conway",
|
||||||
|
build=pages.ConwayPage,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
theme=theme,
|
theme=theme,
|
||||||
@@ -168,13 +198,13 @@ if __name__ == "__main__":
|
|||||||
default_attachments=default_attachments,
|
default_attachments=default_attachments,
|
||||||
on_session_start=on_session_start,
|
on_session_start=on_session_start,
|
||||||
on_app_start=on_app_start,
|
on_app_start=on_app_start,
|
||||||
icon=from_root("src/ez_lan_manager/assets/img/favicon.png"),
|
icon=from_root("src/ezgg_lan_manager/assets/img/favicon.png"),
|
||||||
meta_tags={
|
meta_tags={
|
||||||
"robots": "INDEX,FOLLOW",
|
"robots": "INDEX,FOLLOW",
|
||||||
"description": f"Info und Verwaltungs-Seite der LAN Party '{lan_info.name} - {lan_info.iteration}'.",
|
"description": f"Info und Verwaltungs-Seite der LAN Party '{lan_info.name} - {lan_info.iteration}'.",
|
||||||
"og:description": f"Info und Verwaltungs-Seite der LAN Party '{lan_info.name} - {lan_info.iteration}'.",
|
"og:description": f"Info und Verwaltungs-Seite der LAN Party '{lan_info.name} - {lan_info.iteration}'.",
|
||||||
"keywords": "Gaming, Clan, Guild, Verein, Club, Einfach, Zocken, Gesellschaft, Videospiele, "
|
"keywords": "Gaming, Clan, Guild, Verein, Club, Einfach, Zocken, Gesellschaft, Videospiele, "
|
||||||
"Videogames, LAN, Party, EZ, LAN, Manager",
|
"Videogames, LAN, Party, EZ, EZGG, LAN, Manager",
|
||||||
"author": "David Rodenkirchen",
|
"author": "David Rodenkirchen",
|
||||||
"publisher": "EZ GG e.V.",
|
"publisher": "EZ GG e.V.",
|
||||||
"copyright": "EZ GG e.V.",
|
"copyright": "EZ GG e.V.",
|
||||||
@@ -186,4 +216,7 @@ if __name__ == "__main__":
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
sys.exit(app.run_as_web_server())
|
sys.exit(app.run_as_web_server(
|
||||||
|
host="0.0.0.0",
|
||||||
|
port=8000,
|
||||||
|
))
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from from_root import from_root
|
|
||||||
|
|
||||||
from src.ez_lan_manager.services import *
|
|
||||||
from src.ez_lan_manager.services.AccountingService import AccountingService
|
|
||||||
from src.ez_lan_manager.services.CateringService import CateringService
|
|
||||||
from src.ez_lan_manager.services.ConfigurationService import ConfigurationService
|
|
||||||
from src.ez_lan_manager.services.DatabaseService import DatabaseService
|
|
||||||
from src.ez_lan_manager.services.LocalDataService import LocalDataService
|
|
||||||
from src.ez_lan_manager.services.MailingService import MailingService
|
|
||||||
from src.ez_lan_manager.services.NewsService import NewsService
|
|
||||||
from src.ez_lan_manager.services.SeatingService import SeatingService
|
|
||||||
from src.ez_lan_manager.services.TicketingService import TicketingService
|
|
||||||
from src.ez_lan_manager.services.UserService import UserService
|
|
||||||
from src.ez_lan_manager.types import *
|
|
||||||
|
|
||||||
# Inits services in the correct order
|
|
||||||
def init_services() -> tuple[AccountingService, CateringService, ConfigurationService, DatabaseService, MailingService, NewsService, SeatingService, TicketingService, UserService, LocalDataService]:
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
|
||||||
configuration_service = ConfigurationService(from_root("config.toml"))
|
|
||||||
db_service = DatabaseService(configuration_service.get_database_configuration())
|
|
||||||
user_service = UserService(db_service)
|
|
||||||
accounting_service = AccountingService(db_service)
|
|
||||||
news_service = NewsService(db_service)
|
|
||||||
mailing_service = MailingService(configuration_service)
|
|
||||||
ticketing_service = TicketingService(configuration_service.get_ticket_info(), db_service, accounting_service)
|
|
||||||
seating_service = SeatingService(configuration_service.get_seating_configuration(), configuration_service.get_lan_info(), db_service, ticketing_service)
|
|
||||||
catering_service = CateringService(db_service, accounting_service, user_service)
|
|
||||||
local_data_service = LocalDataService()
|
|
||||||
|
|
||||||
return accounting_service, catering_service, configuration_service, db_service, mailing_service, news_service, seating_service, ticketing_service, user_service, local_data_service
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
from asyncio import sleep
|
|
||||||
|
|
||||||
from rio import Text, Component, TextStyle
|
|
||||||
|
|
||||||
|
|
||||||
class AnimatedText(Component):
|
|
||||||
def __post_init__(self) -> None:
|
|
||||||
self._display_printing: list[bool] = [False]
|
|
||||||
self.text_comp = Text("")
|
|
||||||
|
|
||||||
async def display_text(self, success: bool, text: str, speed: float = 0.06, font_size: float = 0.9) -> None:
|
|
||||||
if self._display_printing[0]:
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
self._display_printing[0] = True
|
|
||||||
self.text_comp.text = ""
|
|
||||||
if success:
|
|
||||||
self.text_comp.style = TextStyle(
|
|
||||||
fill=self.session.theme.success_color,
|
|
||||||
font_size=font_size
|
|
||||||
)
|
|
||||||
for c in text:
|
|
||||||
self.text_comp.text = self.text_comp.text + c
|
|
||||||
self.text_comp.force_refresh()
|
|
||||||
await sleep(speed)
|
|
||||||
else:
|
|
||||||
self.text_comp.style = TextStyle(
|
|
||||||
fill=self.session.theme.danger_color,
|
|
||||||
font_size=font_size
|
|
||||||
)
|
|
||||||
for c in text:
|
|
||||||
self.text_comp.text = self.text_comp.text + c
|
|
||||||
self.text_comp.force_refresh()
|
|
||||||
await sleep(speed)
|
|
||||||
self._display_printing[0] = False
|
|
||||||
|
|
||||||
def build(self) -> Component:
|
|
||||||
return self.text_comp
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
from copy import copy, deepcopy
|
|
||||||
from typing import Optional, Callable
|
|
||||||
|
|
||||||
from rio import *
|
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, UserService, LocalDataService
|
|
||||||
from src.ez_lan_manager.components.DesktopNavigationButton import DesktopNavigationButton
|
|
||||||
from src.ez_lan_manager.components.UserInfoAndLoginBox import UserInfoAndLoginBox
|
|
||||||
from src.ez_lan_manager.services.LocalDataService import LocalData
|
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
|
||||||
from src.ez_lan_manager.types.User import User
|
|
||||||
|
|
||||||
|
|
||||||
class DesktopNavigation(Component):
|
|
||||||
user: Optional[User] = None
|
|
||||||
force_login_box_refresh: list[Callable] = []
|
|
||||||
|
|
||||||
@event.on_populate
|
|
||||||
async def async_init(self) -> None:
|
|
||||||
self.session[SessionStorage].subscribe_to_logged_in_or_out_event(str(self.__class__), self.async_init)
|
|
||||||
local_data = self.session[LocalData]
|
|
||||||
if local_data.stored_session_token:
|
|
||||||
session_ = self.session[LocalDataService].verify_token(local_data.stored_session_token)
|
|
||||||
if session_:
|
|
||||||
self.session.detach(SessionStorage)
|
|
||||||
self.session.attach(session_)
|
|
||||||
self.user = await self.session[UserService].get_user(session_.user_id)
|
|
||||||
try:
|
|
||||||
# Hack-around, maybe fix in the future
|
|
||||||
self.force_login_box_refresh[-1]()
|
|
||||||
except IndexError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
if self.session[SessionStorage].user_id:
|
|
||||||
self.user = await self.session[UserService].get_user(self.session[SessionStorage].user_id)
|
|
||||||
else:
|
|
||||||
self.user = None
|
|
||||||
|
|
||||||
def build(self) -> Component:
|
|
||||||
lan_info = self.session[ConfigurationService].get_lan_info()
|
|
||||||
user_info_and_login_box = UserInfoAndLoginBox()
|
|
||||||
self.force_login_box_refresh.append(user_info_and_login_box.force_refresh)
|
|
||||||
user_navigation = [
|
|
||||||
DesktopNavigationButton("News", "./news"),
|
|
||||||
Spacer(min_height=1),
|
|
||||||
DesktopNavigationButton(f"Über {lan_info.name} {lan_info.iteration}", "./overview"),
|
|
||||||
DesktopNavigationButton("Ticket kaufen", "./buy_ticket"),
|
|
||||||
DesktopNavigationButton("Sitzplan", "./seating"),
|
|
||||||
DesktopNavigationButton("Catering", "./catering"),
|
|
||||||
DesktopNavigationButton("Teilnehmer", "./guests"),
|
|
||||||
DesktopNavigationButton("Turniere", "./tournaments"),
|
|
||||||
DesktopNavigationButton("FAQ", "./faq"),
|
|
||||||
DesktopNavigationButton("Regeln & AGB", "./rules-gtc"),
|
|
||||||
Spacer(min_height=1),
|
|
||||||
DesktopNavigationButton("Discord", "#", open_new_tab=True), # Temporarily disabled: https://discord.gg/8gTjg34yyH
|
|
||||||
DesktopNavigationButton("Die EZ GG e.V.", "https://ezgg-ev.de/about", open_new_tab=True),
|
|
||||||
DesktopNavigationButton("Kontakt", "./contact"),
|
|
||||||
DesktopNavigationButton("Impressum & DSGVO", "./imprint"),
|
|
||||||
Spacer(min_height=1)
|
|
||||||
]
|
|
||||||
team_navigation = [
|
|
||||||
Text("Verwaltung", align_x=0.5, margin_top=0.3, style=TextStyle(fill=Color.from_hex("F0EADE"), font_size=1.2)),
|
|
||||||
Text("Vorsichtig sein!", align_x=0.5, margin_top=0.3, style=TextStyle(fill=self.session.theme.danger_color, font_size=0.6)),
|
|
||||||
DesktopNavigationButton("News", "./manage-news", is_team_navigation=True),
|
|
||||||
DesktopNavigationButton("Benutzer", "./manage-users", is_team_navigation=True),
|
|
||||||
DesktopNavigationButton("Catering", "./manage-catering", is_team_navigation=True),
|
|
||||||
DesktopNavigationButton("Turniere", "./manage-tournaments", is_team_navigation=True),
|
|
||||||
Spacer(min_height=1),
|
|
||||||
Revealer(
|
|
||||||
header="Normale Navigation",
|
|
||||||
content=Column(*user_navigation),
|
|
||||||
header_style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9)
|
|
||||||
)
|
|
||||||
] if self.user is not None and self.user.is_team_member else []
|
|
||||||
|
|
||||||
nav_to_use = copy(team_navigation) if self.user is not None and self.user.is_team_member else copy(user_navigation)
|
|
||||||
|
|
||||||
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=2.5)),
|
|
||||||
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,
|
|
||||||
*nav_to_use,
|
|
||||||
align_y=0
|
|
||||||
),
|
|
||||||
color=self.session.theme.neutral_color,
|
|
||||||
min_width=15,
|
|
||||||
grow_y=True,
|
|
||||||
corner_radius=(0.5, 0, 0, 0),
|
|
||||||
margin_right=0.1
|
|
||||||
)
|
|
||||||
@@ -1,194 +0,0 @@
|
|||||||
from typing import Callable
|
|
||||||
|
|
||||||
from rio import Component, Rectangle, Grid, Column, Row, Text, TextStyle, Color
|
|
||||||
|
|
||||||
from src.ez_lan_manager.components.SeatingPlanPixels import SeatPixel, WallPixel, InvisiblePixel, TextPixel
|
|
||||||
from src.ez_lan_manager.types.Seat import Seat
|
|
||||||
|
|
||||||
MAX_GRID_WIDTH_PIXELS = 34
|
|
||||||
MAX_GRID_HEIGHT_PIXELS = 45
|
|
||||||
|
|
||||||
class SeatingPlanLegend(Component):
|
|
||||||
def build(self) -> Component:
|
|
||||||
return Column(
|
|
||||||
Text("Legende", style=TextStyle(fill=self.session.theme.neutral_color), justify="center", margin=1),
|
|
||||||
Row(
|
|
||||||
Text("L = Luxus Platz", justify="center", style=TextStyle(fill=self.session.theme.neutral_color)),
|
|
||||||
Text("N = Normaler Platz", justify="center", style=TextStyle(fill=self.session.theme.neutral_color)),
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
Rectangle(
|
|
||||||
content=Column(
|
|
||||||
Text(f"Freier Platz", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False),
|
|
||||||
Text(f"", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5,
|
|
||||||
selectable=False, overflow="wrap")
|
|
||||||
),
|
|
||||||
min_width=1,
|
|
||||||
min_height=1,
|
|
||||||
fill=self.session.theme.success_color,
|
|
||||||
grow_x=False,
|
|
||||||
grow_y=False,
|
|
||||||
hover_fill=self.session.theme.success_color,
|
|
||||||
transition_time=0.4,
|
|
||||||
ripple=True
|
|
||||||
),
|
|
||||||
Rectangle(
|
|
||||||
content=Column(
|
|
||||||
Text(f"Belegter Platz", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False),
|
|
||||||
Text(f"", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5,
|
|
||||||
selectable=False, overflow="wrap")
|
|
||||||
),
|
|
||||||
min_width=1,
|
|
||||||
min_height=1,
|
|
||||||
fill=self.session.theme.danger_color,
|
|
||||||
grow_x=False,
|
|
||||||
grow_y=False,
|
|
||||||
hover_fill=self.session.theme.danger_color,
|
|
||||||
transition_time=0.4,
|
|
||||||
ripple=True
|
|
||||||
),
|
|
||||||
Rectangle(
|
|
||||||
content=Column(
|
|
||||||
Text(f"Eigener Platz", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False),
|
|
||||||
Text(f"", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5,
|
|
||||||
selectable=False, overflow="wrap")
|
|
||||||
),
|
|
||||||
min_width=1,
|
|
||||||
min_height=1,
|
|
||||||
fill=Color.from_hex("800080"),
|
|
||||||
grow_x=False,
|
|
||||||
grow_y=False,
|
|
||||||
hover_fill=Color.from_hex("800080"),
|
|
||||||
transition_time=0.4,
|
|
||||||
ripple=True
|
|
||||||
),
|
|
||||||
margin=1,
|
|
||||||
spacing=1
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class SeatingPlan(Component):
|
|
||||||
seat_clicked_cb: Callable
|
|
||||||
seating_info: list[Seat]
|
|
||||||
|
|
||||||
def get_seat(self, seat_id: str) -> Seat:
|
|
||||||
return next(filter(lambda seat: seat.seat_id == seat_id, self.seating_info))
|
|
||||||
|
|
||||||
"""
|
|
||||||
This seating plan is for the community center "Bottenhorn"
|
|
||||||
"""
|
|
||||||
def build(self) -> Component:
|
|
||||||
grid = Grid()
|
|
||||||
# Outlines
|
|
||||||
for column_id in range(0, MAX_GRID_WIDTH_PIXELS):
|
|
||||||
grid.add(InvisiblePixel(), row=0, column=column_id)
|
|
||||||
for y in range(0, 13):
|
|
||||||
grid.add(WallPixel(), row=y, column=0)
|
|
||||||
for y in range(13, 19):
|
|
||||||
grid.add(InvisiblePixel(), row=y, column=0)
|
|
||||||
for y in range(19, MAX_GRID_HEIGHT_PIXELS):
|
|
||||||
grid.add(WallPixel(), row=y, column=0)
|
|
||||||
|
|
||||||
# Block A
|
|
||||||
block_a_margin_left = 12
|
|
||||||
block_a_margin_top = 1
|
|
||||||
(grid
|
|
||||||
.add(SeatPixel("A01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A01")), row=block_a_margin_top, column=block_a_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("A02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A02")), row=block_a_margin_top + 4, column=block_a_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("A03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A03")), row=block_a_margin_top + 8, column=block_a_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("A10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A10")), row=block_a_margin_top, column=block_a_margin_left + 3, width=2, height=3)
|
|
||||||
.add(SeatPixel("A11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A11")), row=block_a_margin_top + 4, column=block_a_margin_left + 3, width=2, height=3)
|
|
||||||
.add(SeatPixel("A12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A12")), row=block_a_margin_top + 8, column=block_a_margin_left + 3, width=2, height=3)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Block B
|
|
||||||
block_b_margin_left = 20
|
|
||||||
block_b_margin_top = 1
|
|
||||||
(grid
|
|
||||||
.add(SeatPixel("B01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B01")), row=block_b_margin_top, column=block_b_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("B02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B02")), row=block_b_margin_top + 4, column=block_b_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("B03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B03")), row=block_b_margin_top + 8, column=block_b_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("B10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B10")), row=block_b_margin_top, column=block_b_margin_left + 3, width=2, height=3)
|
|
||||||
.add(SeatPixel("B11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B11")), row=block_b_margin_top + 4, column=block_b_margin_left + 3, width=2, height=3)
|
|
||||||
.add(SeatPixel("B12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B12")), row=block_b_margin_top + 8, column=block_b_margin_left + 3, width=2, height=3)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Block C
|
|
||||||
block_c_margin_left = 28
|
|
||||||
block_c_margin_top = 1
|
|
||||||
(grid
|
|
||||||
.add(SeatPixel("C01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C01")), row=block_c_margin_top, column=block_c_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("C02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C02")), row=block_c_margin_top + 4, column=block_c_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("C03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C03")), row=block_c_margin_top + 8, column=block_c_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("C10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C10")), row=block_c_margin_top, column=block_c_margin_left + 3, width=2, height=3)
|
|
||||||
.add(SeatPixel("C11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C11")), row=block_c_margin_top + 4, column=block_c_margin_left + 3, width=2, height=3)
|
|
||||||
.add(SeatPixel("C12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C12")), row=block_c_margin_top + 8, column=block_c_margin_left + 3, width=2, height=3)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Block D
|
|
||||||
block_d_margin_left = 20
|
|
||||||
block_d_margin_top = 20
|
|
||||||
(grid
|
|
||||||
.add(SeatPixel("D01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D01")), row=block_d_margin_top, column=block_d_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("D02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D02")), row=block_d_margin_top + 4, column=block_d_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("D03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D03")), row=block_d_margin_top + 8, column=block_d_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("D10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D10")), row=block_d_margin_top, column=block_d_margin_left + 3, width=2, height=3)
|
|
||||||
.add(SeatPixel("D11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D11")), row=block_d_margin_top + 4, column=block_d_margin_left + 3, width=2, height=3)
|
|
||||||
.add(SeatPixel("D12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D12")), row=block_d_margin_top + 8, column=block_d_margin_left + 3, width=2, height=3)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Block E
|
|
||||||
block_e_margin_left = 28
|
|
||||||
block_e_margin_top = 20
|
|
||||||
(grid
|
|
||||||
.add(SeatPixel("E01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E01")), row=block_e_margin_top, column=block_e_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("E02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E02")), row=block_e_margin_top + 4, column=block_e_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("E03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E03")), row=block_e_margin_top + 8, column=block_e_margin_left, width=2, height=3)
|
|
||||||
.add(SeatPixel("E10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E10")), row=block_e_margin_top, column=block_e_margin_left + 3, width=2, height=3)
|
|
||||||
.add(SeatPixel("E11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E11")), row=block_e_margin_top + 4, column=block_e_margin_left + 3, width=2, height=3)
|
|
||||||
.add(SeatPixel("E12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E12")), row=block_e_margin_top + 8, column=block_e_margin_left + 3, width=2, height=3)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Middle Wall
|
|
||||||
for y in range(0, 13):
|
|
||||||
grid.add(WallPixel(), row=y, column=10)
|
|
||||||
for y in range(19, MAX_GRID_HEIGHT_PIXELS):
|
|
||||||
grid.add(WallPixel(), row=y, column=10)
|
|
||||||
|
|
||||||
# Stage
|
|
||||||
for x in range(11, MAX_GRID_WIDTH_PIXELS):
|
|
||||||
grid.add(WallPixel(), row=35, column=x)
|
|
||||||
grid.add(TextPixel(text="Bühne"), row=36, column=11, width=24, height=9)
|
|
||||||
|
|
||||||
# Drinks
|
|
||||||
grid.add(TextPixel(text="G\ne\nt\nr\nä\nn\nk\ne"), row=21, column=11, width=3, height=11)
|
|
||||||
|
|
||||||
# Sleeping
|
|
||||||
grid.add(TextPixel(icon_name="material/bed"), row=1, column=1, width=4, height=11)
|
|
||||||
|
|
||||||
# Toilet
|
|
||||||
grid.add(TextPixel(icon_name="material/floor", no_outline=True), row=1, column=7, width=3, height=2)
|
|
||||||
grid.add(TextPixel(icon_name="material/north", no_outline=True), row=3, column=7, width=3, height=2)
|
|
||||||
grid.add(TextPixel(icon_name="material/wc"), row=5, column=7, width=3, height=2)
|
|
||||||
|
|
||||||
# Entry/Helpdesk
|
|
||||||
grid.add(TextPixel(text="Einlass\n &Orga"), row=19, column=3, width=7, height=5)
|
|
||||||
|
|
||||||
# Wall below Entry/Helpdesk
|
|
||||||
for y in range(24, MAX_GRID_HEIGHT_PIXELS):
|
|
||||||
grid.add(WallPixel(), row=y, column=3)
|
|
||||||
|
|
||||||
# Entry Arrow
|
|
||||||
grid.add(TextPixel(icon_name="material/east", no_outline=True), row=15, column=1, width=2, height=2)
|
|
||||||
|
|
||||||
return Rectangle(
|
|
||||||
content=grid,
|
|
||||||
grow_x=True,
|
|
||||||
grow_y=True,
|
|
||||||
stroke_color=self.session.theme.neutral_color,
|
|
||||||
stroke_width=0.1,
|
|
||||||
fill=self.session.theme.primary_color,
|
|
||||||
margin=0.5
|
|
||||||
)
|
|
||||||
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from rio import Component
|
|
||||||
from src.ez_lan_manager.components.LoginBox import LoginBox
|
|
||||||
from src.ez_lan_manager.components.UserInfoBox import UserInfoBox
|
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__.split(".")[-1])
|
|
||||||
|
|
||||||
class UserInfoAndLoginBox(Component):
|
|
||||||
def build(self) -> Component:
|
|
||||||
if self.session[SessionStorage].user_id is None:
|
|
||||||
return LoginBox(status_change_cb=self.force_refresh)
|
|
||||||
else:
|
|
||||||
return UserInfoBox(status_change_cb=self.force_refresh)
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
from typing import Optional
|
|
||||||
|
|
||||||
from rio import URL, GuardEvent
|
|
||||||
|
|
||||||
from src.ez_lan_manager.services.UserService import UserService
|
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
|
||||||
|
|
||||||
|
|
||||||
# Guards pages against access from users that are NOT logged in
|
|
||||||
def logged_in_guard(event: GuardEvent) -> Optional[URL]:
|
|
||||||
if event.session[SessionStorage].user_id is None:
|
|
||||||
return URL("./")
|
|
||||||
|
|
||||||
# Guards pages against access from users that ARE logged in
|
|
||||||
def not_logged_in_guard(event: GuardEvent) -> Optional[URL]:
|
|
||||||
if event.session[SessionStorage].user_id is not None:
|
|
||||||
return URL("./")
|
|
||||||
|
|
||||||
# Guards pages against access from users that are NOT logged in and NOT team members
|
|
||||||
def team_guard(event: GuardEvent) -> Optional[URL]:
|
|
||||||
user_id = event.session[SessionStorage].user_id
|
|
||||||
is_team_member = event.session[SessionStorage].is_team_member
|
|
||||||
if user_id is None or not is_team_member:
|
|
||||||
return URL("./")
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
from typing import * # type: ignore
|
|
||||||
|
|
||||||
from rio import Component, event, Spacer, Card, Container, Column, Row, TextStyle, Color, Text, PageView
|
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, DatabaseService
|
|
||||||
from src.ez_lan_manager.components.DesktopNavigation import DesktopNavigation
|
|
||||||
|
|
||||||
class BasePage(Component):
|
|
||||||
color = "secondary"
|
|
||||||
corner_radius = (0, 0.5, 0, 0)
|
|
||||||
@event.periodic(60)
|
|
||||||
async def check_db_conn(self) -> None:
|
|
||||||
is_healthy = await self.session[DatabaseService].is_healthy()
|
|
||||||
if not is_healthy:
|
|
||||||
self.session.navigate_to("./db-error")
|
|
||||||
|
|
||||||
@event.on_window_size_change
|
|
||||||
async def on_window_size_change(self):
|
|
||||||
self.force_refresh()
|
|
||||||
|
|
||||||
def build(self) -> Component:
|
|
||||||
content = Card(
|
|
||||||
PageView(),
|
|
||||||
color="secondary",
|
|
||||||
min_width=38,
|
|
||||||
corner_radius=(0, 0.5, 0, 0)
|
|
||||||
)
|
|
||||||
if self.session.window_width > 28:
|
|
||||||
return Container(
|
|
||||||
content=Column(
|
|
||||||
Column(
|
|
||||||
Row(
|
|
||||||
Spacer(grow_x=True, grow_y=True),
|
|
||||||
DesktopNavigation(),
|
|
||||||
content,
|
|
||||||
Spacer(grow_x=True, grow_y=True),
|
|
||||||
grow_y=True
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
Spacer(grow_x=True, grow_y=False),
|
|
||||||
Card(
|
|
||||||
content=Text(f"EZ LAN Manager Version {self.session[ConfigurationService].APP_VERSION} © EZ GG e.V.", align_x=0.5, align_y=0.5, style=TextStyle(fill=self.session.theme.primary_color, font_size=0.5)),
|
|
||||||
color=self.session.theme.neutral_color,
|
|
||||||
corner_radius=(0, 0, 0.5, 0.5),
|
|
||||||
grow_x=False,
|
|
||||||
grow_y=False,
|
|
||||||
min_height=1.2,
|
|
||||||
min_width=53.1,
|
|
||||||
margin_bottom=3
|
|
||||||
),
|
|
||||||
Spacer(grow_x=True, grow_y=False),
|
|
||||||
grow_y=False
|
|
||||||
),
|
|
||||||
margin_top=4
|
|
||||||
)
|
|
||||||
),
|
|
||||||
grow_x=True,
|
|
||||||
grow_y=True
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
return Text(
|
|
||||||
"Der EZ LAN Manager wird\nauf mobilen Endgeräten nur\nim Querformat unterstützt.\nBitte drehe dein Gerät.",
|
|
||||||
align_x=0.5,
|
|
||||||
align_y=0.5,
|
|
||||||
style=TextStyle(fill=Color.from_hex("FFFFFF"), font_size=0.8)
|
|
||||||
)
|
|
||||||
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
from typing import Optional
|
|
||||||
|
|
||||||
from rio import Column, Component, event, Spacer
|
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, UserService
|
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
|
||||||
from src.ez_lan_manager.components.UserEditForm import UserEditForm
|
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
|
||||||
from src.ez_lan_manager.types.User import User
|
|
||||||
|
|
||||||
|
|
||||||
class EditProfilePage(Component):
|
|
||||||
user: Optional[User] = None
|
|
||||||
pfp: Optional[bytes] = None
|
|
||||||
|
|
||||||
@event.on_populate
|
|
||||||
async def on_populate(self) -> None:
|
|
||||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Profil bearbeiten")
|
|
||||||
self.user = await self.session[UserService].get_user(self.session[SessionStorage].user_id)
|
|
||||||
self.pfp = await self.session[UserService].get_profile_picture(self.user.user_id)
|
|
||||||
|
|
||||||
def build(self) -> Component:
|
|
||||||
return Column(
|
|
||||||
MainViewContentBox(UserEditForm(is_own_profile=True)),
|
|
||||||
Spacer(grow_y=True)
|
|
||||||
)
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from rio import Column, Component, event, TextStyle, Text, Spacer
|
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService
|
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__.split(".")[-1])
|
|
||||||
|
|
||||||
class ManageTournamentsPage(Component):
|
|
||||||
@event.on_populate
|
|
||||||
async def on_populate(self) -> None:
|
|
||||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Turnier Verwaltung")
|
|
||||||
|
|
||||||
def build(self) -> Component:
|
|
||||||
return Column(
|
|
||||||
MainViewContentBox(
|
|
||||||
Column(
|
|
||||||
Text(
|
|
||||||
text="Turnier Verwaltung",
|
|
||||||
style=TextStyle(
|
|
||||||
fill=self.session.theme.background_color,
|
|
||||||
font_size=1.2
|
|
||||||
),
|
|
||||||
margin_top=2,
|
|
||||||
margin_bottom=2,
|
|
||||||
align_x=0.5
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
Spacer()
|
|
||||||
)
|
|
||||||
@@ -1,178 +0,0 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from email_validator import validate_email, EmailNotValidError
|
|
||||||
from rio import Column, Component, event, Text, TextStyle, TextInput, TextInputChangeEvent, Button
|
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, UserService, MailingService
|
|
||||||
from src.ez_lan_manager.components.AnimatedText import AnimatedText
|
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
|
||||||
|
|
||||||
MINIMUM_PASSWORD_LENGTH = 6
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__.split(".")[-1])
|
|
||||||
|
|
||||||
|
|
||||||
class RegisterPage(Component):
|
|
||||||
def on_pw_change(self, _: TextInputChangeEvent) -> None:
|
|
||||||
if not (self.pw_1.text == self.pw_2.text) or len(self.pw_1.text) < MINIMUM_PASSWORD_LENGTH:
|
|
||||||
self.pw_1.is_valid = False
|
|
||||||
self.pw_2.is_valid = False
|
|
||||||
return
|
|
||||||
self.pw_1.is_valid = True
|
|
||||||
self.pw_2.is_valid = True
|
|
||||||
|
|
||||||
def on_email_changed(self, change_event: TextInputChangeEvent) -> None:
|
|
||||||
try:
|
|
||||||
validate_email(change_event.text, check_deliverability=False)
|
|
||||||
self.email_input.is_valid = True
|
|
||||||
except EmailNotValidError:
|
|
||||||
self.email_input.is_valid = False
|
|
||||||
|
|
||||||
def on_user_name_input_change(self, _: TextInputChangeEvent) -> None:
|
|
||||||
current_text = self.user_name_input.text
|
|
||||||
if len(current_text) > UserService.MAX_USERNAME_LENGTH:
|
|
||||||
self.user_name_input.text = current_text[:UserService.MAX_USERNAME_LENGTH]
|
|
||||||
|
|
||||||
async def on_submit_button_pressed(self) -> None:
|
|
||||||
self.submit_button.is_loading = True
|
|
||||||
self.submit_button.force_refresh()
|
|
||||||
|
|
||||||
if len(self.user_name_input.text) < 1:
|
|
||||||
await self.animated_text.display_text(False, "Nutzername darf nicht leer sein!")
|
|
||||||
self.submit_button.is_loading = False
|
|
||||||
return
|
|
||||||
|
|
||||||
if not (self.pw_1.text == self.pw_2.text):
|
|
||||||
await self.animated_text.display_text(False, "Passwörter stimmen nicht überein!")
|
|
||||||
self.submit_button.is_loading = False
|
|
||||||
return
|
|
||||||
|
|
||||||
if len(self.pw_1.text) < MINIMUM_PASSWORD_LENGTH:
|
|
||||||
await self.animated_text.display_text(False, f"Passwort muss mindestens {MINIMUM_PASSWORD_LENGTH} Zeichen lang sein!")
|
|
||||||
self.submit_button.is_loading = False
|
|
||||||
return
|
|
||||||
|
|
||||||
if not self.email_input.is_valid or len(self.email_input.text) < 3:
|
|
||||||
await self.animated_text.display_text(False, "E-Mail Adresse ungültig!")
|
|
||||||
self.submit_button.is_loading = False
|
|
||||||
return
|
|
||||||
|
|
||||||
user_service = self.session[UserService]
|
|
||||||
mailing_service = self.session[MailingService]
|
|
||||||
lan_info = self.session[ConfigurationService].get_lan_info()
|
|
||||||
|
|
||||||
if await user_service.get_user(self.email_input.text) is not None or await user_service.get_user(self.user_name_input.text) is not None:
|
|
||||||
await self.animated_text.display_text(False, "Benutzername oder E-Mail bereits regestriert!")
|
|
||||||
self.submit_button.is_loading = False
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
|
||||||
new_user = await user_service.create_user(self.user_name_input.text, self.email_input.text, self.pw_1.text)
|
|
||||||
if not new_user:
|
|
||||||
raise RuntimeError("User could not be created")
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Unknown error during new user registration: {e}")
|
|
||||||
await self.animated_text.display_text(False, "Es ist ein unbekannter Fehler aufgetreten :(")
|
|
||||||
self.submit_button.is_loading = False
|
|
||||||
return
|
|
||||||
|
|
||||||
await mailing_service.send_email(
|
|
||||||
subject="Erfolgreiche Registrierung",
|
|
||||||
body=f"Hallo {self.user_name_input.text},\n\n"
|
|
||||||
f"Du hast dich erfolgreich beim EZ-LAN Manager für {lan_info.name} {lan_info.iteration} registriert.\n\n"
|
|
||||||
f"Wenn du dich nicht registriert hast, kontaktiere bitte unser Team über unsere Homepage.\n\n"
|
|
||||||
f"Liebe Grüße\nDein {lan_info.name} - Team",
|
|
||||||
receiver=self.email_input.text
|
|
||||||
)
|
|
||||||
|
|
||||||
self.submit_button.is_loading = False
|
|
||||||
await self.animated_text.display_text(True, "Erfolgreich registriert!")
|
|
||||||
|
|
||||||
@event.on_populate
|
|
||||||
async def on_populate(self) -> None:
|
|
||||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Registrieren")
|
|
||||||
|
|
||||||
def build(self) -> Component:
|
|
||||||
self.user_name_input = TextInput(
|
|
||||||
label="Benutzername",
|
|
||||||
text="",
|
|
||||||
margin_left=1,
|
|
||||||
margin_right=1,
|
|
||||||
margin_bottom=1,
|
|
||||||
grow_x=True,
|
|
||||||
on_change=self.on_user_name_input_change
|
|
||||||
)
|
|
||||||
self.email_input = TextInput(
|
|
||||||
label="E-Mail Adresse",
|
|
||||||
text="",
|
|
||||||
margin_left=1,
|
|
||||||
margin_right=1,
|
|
||||||
margin_bottom=1,
|
|
||||||
grow_x=True,
|
|
||||||
on_change=self.on_email_changed
|
|
||||||
)
|
|
||||||
self.pw_1 = TextInput(
|
|
||||||
label="Passwort",
|
|
||||||
text="",
|
|
||||||
margin_left=1,
|
|
||||||
margin_right=1,
|
|
||||||
margin_bottom=1,
|
|
||||||
grow_x=True,
|
|
||||||
is_secret=True,
|
|
||||||
on_change=self.on_pw_change
|
|
||||||
)
|
|
||||||
self.pw_2 = TextInput(
|
|
||||||
label="Passwort wiederholen",
|
|
||||||
text="",
|
|
||||||
margin_left=1,
|
|
||||||
margin_right=1,
|
|
||||||
margin_bottom=1,
|
|
||||||
grow_x=True,
|
|
||||||
is_secret=True,
|
|
||||||
on_change=self.on_pw_change
|
|
||||||
)
|
|
||||||
self.submit_button = Button(
|
|
||||||
content=Text(
|
|
||||||
"Registrieren",
|
|
||||||
style=TextStyle(fill=self.session.theme.background_color, font_size=0.9),
|
|
||||||
align_x=0.5
|
|
||||||
),
|
|
||||||
grow_x=True,
|
|
||||||
margin_top=2,
|
|
||||||
margin_left=1,
|
|
||||||
margin_right=1,
|
|
||||||
margin_bottom=1,
|
|
||||||
shape="rectangle",
|
|
||||||
style="minor",
|
|
||||||
color=self.session.theme.secondary_color,
|
|
||||||
on_press=self.on_submit_button_pressed
|
|
||||||
)
|
|
||||||
self.animated_text = AnimatedText(
|
|
||||||
margin_top=2,
|
|
||||||
margin_left=1,
|
|
||||||
margin_right=1,
|
|
||||||
margin_bottom=2
|
|
||||||
)
|
|
||||||
return Column(
|
|
||||||
MainViewContentBox(
|
|
||||||
content=Column(
|
|
||||||
Text(
|
|
||||||
"Neues Konto anlegen",
|
|
||||||
style=TextStyle(
|
|
||||||
fill=self.session.theme.background_color,
|
|
||||||
font_size=1.2
|
|
||||||
),
|
|
||||||
margin_top=2,
|
|
||||||
margin_bottom=2,
|
|
||||||
align_x=0.5
|
|
||||||
),
|
|
||||||
self.user_name_input,
|
|
||||||
self.email_input,
|
|
||||||
self.pw_1,
|
|
||||||
self.pw_2,
|
|
||||||
self.submit_button,
|
|
||||||
self.animated_text
|
|
||||||
)
|
|
||||||
),
|
|
||||||
align_y=0,
|
|
||||||
)
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
from rio import Column, Component, event, TextStyle, Text
|
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService
|
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
|
||||||
|
|
||||||
|
|
||||||
class TournamentsPage(Component):
|
|
||||||
@event.on_populate
|
|
||||||
async def on_populate(self) -> None:
|
|
||||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Turniere")
|
|
||||||
|
|
||||||
def build(self) -> Component:
|
|
||||||
return Column(
|
|
||||||
MainViewContentBox(
|
|
||||||
Column(
|
|
||||||
Text(
|
|
||||||
text="Turniere",
|
|
||||||
style=TextStyle(
|
|
||||||
fill=self.session.theme.background_color,
|
|
||||||
font_size=1.2
|
|
||||||
),
|
|
||||||
margin_top=2,
|
|
||||||
margin_bottom=0,
|
|
||||||
align_x=0.5
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
text="Aktuell ist noch kein Turnierplan hinterlegt.",
|
|
||||||
style=TextStyle(
|
|
||||||
fill=self.session.theme.background_color,
|
|
||||||
font_size=0.9
|
|
||||||
),
|
|
||||||
margin=1,
|
|
||||||
overflow="wrap"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
align_y=0
|
|
||||||
)
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import logging
|
|
||||||
from collections.abc import Callable
|
|
||||||
from dataclasses import dataclass, field
|
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__.split(".")[-1])
|
|
||||||
|
|
||||||
|
|
||||||
# ToDo: Persist between reloads: https://rio.dev/docs/howto/persistent-settings
|
|
||||||
# Note for ToDo: rio.UserSettings are saved LOCALLY, do not just read a user_id here!
|
|
||||||
@dataclass(frozen=False)
|
|
||||||
class SessionStorage:
|
|
||||||
_user_id: Optional[int] = None # DEBUG: Put user ID here to skip login
|
|
||||||
_is_team_member: bool = False
|
|
||||||
_notification_callbacks: dict[str, Callable] = field(default_factory=dict)
|
|
||||||
|
|
||||||
async def clear(self) -> None:
|
|
||||||
await self.set_user_id_and_team_member_flag(None, False)
|
|
||||||
|
|
||||||
def subscribe_to_logged_in_or_out_event(self, component_id: str, callback: Callable) -> None:
|
|
||||||
self._notification_callbacks[component_id] = callback
|
|
||||||
|
|
||||||
@property
|
|
||||||
def user_id(self) -> Optional[int]:
|
|
||||||
return self._user_id
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_team_member(self) -> bool:
|
|
||||||
return self._is_team_member
|
|
||||||
|
|
||||||
async def set_user_id_and_team_member_flag(self, user_id: Optional[int], is_team_member: bool) -> None:
|
|
||||||
self._user_id = user_id
|
|
||||||
self._is_team_member = is_team_member
|
|
||||||
for component_id, callback in self._notification_callbacks.items():
|
|
||||||
logger.debug(f"Calling logged in callback from {component_id}")
|
|
||||||
await callback()
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
from from_root import from_root
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager.services import *
|
||||||
|
from src.ezgg_lan_manager.services.AccountingService import AccountingService
|
||||||
|
from src.ezgg_lan_manager.services.CateringService import CateringService
|
||||||
|
from src.ezgg_lan_manager.services.ConfigurationService import ConfigurationService
|
||||||
|
from src.ezgg_lan_manager.services.DatabaseService import DatabaseService
|
||||||
|
from src.ezgg_lan_manager.services.LocalDataService import LocalDataService
|
||||||
|
from src.ezgg_lan_manager.services.MailingService import MailingService
|
||||||
|
from src.ezgg_lan_manager.services.NewsService import NewsService
|
||||||
|
from src.ezgg_lan_manager.services.RefreshService import RefreshService
|
||||||
|
from src.ezgg_lan_manager.services.ReceiptPrintingService import ReceiptPrintingService
|
||||||
|
from src.ezgg_lan_manager.services.SeatingService import SeatingService
|
||||||
|
from src.ezgg_lan_manager.services.TeamService import TeamService
|
||||||
|
from src.ezgg_lan_manager.services.TicketingService import TicketingService
|
||||||
|
from src.ezgg_lan_manager.services.TournamentService import TournamentService
|
||||||
|
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]:
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
configuration_service = ConfigurationService(from_root("config.toml"))
|
||||||
|
db_service = DatabaseService(configuration_service.get_database_configuration())
|
||||||
|
user_service = UserService(db_service)
|
||||||
|
accounting_service = AccountingService(db_service)
|
||||||
|
news_service = NewsService(db_service)
|
||||||
|
mailing_service = MailingService(configuration_service)
|
||||||
|
ticketing_service = TicketingService(configuration_service.get_ticket_info(), db_service, accounting_service)
|
||||||
|
seating_service = SeatingService(configuration_service.get_lan_info(), db_service, ticketing_service)
|
||||||
|
receipt_printing_service = ReceiptPrintingService(seating_service, configuration_service.get_receipt_printing_configuration(), configuration_service.DEV_MODE_ACTIVE)
|
||||||
|
catering_service = CateringService(db_service, accounting_service, user_service, receipt_printing_service)
|
||||||
|
local_data_service = LocalDataService()
|
||||||
|
tournament_service = TournamentService(db_service, user_service)
|
||||||
|
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
|
||||||
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
@@ -0,0 +1,36 @@
|
|||||||
|
from rio import Component, Rectangle, Text, Column, Icon, TextStyle, PointerEventListener, PointerEvent
|
||||||
|
|
||||||
|
|
||||||
|
class AdminNavigationCard(Component):
|
||||||
|
icon_name: str
|
||||||
|
display_text: str
|
||||||
|
target_url: str
|
||||||
|
|
||||||
|
def on_press(self, _: PointerEvent) -> None:
|
||||||
|
if self.target_url:
|
||||||
|
self.session.navigate_to(self.target_url)
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
return PointerEventListener(
|
||||||
|
Rectangle(
|
||||||
|
content=Column(
|
||||||
|
Icon(
|
||||||
|
self.icon_name,
|
||||||
|
min_width=3.5,
|
||||||
|
min_height=3.5,
|
||||||
|
fill="background",
|
||||||
|
margin=1
|
||||||
|
),
|
||||||
|
Text(self.display_text, style=TextStyle(fill=self.session.theme.background_color), justify="center", margin=1, margin_top=0)
|
||||||
|
),
|
||||||
|
cursor="pointer",
|
||||||
|
stroke_width=0.2,
|
||||||
|
stroke_color=self.session.theme.background_color,
|
||||||
|
hover_stroke_width=0.2,
|
||||||
|
hover_stroke_color=self.session.theme.hud_color,
|
||||||
|
min_width=10,
|
||||||
|
min_height=10,
|
||||||
|
corner_radius=0.2
|
||||||
|
),
|
||||||
|
on_press=self.on_press
|
||||||
|
)
|
||||||
@@ -4,7 +4,7 @@ from decimal import Decimal
|
|||||||
import rio
|
import rio
|
||||||
from rio import Component, Row, Text, IconButton, TextStyle
|
from rio import Component, Row, Text, IconButton, TextStyle
|
||||||
|
|
||||||
from src.ez_lan_manager import AccountingService
|
from src.ezgg_lan_manager import AccountingService
|
||||||
|
|
||||||
MAX_LEN = 24
|
MAX_LEN = 24
|
||||||
|
|
||||||
@@ -3,9 +3,9 @@ from typing import Optional, Callable
|
|||||||
|
|
||||||
from rio import Component, Row, Card, Column, Text, TextStyle, Spacer, PointerEventListener, Button
|
from rio import Component, Row, Card, Column, Text, TextStyle, Spacer, PointerEventListener, Button
|
||||||
|
|
||||||
from src.ez_lan_manager.services.CateringService import CateringService
|
from src.ezgg_lan_manager.services.CateringService import CateringService
|
||||||
from src.ez_lan_manager.types.CateringOrder import CateringOrder, CateringOrderStatus
|
from src.ezgg_lan_manager.types.CateringOrder import CateringOrder, CateringOrderStatus
|
||||||
from src.ez_lan_manager.types.Seat import Seat
|
from src.ezgg_lan_manager.types.Seat import Seat
|
||||||
|
|
||||||
class CateringManagementOrderDisplayStatusButton(Component):
|
class CateringManagementOrderDisplayStatusButton(Component):
|
||||||
status: CateringOrderStatus
|
status: CateringOrderStatus
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from rio import Component, Row, Text, TextStyle, Color, Rectangle, CursorStyle
|
from rio import Component, Row, Text, TextStyle, Color, Rectangle, PointerEventListener
|
||||||
from rio.components.pointer_event_listener import PointerEvent, PointerEventListener
|
|
||||||
|
|
||||||
from src.ez_lan_manager.types.CateringOrder import CateringOrderStatus, CateringOrder
|
from src.ezgg_lan_manager.types.CateringOrder import CateringOrderStatus, CateringOrder
|
||||||
|
|
||||||
MAX_LEN = 24
|
MAX_LEN = 24
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ class CateringOrderItem(Component):
|
|||||||
fill=self.session.theme.primary_color,
|
fill=self.session.theme.primary_color,
|
||||||
hover_fill=self.session.theme.hud_color,
|
hover_fill=self.session.theme.hud_color,
|
||||||
transition_time=0.1,
|
transition_time=0.1,
|
||||||
cursor=CursorStyle.POINTER
|
cursor="pointer"
|
||||||
),
|
),
|
||||||
on_press=lambda _: self.info_modal_cb(self.order),
|
on_press=lambda _: self.info_modal_cb(self.order),
|
||||||
)
|
)
|
||||||
@@ -4,7 +4,7 @@ from typing import Callable
|
|||||||
import rio
|
import rio
|
||||||
from rio import Component, Row, Text, IconButton, TextStyle, Column, Spacer, Card, Color
|
from rio import Component, Row, Text, IconButton, TextStyle, Column, Spacer, Card, Color
|
||||||
|
|
||||||
from src.ez_lan_manager import AccountingService
|
from src.ezgg_lan_manager import AccountingService
|
||||||
|
|
||||||
MAX_LEN = 24
|
MAX_LEN = 24
|
||||||
|
|
||||||
@@ -46,10 +46,10 @@ class CateringSelectionItem(Component):
|
|||||||
Text(AccountingService.make_euro_string_from_decimal(self.article_price),
|
Text(AccountingService.make_euro_string_from_decimal(self.article_price),
|
||||||
style=TextStyle(fill=self.session.theme.background_color, font_size=0.9)),
|
style=TextStyle(fill=self.session.theme.background_color, font_size=0.9)),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon="material/add",
|
icon="material/add" if self.is_sensitive else "material/do_not_disturb_on_total_silence",
|
||||||
min_size=2,
|
min_size=2,
|
||||||
color=self.session.theme.success_color,
|
color=self.session.theme.success_color if self.is_sensitive else self.session.theme.danger_color,
|
||||||
style="plain-text",
|
style="colored-text",
|
||||||
on_press=lambda: self.on_add_callback(self.article_id),
|
on_press=lambda: self.on_add_callback(self.article_id),
|
||||||
is_sensitive=self.is_sensitive
|
is_sensitive=self.is_sensitive
|
||||||
),
|
),
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
from typing import Optional, Callable
|
||||||
|
|
||||||
|
from rio import Component, event, Spacer, Card, Column, Text, TextStyle
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager.services.ConfigurationService import ConfigurationService
|
||||||
|
from src.ezgg_lan_manager.services.UserService import UserService
|
||||||
|
from src.ezgg_lan_manager.components.DesktopNavigationButton import DesktopNavigationButton
|
||||||
|
from src.ezgg_lan_manager.components.NavigationSponsorBox import NavigationSponsorBox
|
||||||
|
from src.ezgg_lan_manager.components.UserInfoAndLoginBox import UserInfoAndLoginBox
|
||||||
|
from src.ezgg_lan_manager.types.User import User
|
||||||
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
|
|
||||||
|
class DesktopNavigation(Component):
|
||||||
|
user: Optional[User] = None
|
||||||
|
|
||||||
|
@event.on_populate
|
||||||
|
async def on_populate(self) -> None:
|
||||||
|
try:
|
||||||
|
self.user = await self.session[UserService].get_user(self.session[UserSession].user_id)
|
||||||
|
except KeyError:
|
||||||
|
self.user = None
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
lan_info = self.session[ConfigurationService].get_lan_info()
|
||||||
|
user_info_and_login_box = UserInfoAndLoginBox(state_changed_cb=self.on_populate)
|
||||||
|
navigation = [
|
||||||
|
DesktopNavigationButton("News", "./news"),
|
||||||
|
Spacer(min_height=0.7),
|
||||||
|
DesktopNavigationButton(f"Über {lan_info.name} {lan_info.iteration}", "./overview"),
|
||||||
|
DesktopNavigationButton("Ticket kaufen", "./buy_ticket"),
|
||||||
|
DesktopNavigationButton("Sitzplan", "./seating"),
|
||||||
|
DesktopNavigationButton("Catering", "./catering"),
|
||||||
|
DesktopNavigationButton("Teilnehmer", "./guests"),
|
||||||
|
DesktopNavigationButton("Teams", "./teams"),
|
||||||
|
DesktopNavigationButton("Turniere", "./tournaments"),
|
||||||
|
DesktopNavigationButton("FAQ", "./faq"),
|
||||||
|
DesktopNavigationButton("Regeln & AGB", "./rules-gtc"),
|
||||||
|
Spacer(min_height=0.7),
|
||||||
|
DesktopNavigationButton("Discord", "https://discord.gg/8gTjg34yyH", open_new_tab=True),
|
||||||
|
DesktopNavigationButton("Die EZ GG e.V.", "https://ezgg-ev.de/about", open_new_tab=True),
|
||||||
|
Spacer(min_height=0.7)
|
||||||
|
]
|
||||||
|
|
||||||
|
if self.user is not None and self.user.is_team_member:
|
||||||
|
navigation.insert(0, DesktopNavigationButton("Adminbereich", "./admin", is_team_navigation=True))
|
||||||
|
|
||||||
|
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=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),
|
||||||
|
NavigationSponsorBox(img_name="crackz", url="https://www.crackz.gg/"),
|
||||||
|
align_y=0
|
||||||
|
),
|
||||||
|
color=self.session.theme.neutral_color,
|
||||||
|
min_width=15,
|
||||||
|
grow_y=True,
|
||||||
|
corner_radius=(0.5, 0, 0, 0),
|
||||||
|
margin_right=0.1
|
||||||
|
)
|
||||||
@@ -1,15 +1,17 @@
|
|||||||
from rio import Component, TextStyle, Color, TextInput, Button, Text, Rectangle, Column, Row, Spacer, \
|
import uuid
|
||||||
EventHandler
|
|
||||||
|
|
||||||
from src.ez_lan_manager.services.LocalDataService import LocalDataService, LocalData
|
from rio import Component, TextStyle, Color, TextInput, Button, Text, Rectangle, Column, Row, Spacer, \
|
||||||
from src.ez_lan_manager.services.UserService import UserService
|
EventHandler, Webview
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
|
||||||
from src.ez_lan_manager.types.User import User
|
from src.ezgg_lan_manager import RefreshService
|
||||||
|
from src.ezgg_lan_manager.services.LocalDataService import LocalDataService, LocalData
|
||||||
|
from src.ezgg_lan_manager.services.UserService import UserService
|
||||||
|
from src.ezgg_lan_manager.types.User import User
|
||||||
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
|
|
||||||
class LoginBox(Component):
|
class LoginBox(Component):
|
||||||
status_change_cb: EventHandler = None
|
status_change_cb: EventHandler = None
|
||||||
TEXT_STYLE = TextStyle(fill=Color.from_hex("02dac5"), font_size=0.9)
|
|
||||||
user_name_input_text: str = ""
|
user_name_input_text: str = ""
|
||||||
password_input_text: str = ""
|
password_input_text: str = ""
|
||||||
user_name_input_is_valid = True
|
user_name_input_is_valid = True
|
||||||
@@ -27,11 +29,13 @@ class LoginBox(Component):
|
|||||||
self.password_input_is_valid = True
|
self.password_input_is_valid = True
|
||||||
self.login_button_is_loading = False
|
self.login_button_is_loading = False
|
||||||
self.is_account_locked = False
|
self.is_account_locked = False
|
||||||
await self.session[SessionStorage].set_user_id_and_team_member_flag(user.user_id, user.is_team_member)
|
user_session = UserSession(id=uuid.uuid4(), user_id=user.user_id, is_team_member=user.is_team_member)
|
||||||
token = self.session[LocalDataService].set_session(self.session[SessionStorage])
|
self.session.attach(user_session)
|
||||||
|
token = self.session[LocalDataService].set_session(user_session)
|
||||||
self.session[LocalData].stored_session_token = token
|
self.session[LocalData].stored_session_token = token
|
||||||
self.session.attach(self.session[LocalData])
|
self.session.attach(self.session[LocalData])
|
||||||
self.status_change_cb()
|
await self.status_change_cb()
|
||||||
|
await self.session[RefreshService].trigger_refresh()
|
||||||
else:
|
else:
|
||||||
self.user_name_input_is_valid = False
|
self.user_name_input_is_valid = False
|
||||||
self.password_input_is_valid = False
|
self.password_input_is_valid = False
|
||||||
@@ -57,7 +61,7 @@ class LoginBox(Component):
|
|||||||
is_valid=self.password_input_is_valid
|
is_valid=self.password_input_is_valid
|
||||||
)
|
)
|
||||||
login_button = Button(
|
login_button = Button(
|
||||||
Text("LOGIN", style=self.TEXT_STYLE, justify="center"),
|
Text("LOGIN", fill=Color.from_hex("02dac5"), style=TextStyle(font_size=0.9), justify="center"),
|
||||||
shape="rectangle",
|
shape="rectangle",
|
||||||
style="minor",
|
style="minor",
|
||||||
color="secondary",
|
color="secondary",
|
||||||
@@ -65,14 +69,14 @@ class LoginBox(Component):
|
|||||||
on_press=self._on_login_pressed
|
on_press=self._on_login_pressed
|
||||||
)
|
)
|
||||||
register_button = Button(
|
register_button = Button(
|
||||||
Text("REG", style=self.TEXT_STYLE, justify="center"),
|
Text("REG", fill=Color.from_hex("02dac5"), style=TextStyle(font_size=0.9), justify="center"),
|
||||||
shape="rectangle",
|
shape="rectangle",
|
||||||
style="minor",
|
style="minor",
|
||||||
color="secondary",
|
color="secondary",
|
||||||
on_press=lambda: self.session.navigate_to("./register")
|
on_press=lambda: self.session.navigate_to("./register")
|
||||||
)
|
)
|
||||||
forgot_password_button = Button(
|
forgot_password_button = Button(
|
||||||
Text("LST PWD", style=self.TEXT_STYLE, justify="center"),
|
Text("LST PWD", fill=Color.from_hex("02dac5"), style=TextStyle(font_size=0.9), justify="center"),
|
||||||
shape="rectangle",
|
shape="rectangle",
|
||||||
style="minor",
|
style="minor",
|
||||||
color="secondary",
|
color="secondary",
|
||||||
@@ -95,7 +99,7 @@ class LoginBox(Component):
|
|||||||
),
|
),
|
||||||
margin_bottom=0.5
|
margin_bottom=0.5
|
||||||
),
|
),
|
||||||
Text(text="Dieses Konto\nist gesperrt", style=TextStyle(fill=self.session.theme.danger_color, font_size=0.9 if self.is_account_locked else 0), align_x=0.5),
|
Text(text="Dieses Konto\nist gesperrt", fill=self.session.theme.danger_color, style=TextStyle(font_size=0.9 if self.is_account_locked else 0), align_x=0.5),
|
||||||
spacing=0.4
|
spacing=0.4
|
||||||
),
|
),
|
||||||
fill=Color.TRANSPARENT,
|
fill=Color.TRANSPARENT,
|
||||||
@@ -103,5 +107,5 @@ class LoginBox(Component):
|
|||||||
min_width=12,
|
min_width=12,
|
||||||
align_x=0.5,
|
align_x=0.5,
|
||||||
margin_top=0.3,
|
margin_top=0.3,
|
||||||
margin_bottom=2
|
margin_bottom=1.5
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
from from_root import from_root
|
||||||
|
from rio import Component, Link, Rectangle, Image, Color
|
||||||
|
|
||||||
|
|
||||||
|
class NavigationSponsorBox(Component):
|
||||||
|
img_name: str
|
||||||
|
url: str
|
||||||
|
img_suffix: str = "png"
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
return Link(
|
||||||
|
content=Rectangle(
|
||||||
|
content=Image(image=from_root(f"src/ezgg_lan_manager/assets/img/{self.img_name}.{self.img_suffix}"), min_width=10, min_height=10),
|
||||||
|
stroke_width=0.1,
|
||||||
|
stroke_color=Color.TRANSPARENT,
|
||||||
|
hover_stroke_width=0.1,
|
||||||
|
hover_stroke_color=self.session.theme.secondary_color,
|
||||||
|
margin=0.6,
|
||||||
|
cursor="pointer"
|
||||||
|
),
|
||||||
|
target_url=self.url,
|
||||||
|
open_in_new_tab=True
|
||||||
|
)
|
||||||
@@ -4,8 +4,8 @@ from typing import Optional
|
|||||||
|
|
||||||
from rio import Component, Column, NumberInput, ThemeContextSwitcher, TextInput, Row, Button, EventHandler
|
from rio import Component, Column, NumberInput, ThemeContextSwitcher, TextInput, Row, Button, EventHandler
|
||||||
|
|
||||||
from src.ez_lan_manager.types.Transaction import Transaction
|
from src.ezgg_lan_manager.types.Transaction import Transaction
|
||||||
from src.ez_lan_manager.types.User import User
|
from src.ezgg_lan_manager.types.User import User
|
||||||
|
|
||||||
|
|
||||||
class NewTransactionForm(Component):
|
class NewTransactionForm(Component):
|
||||||
@@ -46,7 +46,6 @@ class NewTransactionForm(Component):
|
|||||||
label="Betrag",
|
label="Betrag",
|
||||||
suffix_text="€",
|
suffix_text="€",
|
||||||
decimals=2,
|
decimals=2,
|
||||||
thousands_separator=".",
|
|
||||||
margin=1,
|
margin=1,
|
||||||
margin_bottom=0
|
margin_bottom=0
|
||||||
),
|
),
|
||||||
@@ -21,8 +21,8 @@ class NewsPost(Component):
|
|||||||
grow_x=True,
|
grow_x=True,
|
||||||
margin=2,
|
margin=2,
|
||||||
margin_bottom=0,
|
margin_bottom=0,
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
style=TextStyle(
|
style=TextStyle(
|
||||||
fill=self.session.theme.background_color,
|
|
||||||
font_size=1.3
|
font_size=1.3
|
||||||
),
|
),
|
||||||
overflow="ellipsize"
|
overflow="ellipsize"
|
||||||
@@ -31,8 +31,8 @@ class NewsPost(Component):
|
|||||||
self.date,
|
self.date,
|
||||||
margin=2,
|
margin=2,
|
||||||
align_x=1,
|
align_x=1,
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
style=TextStyle(
|
style=TextStyle(
|
||||||
fill=self.session.theme.background_color,
|
|
||||||
font_size=0.6
|
font_size=0.6
|
||||||
),
|
),
|
||||||
overflow="wrap"
|
overflow="wrap"
|
||||||
@@ -44,8 +44,8 @@ class NewsPost(Component):
|
|||||||
margin=2,
|
margin=2,
|
||||||
margin_top=0,
|
margin_top=0,
|
||||||
margin_bottom=0,
|
margin_bottom=0,
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
style=TextStyle(
|
style=TextStyle(
|
||||||
fill=self.session.theme.background_color,
|
|
||||||
font_size=0.8
|
font_size=0.8
|
||||||
),
|
),
|
||||||
overflow="ellipsize"
|
overflow="ellipsize"
|
||||||
@@ -53,9 +53,7 @@ class NewsPost(Component):
|
|||||||
Text(
|
Text(
|
||||||
self.text,
|
self.text,
|
||||||
margin=2,
|
margin=2,
|
||||||
style=TextStyle(
|
fill=self.session.theme.background_color,
|
||||||
fill=self.session.theme.background_color
|
|
||||||
),
|
|
||||||
overflow="wrap"
|
overflow="wrap"
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
@@ -65,8 +63,8 @@ class NewsPost(Component):
|
|||||||
margin=2,
|
margin=2,
|
||||||
margin_top=0,
|
margin_top=0,
|
||||||
margin_bottom=1,
|
margin_bottom=1,
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
style=TextStyle(
|
style=TextStyle(
|
||||||
fill=self.session.theme.background_color,
|
|
||||||
font_size=0.5,
|
font_size=0.5,
|
||||||
italic=True
|
italic=True
|
||||||
),
|
),
|
||||||
@@ -0,0 +1,274 @@
|
|||||||
|
from typing import Callable
|
||||||
|
|
||||||
|
from rio import Component, Rectangle, Grid, Column, Row, Text, TextStyle, Color, PointerEventListener, Spacer
|
||||||
|
|
||||||
|
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 = 60
|
||||||
|
MAX_GRID_HEIGHT_PIXELS = 60
|
||||||
|
|
||||||
|
class SeatingPlanLegend(Component):
|
||||||
|
def build(self) -> Component:
|
||||||
|
return Column(
|
||||||
|
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,
|
||||||
|
stroke_width=0.2,
|
||||||
|
stroke_color=Color.from_hex("66ff99"),
|
||||||
|
min_width=20
|
||||||
|
),
|
||||||
|
Spacer()
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
Rectangle(
|
||||||
|
content=Column(
|
||||||
|
Text(f"Freier Platz", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False),
|
||||||
|
Text(f"", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5,
|
||||||
|
selectable=False, overflow="wrap")
|
||||||
|
),
|
||||||
|
min_width=1,
|
||||||
|
min_height=1,
|
||||||
|
fill=self.session.theme.success_color,
|
||||||
|
grow_x=False,
|
||||||
|
grow_y=False,
|
||||||
|
hover_fill=self.session.theme.success_color,
|
||||||
|
transition_time=0.4,
|
||||||
|
ripple=True
|
||||||
|
),
|
||||||
|
Rectangle(
|
||||||
|
content=Column(
|
||||||
|
Text(f"Belegter Platz", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False),
|
||||||
|
Text(f"", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5,
|
||||||
|
selectable=False, overflow="wrap")
|
||||||
|
),
|
||||||
|
min_width=1,
|
||||||
|
min_height=1,
|
||||||
|
fill=self.session.theme.danger_color,
|
||||||
|
grow_x=False,
|
||||||
|
grow_y=False,
|
||||||
|
hover_fill=self.session.theme.danger_color,
|
||||||
|
transition_time=0.4,
|
||||||
|
ripple=True
|
||||||
|
),
|
||||||
|
Rectangle(
|
||||||
|
content=Column(
|
||||||
|
Text(f"Eigener Platz", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False),
|
||||||
|
Text(f"", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5,
|
||||||
|
selectable=False, overflow="wrap")
|
||||||
|
),
|
||||||
|
min_width=1,
|
||||||
|
min_height=1,
|
||||||
|
fill=Color.from_hex("800080"),
|
||||||
|
grow_x=False,
|
||||||
|
grow_y=False,
|
||||||
|
hover_fill=Color.from_hex("800080"),
|
||||||
|
transition_time=0.4,
|
||||||
|
ripple=True
|
||||||
|
),
|
||||||
|
margin=1,
|
||||||
|
spacing=1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class SeatingPlan(Component):
|
||||||
|
seat_clicked_cb: Callable
|
||||||
|
seating_info: list[Seat]
|
||||||
|
info_clicked_cb: Callable
|
||||||
|
|
||||||
|
def get_seat(self, seat_id: str) -> Seat:
|
||||||
|
seat = next(filter(lambda seat_: seat_.seat_id == seat_id, self.seating_info), None)
|
||||||
|
return seat if seat else Seat(seat_id="Z99", is_blocked=True, category="LUXUS", user=None)
|
||||||
|
|
||||||
|
"""
|
||||||
|
This seating plan is for the community center "Donsbach"
|
||||||
|
"""
|
||||||
|
def build(self) -> Component:
|
||||||
|
grid = Grid()
|
||||||
|
# Outlines
|
||||||
|
for x in range(0, MAX_GRID_WIDTH_PIXELS):
|
||||||
|
grid.add(WallPixel(), row=0, column=x)
|
||||||
|
|
||||||
|
for y in range(0, MAX_GRID_HEIGHT_PIXELS):
|
||||||
|
grid.add(WallPixel(), row=y, column=0)
|
||||||
|
|
||||||
|
for x in range(0, MAX_GRID_WIDTH_PIXELS):
|
||||||
|
grid.add(WallPixel(), row=MAX_GRID_HEIGHT_PIXELS, column=x)
|
||||||
|
|
||||||
|
for x in range(0, 31):
|
||||||
|
grid.add(WallPixel(), row=15, column=x)
|
||||||
|
|
||||||
|
for x in range(41, MAX_GRID_WIDTH_PIXELS):
|
||||||
|
grid.add(WallPixel(), row=32, 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 y in range(40, MAX_GRID_HEIGHT_PIXELS):
|
||||||
|
grid.add(WallPixel(), row=y, column=30)
|
||||||
|
|
||||||
|
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="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)
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
# 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("Damen Toilette")
|
||||||
|
), row=1, column=42, width=19, height=10)
|
||||||
|
grid.add(PointerEventListener(
|
||||||
|
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="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)
|
||||||
|
|
||||||
|
|
||||||
|
return Rectangle(
|
||||||
|
content=grid,
|
||||||
|
grow_x=True,
|
||||||
|
grow_y=True,
|
||||||
|
stroke_color=self.session.theme.neutral_color,
|
||||||
|
stroke_width=0.1,
|
||||||
|
fill=self.session.theme.primary_color,
|
||||||
|
margin=0.5
|
||||||
|
)
|
||||||
|
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import Optional, Callable
|
from typing import Optional, Callable
|
||||||
|
|
||||||
from rio import Component, Column, Text, TextStyle, Button, Spacer
|
from rio import Component, Column, Text, TextStyle, Button, Spacer, event
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager import TicketingService
|
||||||
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
|
|
||||||
class SeatingPlanInfoBox(Component):
|
class SeatingPlanInfoBox(Component):
|
||||||
@@ -12,8 +15,38 @@ class SeatingPlanInfoBox(Component):
|
|||||||
seat_occupant: Optional[str] = None
|
seat_occupant: Optional[str] = None
|
||||||
seat_price: Decimal = Decimal("0")
|
seat_price: Decimal = Decimal("0")
|
||||||
is_blocked: bool = False
|
is_blocked: bool = False
|
||||||
|
has_user_ticket: bool = False
|
||||||
|
booking_button_text: str = ""
|
||||||
|
override_text: str = "" # If this is set, all other functionality is disabled and the text is shown
|
||||||
|
|
||||||
|
@event.on_populate
|
||||||
|
async def check_ticket(self) -> None:
|
||||||
|
try:
|
||||||
|
user_id = self.session[UserSession].user_id
|
||||||
|
user_ticket = await self.session[TicketingService].get_user_ticket(user_id)
|
||||||
|
self.has_user_ticket = not (user_ticket is None)
|
||||||
|
self.booking_button_text = "Buchen" if self.has_user_ticket else "Ticket kaufen"
|
||||||
|
self.force_refresh()
|
||||||
|
except KeyError:
|
||||||
|
return
|
||||||
|
|
||||||
|
async def purchase_clicked(self):
|
||||||
|
if self.has_user_ticket:
|
||||||
|
await self.purchase_cb()
|
||||||
|
else:
|
||||||
|
self.session.navigate_to("./buy_ticket")
|
||||||
|
|
||||||
def build(self) -> Component:
|
def build(self) -> Component:
|
||||||
|
try:
|
||||||
|
user_id = self.session[UserSession].user_id
|
||||||
|
except KeyError:
|
||||||
|
user_id = None
|
||||||
|
|
||||||
|
if self.override_text:
|
||||||
|
return Column(Text(self.override_text, margin=1,
|
||||||
|
style=TextStyle(fill=self.session.theme.neutral_color, font_size=1.4), overflow="wrap",
|
||||||
|
justify="center"), min_height=10)
|
||||||
|
|
||||||
if not self.show:
|
if not self.show:
|
||||||
return Spacer()
|
return Spacer()
|
||||||
if self.is_blocked:
|
if self.is_blocked:
|
||||||
@@ -36,7 +69,7 @@ class SeatingPlanInfoBox(Component):
|
|||||||
style=TextStyle(fill=self.session.theme.neutral_color), overflow="wrap", justify="center"),
|
style=TextStyle(fill=self.session.theme.neutral_color), overflow="wrap", justify="center"),
|
||||||
Button(
|
Button(
|
||||||
Text(
|
Text(
|
||||||
f"Buchen",
|
text=self.booking_button_text,
|
||||||
margin=1,
|
margin=1,
|
||||||
style=TextStyle(fill=self.session.theme.neutral_color, font_size=1.1),
|
style=TextStyle(fill=self.session.theme.neutral_color, font_size=1.1),
|
||||||
overflow="wrap",
|
overflow="wrap",
|
||||||
@@ -48,7 +81,10 @@ class SeatingPlanInfoBox(Component):
|
|||||||
margin=1,
|
margin=1,
|
||||||
grow_y=False,
|
grow_y=False,
|
||||||
is_sensitive=not self.is_booking_blocked,
|
is_sensitive=not self.is_booking_blocked,
|
||||||
on_press=self.purchase_cb
|
on_press=self.purchase_clicked
|
||||||
),
|
) if user_id is not None else Text(f"Du musst eingeloggt sein um einen Sitzplatz zu buchen",
|
||||||
|
margin=1,
|
||||||
|
style=TextStyle(fill=self.session.theme.neutral_color),
|
||||||
|
overflow="wrap", justify="center"),
|
||||||
min_height=10
|
min_height=10
|
||||||
)
|
)
|
||||||
@@ -1,44 +1,62 @@
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from rio import Component, Text, Icon, TextStyle, Rectangle, Spacer, Color, PointerEventListener, Column
|
from rio import Component, Text, Icon, TextStyle, Rectangle, Spacer, Color, PointerEventListener, Column, Row, PointerEvent, Tooltip
|
||||||
from typing import Optional, Callable
|
from typing import Optional, Callable, Literal
|
||||||
|
|
||||||
from src.ez_lan_manager.types.Seat import Seat
|
from src.ezgg_lan_manager.types.Seat import Seat
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
|
|
||||||
class SeatPixel(Component):
|
class SeatPixel(Component):
|
||||||
seat_id: str
|
seat_id: str
|
||||||
on_press_cb: Callable
|
on_press_cb: Callable
|
||||||
seat: Seat
|
seat: Seat
|
||||||
|
seat_orientation: Literal["top", "bottom"]
|
||||||
|
|
||||||
def determine_color(self) -> Color:
|
def determine_color(self) -> Color:
|
||||||
if self.seat.user is not None and self.seat.user.user_id == self.session[SessionStorage].user_id:
|
try:
|
||||||
|
user_id = self.session[UserSession].user_id
|
||||||
|
except KeyError:
|
||||||
|
user_id = None
|
||||||
|
if self.seat.user is not None and self.seat.user.user_id == user_id:
|
||||||
return Color.from_hex("800080")
|
return Color.from_hex("800080")
|
||||||
elif self.seat.is_blocked or self.seat.user is not None:
|
elif self.seat.is_blocked or self.seat.user is not None:
|
||||||
return self.session.theme.danger_color
|
return self.session.theme.danger_color
|
||||||
return self.session.theme.success_color
|
return self.session.theme.success_color
|
||||||
|
|
||||||
def build(self) -> Component:
|
def build(self) -> Component:
|
||||||
return PointerEventListener(
|
text = Text(f"{self.seat_id}", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5, selectable=False)
|
||||||
content=Rectangle(
|
rec = Rectangle(
|
||||||
content=Column(
|
content=Row(text),
|
||||||
Text(f"{self.seat_id}", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False),
|
min_width=1,
|
||||||
Text(f"{self.seat.category[0]}", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5, selectable=False, overflow="wrap")
|
min_height=1,
|
||||||
),
|
fill=self.determine_color(),
|
||||||
min_width=1,
|
stroke_width=0.1,
|
||||||
min_height=1,
|
hover_stroke_width=0.1,
|
||||||
fill=self.determine_color(),
|
stroke_color=Color.from_hex("003300") if self.seat.category == "NORMAL" else Color.from_hex("66ff99"),
|
||||||
hover_stroke_width = 0.1,
|
grow_x=True,
|
||||||
grow_x=True,
|
grow_y=True,
|
||||||
grow_y=True,
|
hover_fill=self.session.theme.hud_color,
|
||||||
hover_fill=self.session.theme.hud_color,
|
transition_time=0.4,
|
||||||
transition_time=0.4,
|
ripple=True
|
||||||
ripple=True
|
|
||||||
),
|
|
||||||
on_press=partial(self.on_press_cb, self.seat_id)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if self.seat.user or self.seat.is_blocked:
|
||||||
|
return PointerEventListener(
|
||||||
|
content=Tooltip(
|
||||||
|
anchor=rec,
|
||||||
|
tip=self.seat.user.user_name if self.seat.user else "Gesperrt",
|
||||||
|
position=self.seat_orientation,
|
||||||
|
),
|
||||||
|
on_press=partial(self.on_press_cb, self.seat_id),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return PointerEventListener(
|
||||||
|
content=rec,
|
||||||
|
on_press=partial(self.on_press_cb, self.seat_id),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TextPixel(Component):
|
class TextPixel(Component):
|
||||||
text: Optional[str] = None
|
text: Optional[str] = None
|
||||||
icon_name: Optional[str] = None
|
icon_name: Optional[str] = None
|
||||||
@@ -58,13 +76,14 @@ class TextPixel(Component):
|
|||||||
fill=self.session.theme.primary_color,
|
fill=self.session.theme.primary_color,
|
||||||
stroke_width=0.0 if self.no_outline else 0.1,
|
stroke_width=0.0 if self.no_outline else 0.1,
|
||||||
stroke_color=self.session.theme.neutral_color,
|
stroke_color=self.session.theme.neutral_color,
|
||||||
hover_stroke_width = None if self.no_outline else 0.1,
|
hover_stroke_width=None if self.no_outline else 0.1,
|
||||||
grow_x=True,
|
grow_x=True,
|
||||||
grow_y=True,
|
grow_y=True,
|
||||||
hover_fill=None,
|
hover_fill=None,
|
||||||
ripple=True
|
ripple=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class WallPixel(Component):
|
class WallPixel(Component):
|
||||||
def build(self) -> Component:
|
def build(self) -> Component:
|
||||||
return Rectangle(
|
return Rectangle(
|
||||||
@@ -75,6 +94,7 @@ class WallPixel(Component):
|
|||||||
grow_y=True,
|
grow_y=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class DebugPixel(Component):
|
class DebugPixel(Component):
|
||||||
def build(self) -> Component:
|
def build(self) -> Component:
|
||||||
return Rectangle(
|
return Rectangle(
|
||||||
@@ -82,14 +102,15 @@ class DebugPixel(Component):
|
|||||||
min_width=1,
|
min_width=1,
|
||||||
min_height=1,
|
min_height=1,
|
||||||
fill=self.session.theme.success_color,
|
fill=self.session.theme.success_color,
|
||||||
hover_stroke_color = self.session.theme.hud_color,
|
hover_stroke_color=self.session.theme.hud_color,
|
||||||
hover_stroke_width = 0.1,
|
hover_stroke_width=0.1,
|
||||||
grow_x=True,
|
grow_x=True,
|
||||||
grow_y=True,
|
grow_y=True,
|
||||||
hover_fill=self.session.theme.secondary_color,
|
hover_fill=self.session.theme.secondary_color,
|
||||||
transition_time=0.1
|
transition_time=0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class InvisiblePixel(Component):
|
class InvisiblePixel(Component):
|
||||||
def build(self) -> Component:
|
def build(self) -> Component:
|
||||||
return Rectangle(
|
return Rectangle(
|
||||||
@@ -100,4 +121,4 @@ class InvisiblePixel(Component):
|
|||||||
hover_stroke_width=0.0,
|
hover_stroke_width=0.0,
|
||||||
grow_x=True,
|
grow_x=True,
|
||||||
grow_y=True
|
grow_y=True
|
||||||
)
|
)
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
from asyncio import sleep, create_task
|
from asyncio import sleep, create_task
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
import rio
|
from rio import Component, Column, Text, TextStyle, Button, Row, ScrollContainer, Spacer, Popup, Table, event, Card
|
||||||
from rio import Component, Column, Text, TextStyle, Button, Row, ScrollContainer, Spacer, Popup, Table
|
|
||||||
|
|
||||||
from src.ez_lan_manager.components.CateringCartItem import CateringCartItem
|
from src.ezgg_lan_manager.components.CateringCartItem import CateringCartItem
|
||||||
from src.ez_lan_manager.components.CateringOrderItem import CateringOrderItem
|
from src.ezgg_lan_manager.components.CateringOrderItem import CateringOrderItem
|
||||||
from src.ez_lan_manager.services.AccountingService import AccountingService
|
from src.ezgg_lan_manager.services.AccountingService import AccountingService
|
||||||
from src.ez_lan_manager.services.CateringService import CateringService, CateringError, CateringErrorType
|
from src.ezgg_lan_manager.services.CateringService import CateringService, CateringError, CateringErrorType
|
||||||
from src.ez_lan_manager.types.CateringOrder import CateringOrder, CateringMenuItemsWithAmount
|
from src.ezgg_lan_manager.types.CateringOrder import CateringOrder, CateringMenuItemsWithAmount
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
POPUP_CLOSE_TIMEOUT_SECONDS = 3
|
POPUP_CLOSE_TIMEOUT_SECONDS = 3
|
||||||
|
|
||||||
@@ -21,13 +21,23 @@ class ShoppingCartAndOrders(Component):
|
|||||||
popup_is_shown: bool = False
|
popup_is_shown: bool = False
|
||||||
popup_is_error: bool = True
|
popup_is_error: bool = True
|
||||||
|
|
||||||
|
@event.periodic(5)
|
||||||
|
async def periodic_refresh_of_orders(self) -> None:
|
||||||
|
user_id = self._get_user_id()
|
||||||
|
if not self.show_cart and not self.popup_is_shown and user_id is not None:
|
||||||
|
self.orders = await self.session[CateringService].get_orders_for_user(user_id)
|
||||||
|
|
||||||
async def switch(self) -> None:
|
async def switch(self) -> None:
|
||||||
self.show_cart = not self.show_cart
|
self.show_cart = not self.show_cart
|
||||||
self.orders = await self.session[CateringService].get_orders_for_user(self.session[SessionStorage].user_id)
|
user_id = self._get_user_id()
|
||||||
|
if user_id is not None:
|
||||||
|
self.orders = await self.session[CateringService].get_orders_for_user(user_id)
|
||||||
|
|
||||||
async def on_remove_item(self, list_id: int) -> None:
|
async def on_remove_item(self, list_id: int) -> None:
|
||||||
catering_service = self.session[CateringService]
|
catering_service = self.session[CateringService]
|
||||||
user_id = self.session[SessionStorage].user_id
|
user_id = self._get_user_id()
|
||||||
|
if user_id is None:
|
||||||
|
return
|
||||||
cart = catering_service.get_cart(user_id)
|
cart = catering_service.get_cart(user_id)
|
||||||
try:
|
try:
|
||||||
cart.pop(list_id)
|
cart.pop(list_id)
|
||||||
@@ -37,13 +47,16 @@ class ShoppingCartAndOrders(Component):
|
|||||||
self.force_refresh()
|
self.force_refresh()
|
||||||
|
|
||||||
async def on_empty_cart_pressed(self) -> None:
|
async def on_empty_cart_pressed(self) -> None:
|
||||||
self.session[CateringService].save_cart(self.session[SessionStorage].user_id, [])
|
user_id = self._get_user_id()
|
||||||
|
if user_id is None:
|
||||||
|
return
|
||||||
|
self.session[CateringService].save_cart(user_id, [])
|
||||||
self.force_refresh()
|
self.force_refresh()
|
||||||
|
|
||||||
async def on_add_item(self, article_id: int) -> None:
|
async def on_add_item(self, article_id: int) -> None:
|
||||||
catering_service = self.session[CateringService]
|
catering_service = self.session[CateringService]
|
||||||
user_id = self.session[SessionStorage].user_id
|
user_id = self._get_user_id()
|
||||||
if not user_id:
|
if user_id is None:
|
||||||
return
|
return
|
||||||
cart = catering_service.get_cart(user_id)
|
cart = catering_service.get_cart(user_id)
|
||||||
item_to_add = await catering_service.get_menu_item_by_id(article_id)
|
item_to_add = await catering_service.get_menu_item_by_id(article_id)
|
||||||
@@ -64,7 +77,9 @@ class ShoppingCartAndOrders(Component):
|
|||||||
self.order_button_loading = True
|
self.order_button_loading = True
|
||||||
self.force_refresh()
|
self.force_refresh()
|
||||||
|
|
||||||
user_id = self.session[SessionStorage].user_id
|
user_id = self._get_user_id()
|
||||||
|
if user_id is None:
|
||||||
|
return
|
||||||
cart = self.session[CateringService].get_cart(user_id)
|
cart = self.session[CateringService].get_cart(user_id)
|
||||||
show_popup_task = None
|
show_popup_task = None
|
||||||
if len(cart) < 1:
|
if len(cart) < 1:
|
||||||
@@ -85,13 +100,14 @@ class ShoppingCartAndOrders(Component):
|
|||||||
show_popup_task = create_task(self.show_popup("Guthaben nicht ausreichend", True))
|
show_popup_task = create_task(self.show_popup("Guthaben nicht ausreichend", True))
|
||||||
else:
|
else:
|
||||||
show_popup_task = create_task(self.show_popup("Unbekannter Fehler", True))
|
show_popup_task = create_task(self.show_popup("Unbekannter Fehler", True))
|
||||||
self.session[CateringService].save_cart(self.session[SessionStorage].user_id, [])
|
else:
|
||||||
|
self.session[CateringService].save_cart(user_id, [])
|
||||||
self.order_button_loading = False
|
self.order_button_loading = False
|
||||||
if not show_popup_task:
|
if not show_popup_task:
|
||||||
show_popup_task = create_task(self.show_popup("Bestellung erfolgreich aufgegeben!", False))
|
show_popup_task = create_task(self.show_popup("Bestellung erfolgreich aufgegeben!", False))
|
||||||
|
|
||||||
async def _create_order_info_modal(self, order: CateringOrder) -> None:
|
async def _create_order_info_modal(self, order: CateringOrder) -> None:
|
||||||
def build_dialog_content() -> rio.Component:
|
def build_dialog_content() -> Component:
|
||||||
# @todo: rio 0.10.8 did not have the ability to align the columns, check back in a future version
|
# @todo: rio 0.10.8 did not have the ability to align the columns, check back in a future version
|
||||||
table = Table(
|
table = Table(
|
||||||
{
|
{
|
||||||
@@ -101,9 +117,9 @@ class ShoppingCartAndOrders(Component):
|
|||||||
},
|
},
|
||||||
show_row_numbers=False
|
show_row_numbers=False
|
||||||
)
|
)
|
||||||
return rio.Card(
|
return Card(
|
||||||
rio.Column(
|
Column(
|
||||||
rio.Text(
|
Text(
|
||||||
f"Deine Bestellung ({order.order_id})",
|
f"Deine Bestellung ({order.order_id})",
|
||||||
align_x=0.5,
|
align_x=0.5,
|
||||||
margin_bottom=0.5
|
margin_bottom=0.5
|
||||||
@@ -124,14 +140,20 @@ class ShoppingCartAndOrders(Component):
|
|||||||
dialog = await self.session.show_custom_dialog(
|
dialog = await self.session.show_custom_dialog(
|
||||||
build=build_dialog_content,
|
build=build_dialog_content,
|
||||||
modal=True,
|
modal=True,
|
||||||
user_closeable=True,
|
user_closable=True,
|
||||||
)
|
)
|
||||||
await dialog.wait_for_close()
|
await dialog.wait_for_close()
|
||||||
|
|
||||||
def build(self) -> rio.Component:
|
def _get_user_id(self) -> Optional[int]:
|
||||||
user_id = self.session[SessionStorage].user_id
|
try:
|
||||||
|
return self.session[UserSession].user_id
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
user_id = self._get_user_id()
|
||||||
catering_service = self.session[CateringService]
|
catering_service = self.session[CateringService]
|
||||||
cart = catering_service.get_cart(user_id)
|
cart = catering_service.get_cart(user_id) if user_id is not None else []
|
||||||
if self.show_cart:
|
if self.show_cart:
|
||||||
cart_container = ScrollContainer(
|
cart_container = ScrollContainer(
|
||||||
content=Column(
|
content=Column(
|
||||||
@@ -149,7 +171,6 @@ class ShoppingCartAndOrders(Component):
|
|||||||
margin=1
|
margin=1
|
||||||
)
|
)
|
||||||
return Column(
|
return Column(
|
||||||
cart_container,
|
|
||||||
Popup(
|
Popup(
|
||||||
anchor=cart_container,
|
anchor=cart_container,
|
||||||
content=Text(self.popup_message, style=TextStyle(fill=self.session.theme.danger_color if self.popup_is_error else self.session.theme.success_color), overflow="wrap", margin=2, justify="center", min_width=20),
|
content=Text(self.popup_message, style=TextStyle(fill=self.session.theme.danger_color if self.popup_is_error else self.session.theme.success_color), overflow="wrap", margin=2, justify="center", min_width=20),
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
from functools import partial
|
||||||
|
from typing import Callable, Optional, Literal
|
||||||
|
|
||||||
|
from rio import Component, Revealer, TextStyle, Column, Row, Tooltip, Icon, Spacer, Text, Button
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager.types.Team import TeamStatus, Team
|
||||||
|
from src.ezgg_lan_manager.types.User import User
|
||||||
|
|
||||||
|
|
||||||
|
class TeamRevealer(Component):
|
||||||
|
user: Optional[User]
|
||||||
|
team: Team
|
||||||
|
mode: Literal["join", "leave", "display"]
|
||||||
|
on_button_pressed: Callable
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
return Revealer(
|
||||||
|
header=self.team.name,
|
||||||
|
header_style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1
|
||||||
|
),
|
||||||
|
content=Column(
|
||||||
|
*[Row(
|
||||||
|
Tooltip(
|
||||||
|
anchor=Icon("material/star" if self.team.members[member] == TeamStatus.LEADER else "material/stat_1", fill=self.session.theme.hud_color),
|
||||||
|
tip="Leiter" if self.team.members[member] == TeamStatus.LEADER else "Mitglied", position="top"),
|
||||||
|
Text(member.user_name, style=TextStyle(fill=self.session.theme.background_color, font_size=1), margin_left=0.5),
|
||||||
|
Spacer(grow_y=False))
|
||||||
|
for member in self.team.members
|
||||||
|
],
|
||||||
|
Row(Button(
|
||||||
|
content=f"{self.team.name} beitreten" if self.mode == "join" else f"{self.team.name} verlassen",
|
||||||
|
shape="rectangle",
|
||||||
|
style="major",
|
||||||
|
color="hud",
|
||||||
|
on_press=partial(self.on_button_pressed, self.team),
|
||||||
|
), margin_top=1, margin_bottom=1),
|
||||||
|
margin_right=1,
|
||||||
|
margin_left=1
|
||||||
|
),
|
||||||
|
margin_left=1,
|
||||||
|
margin_right=1,
|
||||||
|
)
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
import logging
|
||||||
|
from typing import Optional, Callable
|
||||||
|
|
||||||
|
from rio import Component, Text, Spacer, Rectangle, Column, TextStyle, Row, Button, TextInput, ThemeContextSwitcher
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager.services.TeamService import TeamService, NotMemberError, TeamLeadRemovalError, AlreadyMemberError, NameNotAllowedError, TeamNameTooLongError, \
|
||||||
|
TeamAbbrInvalidError, TeamNameAlreadyTaken
|
||||||
|
from src.ezgg_lan_manager.types.Team import Team
|
||||||
|
from src.ezgg_lan_manager.types.User import User
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__.split(".")[-1])
|
||||||
|
|
||||||
|
|
||||||
|
class ErrorBox(Component):
|
||||||
|
error_message: str
|
||||||
|
cancel: Callable
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
return Rectangle(
|
||||||
|
content=Column(
|
||||||
|
Text(self.error_message, style=TextStyle(fill=self.session.theme.background_color), margin_bottom=1.5),
|
||||||
|
Row(
|
||||||
|
Button(
|
||||||
|
content="Ok",
|
||||||
|
shape="rectangle",
|
||||||
|
style="major",
|
||||||
|
color="hud",
|
||||||
|
on_press=self.cancel,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
margin=1
|
||||||
|
),
|
||||||
|
fill=self.session.theme.primary_color
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TeamsDialogJoinHandler(Component):
|
||||||
|
is_active: bool
|
||||||
|
cancel: Callable
|
||||||
|
user: Optional[User] = None
|
||||||
|
team: Optional[Team] = None
|
||||||
|
error_message: Optional[str] = None
|
||||||
|
password: str = ""
|
||||||
|
|
||||||
|
async def join(self) -> None:
|
||||||
|
if self.user is None or self.team is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.password != self.team.join_password:
|
||||||
|
self.error_message = "Falsches Passwort!"
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
await self.session[TeamService].add_member_to_team(self.team, self.user)
|
||||||
|
except AlreadyMemberError:
|
||||||
|
self.error_message = "Du bist bereits Mitglied dieses Teams"
|
||||||
|
else:
|
||||||
|
await self.cancel_with_reset()
|
||||||
|
|
||||||
|
async def cancel_with_reset(self) -> None:
|
||||||
|
await self.cancel()
|
||||||
|
self.error_message = None
|
||||||
|
self.password = ""
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
if not self.is_active or self.user is None or self.team is None:
|
||||||
|
return Spacer()
|
||||||
|
|
||||||
|
if self.error_message is not None:
|
||||||
|
return ErrorBox(error_message=self.error_message, cancel=self.cancel_with_reset)
|
||||||
|
|
||||||
|
return Rectangle(
|
||||||
|
content=Column(
|
||||||
|
Text(f"Team {self.team.name} beitreten", style=TextStyle(fill=self.session.theme.background_color), margin_bottom=1, justify="center"),
|
||||||
|
ThemeContextSwitcher(content=TextInput(text=self.bind().password, label="Beitrittspasswort", margin_bottom=1), color="secondary"),
|
||||||
|
Row(
|
||||||
|
Button(
|
||||||
|
content="Abbrechen",
|
||||||
|
shape="rectangle",
|
||||||
|
style="major",
|
||||||
|
color=self.session.theme.danger_color,
|
||||||
|
on_press=self.cancel_with_reset,
|
||||||
|
),
|
||||||
|
Button(
|
||||||
|
content="Beitreten",
|
||||||
|
shape="rectangle",
|
||||||
|
style="major",
|
||||||
|
color=self.session.theme.success_color,
|
||||||
|
on_press=self.join,
|
||||||
|
),
|
||||||
|
spacing=1
|
||||||
|
),
|
||||||
|
margin=1
|
||||||
|
),
|
||||||
|
fill=self.session.theme.primary_color
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TeamsDialogLeaveHandler(Component):
|
||||||
|
is_active: bool
|
||||||
|
cancel: Callable
|
||||||
|
user: Optional[User] = None
|
||||||
|
team: Optional[Team] = None
|
||||||
|
error_message: Optional[str] = None
|
||||||
|
|
||||||
|
async def leave(self) -> None:
|
||||||
|
if self.user is not None and self.team is not None:
|
||||||
|
try:
|
||||||
|
await self.session[TeamService].remove_member_from_team(self.team, self.user)
|
||||||
|
except NotMemberError:
|
||||||
|
self.error_message = "Du bist kein Mitglied in diesem Team"
|
||||||
|
except TeamLeadRemovalError:
|
||||||
|
self.error_message = "Als Teamleiter kannst du das Team nicht verlassen"
|
||||||
|
else:
|
||||||
|
await self.cancel_with_reset()
|
||||||
|
|
||||||
|
async def cancel_with_reset(self) -> None:
|
||||||
|
await self.cancel()
|
||||||
|
self.error_message = None
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
if not self.is_active or self.user is None or self.team is None:
|
||||||
|
return Spacer()
|
||||||
|
|
||||||
|
if self.error_message is not None:
|
||||||
|
return ErrorBox(error_message=self.error_message, cancel=self.cancel_with_reset)
|
||||||
|
|
||||||
|
return Rectangle(
|
||||||
|
content=Column(
|
||||||
|
Text(f"Team {self.team.name} wirklich verlassen?", style=TextStyle(fill=self.session.theme.background_color), margin_bottom=1.5, justify="center"),
|
||||||
|
Row(
|
||||||
|
Button(
|
||||||
|
content="Nein",
|
||||||
|
shape="rectangle",
|
||||||
|
style="major",
|
||||||
|
color=self.session.theme.danger_color,
|
||||||
|
on_press=self.cancel_with_reset,
|
||||||
|
),
|
||||||
|
Button(
|
||||||
|
content="Ja",
|
||||||
|
shape="rectangle",
|
||||||
|
style="major",
|
||||||
|
color=self.session.theme.success_color,
|
||||||
|
on_press=self.leave,
|
||||||
|
),
|
||||||
|
spacing=1
|
||||||
|
),
|
||||||
|
margin=1
|
||||||
|
),
|
||||||
|
fill=self.session.theme.primary_color
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TeamsDialogCreateHandler(Component):
|
||||||
|
is_active: bool
|
||||||
|
cancel: Callable
|
||||||
|
user: Optional[User] = None
|
||||||
|
error_message: Optional[str] = None
|
||||||
|
team_name: str = ""
|
||||||
|
team_abbr: str = ""
|
||||||
|
team_join_password: str = ""
|
||||||
|
|
||||||
|
async def cancel_with_reset(self) -> None:
|
||||||
|
await self.cancel()
|
||||||
|
self.error_message = None
|
||||||
|
self.team_name, self.team_abbr, self.team_join_password = "", "", ""
|
||||||
|
|
||||||
|
async def create(self) -> None:
|
||||||
|
if self.user is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
if not self.team_name or not self.team_abbr or not self.team_join_password:
|
||||||
|
self.error_message = "Angaben unvollständig"
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
await self.session[TeamService].create_team(self.team_name, self.team_abbr, self.team_join_password, self.user)
|
||||||
|
except NameNotAllowedError as e:
|
||||||
|
self.error_message = f"Angaben ungültig. Darf kein '{e.disallowed_char}' enthalten."
|
||||||
|
except TeamNameTooLongError:
|
||||||
|
self.error_message = f"Name zu lang. Maximal {TeamService.MAX_TEAM_NAME_LENGTH} Zeichen."
|
||||||
|
except TeamAbbrInvalidError:
|
||||||
|
self.error_message = f"Name zu lang. Maximal {TeamService.MAX_TEAM_ABBR_LENGTH} Zeichen."
|
||||||
|
except TeamNameAlreadyTaken:
|
||||||
|
self.error_message = "Ein Team mit diesem Namen existiert bereits."
|
||||||
|
else:
|
||||||
|
await self.cancel_with_reset()
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
if not self.is_active or self.user is None:
|
||||||
|
return Spacer()
|
||||||
|
|
||||||
|
if self.error_message is not None:
|
||||||
|
return ErrorBox(error_message=self.error_message, cancel=self.cancel_with_reset)
|
||||||
|
|
||||||
|
return Rectangle(
|
||||||
|
content=Column(
|
||||||
|
Text(f"Team gründen", style=TextStyle(fill=self.session.theme.background_color), margin_bottom=1.5, justify="center"),
|
||||||
|
ThemeContextSwitcher(content=TextInput(text=self.bind().team_name, label="Team Name", margin_bottom=1), color="secondary"),
|
||||||
|
ThemeContextSwitcher(content=TextInput(text=self.bind().team_abbr, label="Team Abkürzung", margin_bottom=1), color="secondary"),
|
||||||
|
ThemeContextSwitcher(content=TextInput(text=self.bind().team_join_password, label="Beitrittspasswort", margin_bottom=1), color="secondary"),
|
||||||
|
Row(
|
||||||
|
Button(
|
||||||
|
content="Abbrechen",
|
||||||
|
shape="rectangle",
|
||||||
|
style="major",
|
||||||
|
color=self.session.theme.danger_color,
|
||||||
|
on_press=self.cancel_with_reset,
|
||||||
|
),
|
||||||
|
Button(
|
||||||
|
content="Gründen",
|
||||||
|
shape="rectangle",
|
||||||
|
style="major",
|
||||||
|
color=self.session.theme.success_color,
|
||||||
|
on_press=self.create,
|
||||||
|
),
|
||||||
|
spacing=1
|
||||||
|
),
|
||||||
|
margin=1
|
||||||
|
),
|
||||||
|
fill=self.session.theme.primary_color
|
||||||
|
)
|
||||||
@@ -2,12 +2,11 @@ from functools import partial
|
|||||||
from typing import Callable, Optional
|
from typing import Callable, Optional
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
import rio
|
|
||||||
from rio import Component, Card, Column, Text, Row, Button, TextStyle, ProgressBar, event, Spacer
|
from rio import Component, Card, Column, Text, Row, Button, TextStyle, ProgressBar, event, Spacer
|
||||||
|
|
||||||
from src.ez_lan_manager import TicketingService
|
from src.ezgg_lan_manager import TicketingService
|
||||||
from src.ez_lan_manager.services.AccountingService import AccountingService
|
from src.ezgg_lan_manager.services.AccountingService import AccountingService
|
||||||
from src.ez_lan_manager.types.Ticket import Ticket
|
from src.ezgg_lan_manager.types.Ticket import Ticket
|
||||||
|
|
||||||
|
|
||||||
class TicketBuyCard(Component):
|
class TicketBuyCard(Component):
|
||||||
@@ -22,10 +21,10 @@ class TicketBuyCard(Component):
|
|||||||
available_tickets: int = 0
|
available_tickets: int = 0
|
||||||
|
|
||||||
@event.on_populate
|
@event.on_populate
|
||||||
async def async_init(self) -> None:
|
async def on_populate(self) -> None:
|
||||||
self.available_tickets = await self.session[TicketingService].get_available_tickets_for_category(self.category)
|
self.available_tickets = await self.session[TicketingService].get_available_tickets_for_category(self.category)
|
||||||
|
|
||||||
def build(self) -> rio.Component:
|
def build(self) -> Component:
|
||||||
ticket_description_style = TextStyle(
|
ticket_description_style = TextStyle(
|
||||||
fill=self.session.theme.neutral_color,
|
fill=self.session.theme.neutral_color,
|
||||||
font_size=1.2,
|
font_size=1.2,
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from rio import Component, Row, Text, TextStyle, Color
|
||||||
|
|
||||||
|
|
||||||
|
class TournamentDetailsInfoRow(Component):
|
||||||
|
key: str
|
||||||
|
value: str
|
||||||
|
key_color: Optional[Color] = None
|
||||||
|
value_color: Optional[Color] = None
|
||||||
|
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
return Row(
|
||||||
|
Text(
|
||||||
|
text=self.key,
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.key_color if self.key_color is not None else self.session.theme.background_color,
|
||||||
|
font_size=1
|
||||||
|
),
|
||||||
|
margin_bottom=0.5,
|
||||||
|
align_x=0
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
text=self.value,
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.value_color if self.value_color is not None else self.session.theme.background_color,
|
||||||
|
font_size=1
|
||||||
|
),
|
||||||
|
margin_bottom=0.5,
|
||||||
|
align_x=1
|
||||||
|
),
|
||||||
|
margin_left=4,
|
||||||
|
margin_right=4
|
||||||
|
)
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
from typing import Literal, Callable
|
||||||
|
|
||||||
|
from rio import Component, PointerEventListener, Rectangle, Image, Text, Tooltip, TextStyle, Color, Icon, Row, PointerEvent
|
||||||
|
|
||||||
|
from from_root import from_root
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager.types.TournamentBase import TournamentStatus
|
||||||
|
|
||||||
|
|
||||||
|
class TournamentPageRow(Component):
|
||||||
|
tournament_id: int
|
||||||
|
tournament_name: str
|
||||||
|
game_image_name: str
|
||||||
|
current_participants: int
|
||||||
|
max_participants: int
|
||||||
|
tournament_status: TournamentStatus
|
||||||
|
clicked_cb: Callable
|
||||||
|
|
||||||
|
def handle_click(self, _: PointerEvent) -> None:
|
||||||
|
self.clicked_cb(self.tournament_id)
|
||||||
|
|
||||||
|
def determine_tournament_status_icon_color_and_text(self) -> tuple[str, Literal["success", "warning", "danger"], str]:
|
||||||
|
if self.tournament_status == TournamentStatus.OPEN:
|
||||||
|
return "material/lock_open", "success", "Anmeldung geöffnet"
|
||||||
|
elif self.tournament_status == TournamentStatus.CLOSED:
|
||||||
|
return "material/lock", "danger", "Anmeldung geschlossen"
|
||||||
|
elif self.tournament_status == TournamentStatus.ONGOING:
|
||||||
|
return "material/autoplay", "warning", "Turnier läuft"
|
||||||
|
elif self.tournament_status == TournamentStatus.COMPLETED:
|
||||||
|
return "material/check_circle", "success", "Turnier beendet"
|
||||||
|
elif self.tournament_status == TournamentStatus.CANCELED:
|
||||||
|
return "material/cancel", "danger", "Turnier abgesagt"
|
||||||
|
elif self.tournament_status == TournamentStatus.INVITE_ONLY:
|
||||||
|
return "material/person_cancel", "warning", "Teilnahme nur per Einladung"
|
||||||
|
else:
|
||||||
|
raise RuntimeError(f"Unknown tournament status: {str(self.tournament_status)}")
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
icon_name, color, text = self.determine_tournament_status_icon_color_and_text()
|
||||||
|
return PointerEventListener(
|
||||||
|
content=Rectangle(
|
||||||
|
content=Row(
|
||||||
|
Image(image=from_root(f"src/ezgg_lan_manager/assets/img/games/{self.game_image_name}")),
|
||||||
|
Text(self.tournament_name, style=TextStyle(fill=self.session.theme.background_color, font_size=1)),
|
||||||
|
Text(f"{self.current_participants}/{self.max_participants}", style=TextStyle(fill=self.session.theme.background_color, font_size=1), justify="right", margin_right=0.5),
|
||||||
|
Tooltip(anchor=Icon(icon_name, min_width=1, min_height=1, fill=color), position="top",
|
||||||
|
tip=Text(text, style=TextStyle(fill=self.session.theme.background_color, font_size=0.7))),
|
||||||
|
proportions=[1, 4, 1, 1],
|
||||||
|
margin=.5
|
||||||
|
),
|
||||||
|
fill=self.session.theme.hud_color,
|
||||||
|
margin=1,
|
||||||
|
margin_bottom=0,
|
||||||
|
stroke_color=Color.TRANSPARENT,
|
||||||
|
stroke_width=0.2,
|
||||||
|
hover_stroke_color=self.session.theme.background_color,
|
||||||
|
cursor="pointer"
|
||||||
|
),
|
||||||
|
on_press=self.handle_click
|
||||||
|
)
|
||||||
@@ -7,10 +7,10 @@ from from_root import from_root
|
|||||||
from rio import Component, Column, Button, Color, TextStyle, Text, TextInput, Row, Image, event, Spacer, DateInput, \
|
from rio import Component, Column, Button, Color, TextStyle, Text, TextInput, Row, Image, event, Spacer, DateInput, \
|
||||||
TextInputChangeEvent, NoFileSelectedError
|
TextInputChangeEvent, NoFileSelectedError
|
||||||
|
|
||||||
from src.ez_lan_manager.services.UserService import UserService, NameNotAllowedError
|
from src.ezgg_lan_manager.services.UserService import UserService, NameNotAllowedError
|
||||||
from src.ez_lan_manager.services.ConfigurationService import ConfigurationService
|
from src.ezgg_lan_manager.services.ConfigurationService import ConfigurationService
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
from src.ezgg_lan_manager.types.User import User
|
||||||
from src.ez_lan_manager.types.User import User
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
|
|
||||||
class UserEditForm(Component):
|
class UserEditForm(Component):
|
||||||
@@ -35,8 +35,13 @@ class UserEditForm(Component):
|
|||||||
async def on_populate(self) -> None:
|
async def on_populate(self) -> None:
|
||||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Profil bearbeiten")
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Profil bearbeiten")
|
||||||
if self.is_own_profile:
|
if self.is_own_profile:
|
||||||
self.user = await self.session[UserService].get_user(self.session[SessionStorage].user_id)
|
try:
|
||||||
self.profile_picture = await self.session[UserService].get_profile_picture(self.user.user_id)
|
user_id = self.session[UserSession].user_id
|
||||||
|
except KeyError:
|
||||||
|
self.session.navigate_to("/")
|
||||||
|
else:
|
||||||
|
self.user = await self.session[UserService].get_user(user_id)
|
||||||
|
self.profile_picture = await self.session[UserService].get_profile_picture(self.user.user_id)
|
||||||
else:
|
else:
|
||||||
self.profile_picture = await self.session[UserService].get_profile_picture(self.user.user_id)
|
self.profile_picture = await self.session[UserService].get_profile_picture(self.user.user_id)
|
||||||
|
|
||||||
@@ -122,7 +127,7 @@ class UserEditForm(Component):
|
|||||||
|
|
||||||
def build(self) -> Component:
|
def build(self) -> Component:
|
||||||
pfp_image_container = Image(
|
pfp_image_container = Image(
|
||||||
from_root("src/ez_lan_manager/assets/img/anon_pfp.png") if self.profile_picture is None else self.profile_picture,
|
from_root("src/ezgg_lan_manager/assets/img/anon_pfp.png") if self.profile_picture is None else self.profile_picture,
|
||||||
align_x=0.5,
|
align_x=0.5,
|
||||||
min_width=10,
|
min_width=10,
|
||||||
min_height=10,
|
min_height=10,
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import logging
|
||||||
|
from typing import Callable
|
||||||
|
|
||||||
|
from rio import Component
|
||||||
|
from src.ezgg_lan_manager.components.LoginBox import LoginBox
|
||||||
|
from src.ezgg_lan_manager.components.UserInfoBox import UserInfoBox
|
||||||
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__.split(".")[-1])
|
||||||
|
|
||||||
|
class UserInfoAndLoginBox(Component):
|
||||||
|
state_changed_cb: Callable
|
||||||
|
def build(self) -> Component:
|
||||||
|
try:
|
||||||
|
user_id = self.session[UserSession].user_id
|
||||||
|
return UserInfoBox(status_change_cb=self.state_changed_cb, user_id=user_id)
|
||||||
|
except KeyError:
|
||||||
|
return LoginBox(status_change_cb=self.state_changed_cb)
|
||||||
@@ -4,16 +4,17 @@ from decimal import Decimal
|
|||||||
|
|
||||||
from rio import Component, TextStyle, Color, Button, Text, Rectangle, Column, Row, Spacer, Link, event, EventHandler
|
from rio import Component, TextStyle, Color, Button, Text, Rectangle, Column, Row, Spacer, Link, event, EventHandler
|
||||||
|
|
||||||
from src.ez_lan_manager.components.UserInfoBoxButton import UserInfoBoxButton
|
from src.ezgg_lan_manager.components.UserInfoBoxButton import UserInfoBoxButton
|
||||||
from src.ez_lan_manager.services.LocalDataService import LocalData, LocalDataService
|
from src.ezgg_lan_manager.services.LocalDataService import LocalData, LocalDataService
|
||||||
from src.ez_lan_manager.services.UserService import UserService
|
from src.ezgg_lan_manager.services.RefreshService import RefreshService
|
||||||
from src.ez_lan_manager.services.AccountingService import AccountingService
|
from src.ezgg_lan_manager.services.UserService import UserService
|
||||||
from src.ez_lan_manager.services.TicketingService import TicketingService
|
from src.ezgg_lan_manager.services.AccountingService import AccountingService
|
||||||
from src.ez_lan_manager.services.SeatingService import SeatingService
|
from src.ezgg_lan_manager.services.TicketingService import TicketingService
|
||||||
from src.ez_lan_manager.types.Seat import Seat
|
from src.ezgg_lan_manager.services.SeatingService import SeatingService
|
||||||
from src.ez_lan_manager.types.Ticket import Ticket
|
from src.ezgg_lan_manager.types.Seat import Seat
|
||||||
from src.ez_lan_manager.types.User import User
|
from src.ezgg_lan_manager.types.Ticket import Ticket
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
from src.ezgg_lan_manager.types.User import User
|
||||||
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
|
|
||||||
class StatusButton(Component):
|
class StatusButton(Component):
|
||||||
@@ -41,6 +42,7 @@ class StatusButton(Component):
|
|||||||
|
|
||||||
|
|
||||||
class UserInfoBox(Component):
|
class UserInfoBox(Component):
|
||||||
|
user_id: int
|
||||||
status_change_cb: EventHandler = None
|
status_change_cb: EventHandler = None
|
||||||
TEXT_STYLE = TextStyle(fill=Color.from_hex("02dac5"), font_size=0.9)
|
TEXT_STYLE = TextStyle(fill=Color.from_hex("02dac5"), font_size=0.9)
|
||||||
user: Optional[User] = None
|
user: Optional[User] = None
|
||||||
@@ -53,29 +55,26 @@ class UserInfoBox(Component):
|
|||||||
return choice(["Guten Tacho", "Tuten Gag", "Servus", "Moinjour", "Hallöchen", "Heyho", "Moinsen"])
|
return choice(["Guten Tacho", "Tuten Gag", "Servus", "Moinjour", "Hallöchen", "Heyho", "Moinsen"])
|
||||||
|
|
||||||
async def logout(self) -> None:
|
async def logout(self) -> None:
|
||||||
await self.session[SessionStorage].clear()
|
self.session.detach(UserSession)
|
||||||
self.user = None
|
self.user = None
|
||||||
self.session[LocalDataService].del_session(self.session[LocalData].stored_session_token)
|
self.session[LocalDataService].del_session(self.session[LocalData].stored_session_token)
|
||||||
self.session[LocalData].stored_session_token = None
|
self.session[LocalData].stored_session_token = None
|
||||||
self.session.attach(self.session[LocalData])
|
self.session.attach(self.session[LocalData])
|
||||||
self.status_change_cb()
|
await self.status_change_cb()
|
||||||
self.session.navigate_to("/")
|
await self.session[RefreshService].trigger_refresh()
|
||||||
|
|
||||||
@event.on_populate
|
@event.on_populate
|
||||||
async def async_init(self) -> None:
|
async def async_init(self) -> None:
|
||||||
if self.session[SessionStorage].user_id:
|
self.user = await self.session[UserService].get_user(self.user_id)
|
||||||
self.user = await self.session[UserService].get_user(self.session[SessionStorage].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)
|
|
||||||
self.session[AccountingService].add_update_hook(self.update)
|
|
||||||
|
|
||||||
async def update(self) -> None:
|
|
||||||
if not self.user:
|
|
||||||
self.user = await self.session[UserService].get_user(self.session[SessionStorage].user_id)
|
|
||||||
self.user_balance = await self.session[AccountingService].get_balance(self.user.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_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.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:
|
||||||
|
self.user_balance = await self.session[AccountingService].get_balance(self.user_id)
|
||||||
|
self.user_ticket = await self.session[TicketingService].get_user_ticket(self.user_id)
|
||||||
|
self.user_seat = await self.session[SeatingService].get_user_seat(self.user_id)
|
||||||
|
|
||||||
def build(self) -> Component:
|
def build(self) -> Component:
|
||||||
if not self.user:
|
if not self.user:
|
||||||
@@ -115,5 +114,5 @@ class UserInfoBox(Component):
|
|||||||
min_width=12,
|
min_width=12,
|
||||||
align_x=0.5,
|
align_x=0.5,
|
||||||
margin_top=0.3,
|
margin_top=0.3,
|
||||||
margin_bottom=2
|
margin_bottom=1.5
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from rio import URL, GuardEvent
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager.services.UserService import UserService
|
||||||
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
|
|
||||||
|
# Guards pages against access from users that are NOT logged in
|
||||||
|
def logged_in_guard(event: GuardEvent) -> Optional[URL]:
|
||||||
|
try:
|
||||||
|
_ = event.session[UserSession].user_id
|
||||||
|
return None
|
||||||
|
except KeyError:
|
||||||
|
return URL("./")
|
||||||
|
|
||||||
|
# Guards pages against access from users that ARE logged in
|
||||||
|
def not_logged_in_guard(event: GuardEvent) -> Optional[URL]:
|
||||||
|
try:
|
||||||
|
_ = event.session[UserSession].user_id
|
||||||
|
return URL("./")
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Guards pages against access from users that are NOT logged in and NOT team members
|
||||||
|
def team_guard(event: GuardEvent) -> Optional[URL]:
|
||||||
|
try:
|
||||||
|
user_id = event.session[UserSession].user_id
|
||||||
|
is_team_member = event.session[UserSession].is_team_member
|
||||||
|
if user_id and is_team_member:
|
||||||
|
return None
|
||||||
|
return URL("./")
|
||||||
|
except KeyError:
|
||||||
|
return URL("./")
|
||||||
@@ -5,9 +5,9 @@ from decimal import Decimal
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from src.ez_lan_manager import init_services
|
from src.ezgg_lan_manager import init_services
|
||||||
from src.ez_lan_manager.types.CateringMenuItem import CateringMenuItemCategory
|
from src.ezgg_lan_manager.types.CateringMenuItem import CateringMenuItemCategory
|
||||||
from src.ez_lan_manager.types.News import News
|
from src.ezgg_lan_manager.types.News import News
|
||||||
|
|
||||||
DEMO_USERS = [
|
DEMO_USERS = [
|
||||||
{"user_name": "manfred", "user_mail": "manfred@demomail.com", "password_clear_text": "manfred"}, # Gast
|
{"user_name": "manfred", "user_mail": "manfred@demomail.com", "password_clear_text": "manfred"}, # Gast
|
||||||
@@ -185,9 +185,9 @@ async def run() -> None:
|
|||||||
|
|
||||||
await news_service.add_news(News(
|
await news_service.add_news(News(
|
||||||
news_id=None,
|
news_id=None,
|
||||||
title="Der EZ LAN Manager",
|
title="Der EZGG LAN Manager",
|
||||||
subtitle="Eine Software des EZ GG e.V.",
|
subtitle="Eine Software des EZ GG e.V.",
|
||||||
content="Dies ist eine WIP-Version des EZ LAN Managers. Diese Software soll uns helfen in Zukunft die LAN "
|
content="Dies ist eine WIP-Version des EZGG LAN Managers. Diese Software soll uns helfen in Zukunft die LAN "
|
||||||
"Parties des EZ GG e.V.'s zu organisieren. Wer Fehler findet darf sie behalten. (Oder er meldet "
|
"Parties des EZ GG e.V.'s zu organisieren. Wer Fehler findet darf sie behalten. (Oder er meldet "
|
||||||
"sie)",
|
"sie)",
|
||||||
author=user,
|
author=user,
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
from functools import partial
|
from decimal import Decimal
|
||||||
from typing import Optional
|
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
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, UserService, AccountingService
|
from src.ezgg_lan_manager import ConfigurationService, UserService, AccountingService
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
from src.ezgg_lan_manager.types.Transaction import Transaction
|
||||||
from src.ez_lan_manager.types.Transaction import Transaction
|
from src.ezgg_lan_manager.types.User import User
|
||||||
from src.ez_lan_manager.types.User import User
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
|
|
||||||
class AccountPage(Component):
|
class AccountPage(Component):
|
||||||
user: Optional[User] = None
|
user: Optional[User] = None
|
||||||
balance: Optional[int] = None
|
balance: Optional[Decimal] = None
|
||||||
transaction_history: list[Transaction] = list()
|
transaction_history: list[Transaction] = list()
|
||||||
banking_info_revealer_open: bool = False
|
banking_info_revealer_open: bool = False
|
||||||
paypal_info_revealer_open: bool = False
|
paypal_info_revealer_open: bool = False
|
||||||
@@ -20,9 +20,14 @@ class AccountPage(Component):
|
|||||||
@event.on_populate
|
@event.on_populate
|
||||||
async def on_populate(self) -> None:
|
async def on_populate(self) -> None:
|
||||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Guthabenkonto")
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Guthabenkonto")
|
||||||
self.user = await self.session[UserService].get_user(self.session[SessionStorage].user_id)
|
try:
|
||||||
self.balance = await self.session[AccountingService].get_balance(self.user.user_id)
|
user_id = self.session[UserSession].user_id
|
||||||
self.transaction_history = await self.session[AccountingService].get_transaction_history(self.user.user_id)
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
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)
|
||||||
|
|
||||||
async def _on_banking_info_press(self) -> None:
|
async def _on_banking_info_press(self) -> None:
|
||||||
self.banking_info_revealer_open = not self.banking_info_revealer_open
|
self.banking_info_revealer_open = not self.banking_info_revealer_open
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
from rio import Column, Component, event, Text, TextStyle, Row
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager.components.AdminNavigationCard import AdminNavigationCard
|
||||||
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
from src.ezgg_lan_manager.services.ConfigurationService import ConfigurationService
|
||||||
|
|
||||||
|
|
||||||
|
class AdminNavigationPage(Component):
|
||||||
|
@event.on_populate
|
||||||
|
async def on_populate(self) -> None:
|
||||||
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Admin")
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
return Column(
|
||||||
|
MainViewContentBox(
|
||||||
|
Text(
|
||||||
|
text="Admin",
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1.2
|
||||||
|
),
|
||||||
|
margin_top=2,
|
||||||
|
margin_bottom=2,
|
||||||
|
align_x=0.5
|
||||||
|
)
|
||||||
|
),
|
||||||
|
MainViewContentBox(
|
||||||
|
Column(
|
||||||
|
Row(
|
||||||
|
AdminNavigationCard(icon_name="material/supervised_user_circle", display_text="Nutzer", target_url="manage-users"),
|
||||||
|
AdminNavigationCard(icon_name="material/fastfood", display_text="Catering", target_url="manage-catering"),
|
||||||
|
spacing=1
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
AdminNavigationCard(icon_name="material/text_ad", display_text="News", target_url="manage-news"),
|
||||||
|
AdminNavigationCard(icon_name="material/trophy", display_text="Turniere", target_url="manage-tournaments"),
|
||||||
|
spacing=1
|
||||||
|
),
|
||||||
|
margin=1,
|
||||||
|
spacing=1
|
||||||
|
)
|
||||||
|
),
|
||||||
|
align_y=0
|
||||||
|
)
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import * # type: ignore
|
||||||
|
|
||||||
|
from rio import Component, event, Spacer, Card, Container, Column, Row, TextStyle, Color, Text, PageView, Button, Link
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager import ConfigurationService, DatabaseService
|
||||||
|
from src.ezgg_lan_manager.components.DesktopNavigation import DesktopNavigation
|
||||||
|
|
||||||
|
class BasePage(Component):
|
||||||
|
color = "secondary"
|
||||||
|
corner_radius = (0, 0.5, 0, 0)
|
||||||
|
footer_size = 53.1
|
||||||
|
force_portrait_mode = False
|
||||||
|
|
||||||
|
@event.periodic(60)
|
||||||
|
async def check_db_conn(self) -> None:
|
||||||
|
is_healthy = await self.session[DatabaseService].is_healthy()
|
||||||
|
if not is_healthy:
|
||||||
|
self.session.navigate_to("./db-error")
|
||||||
|
|
||||||
|
@event.on_window_size_change
|
||||||
|
async def on_window_size_change(self):
|
||||||
|
self.force_refresh()
|
||||||
|
|
||||||
|
@event.on_page_change
|
||||||
|
def check_needed_size(self):
|
||||||
|
# ToDo: Low-Prio: Change layout, so the footer is always as wide as needed.
|
||||||
|
# This is a workaround, bc the seating page needs more width
|
||||||
|
if "/seating" in self.session.active_page_url.__str__():
|
||||||
|
self.footer_size = 78.2
|
||||||
|
else:
|
||||||
|
self.footer_size = 53.1
|
||||||
|
self.force_refresh()
|
||||||
|
|
||||||
|
def enforce_portrait_mode(self) -> None:
|
||||||
|
self.force_portrait_mode = True
|
||||||
|
self.force_refresh()
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
content = Card(
|
||||||
|
PageView(),
|
||||||
|
color="secondary",
|
||||||
|
min_width=38,
|
||||||
|
corner_radius=(0, 0.5, 0, 0)
|
||||||
|
)
|
||||||
|
if self.session.window_width > 28 or self.force_portrait_mode:
|
||||||
|
return Container(
|
||||||
|
content=Column(
|
||||||
|
Column(
|
||||||
|
Row(
|
||||||
|
Spacer(grow_x=True, grow_y=True),
|
||||||
|
DesktopNavigation(),
|
||||||
|
content,
|
||||||
|
Spacer(grow_x=True, grow_y=True),
|
||||||
|
grow_y=True
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
Spacer(grow_x=True, grow_y=False),
|
||||||
|
Card(
|
||||||
|
content=Row(
|
||||||
|
Text(f"EZGG LAN Manager Version {self.session[ConfigurationService].APP_VERSION} © EZ GG e.V.", fill=self.session.theme.primary_color, style=TextStyle(font_size=0.5)),
|
||||||
|
Text(f"-", fill=self.session.theme.primary_color, style=TextStyle(font_size=0.5), margin_left=0.5, margin_right=0.5),
|
||||||
|
Link(content=Text(f"Impressum & DSGVO", fill=self.session.theme.primary_color, style=TextStyle(font_size=0.5)), target_url="./imprint"),
|
||||||
|
Text(f"-", fill=self.session.theme.primary_color, style=TextStyle(font_size=0.5), margin_left=0.5, margin_right=0.5),
|
||||||
|
Link(content=Text(f"Kontakt", fill=self.session.theme.primary_color, style=TextStyle(font_size=0.5)), target_url="./contact"),
|
||||||
|
align_x=0.5,
|
||||||
|
align_y=0.5
|
||||||
|
),
|
||||||
|
color=self.session.theme.neutral_color,
|
||||||
|
corner_radius=(0, 0, 0.5, 0.5),
|
||||||
|
grow_x=False,
|
||||||
|
grow_y=False,
|
||||||
|
min_height=1.2,
|
||||||
|
min_width=self.footer_size,
|
||||||
|
margin_bottom=3
|
||||||
|
),
|
||||||
|
Spacer(grow_x=True, grow_y=False),
|
||||||
|
grow_y=False
|
||||||
|
),
|
||||||
|
margin_top=4
|
||||||
|
)
|
||||||
|
),
|
||||||
|
grow_x=True,
|
||||||
|
grow_y=True
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return Column(
|
||||||
|
Text(
|
||||||
|
"Wir empfehlen auf\nmobilen Endgeräten im\nQuerformat zu arbeiten.\n\nBitte drehe dein Gerät.",
|
||||||
|
fill=Color.from_hex("FFFFFF"),
|
||||||
|
align_x=0.5,
|
||||||
|
align_y=0.5,
|
||||||
|
style=TextStyle(font_size=0.8)
|
||||||
|
),
|
||||||
|
Button(
|
||||||
|
content=Text("Ohne drehen fortfahren", margin=0.2),
|
||||||
|
style="minor",
|
||||||
|
shape="rounded",
|
||||||
|
align_x=0.5,
|
||||||
|
align_y=0,
|
||||||
|
on_press=self.enforce_portrait_mode
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
@@ -2,14 +2,14 @@ from typing import Optional
|
|||||||
|
|
||||||
from rio import Text, Column, TextStyle, Component, event, Button, Popup
|
from rio import Text, Column, TextStyle, Component, event, Button, Popup
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, UserService, TicketingService
|
from src.ezgg_lan_manager import ConfigurationService, UserService, TicketingService, RefreshService
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
from src.ez_lan_manager.components.TicketBuyCard import TicketBuyCard
|
from src.ezgg_lan_manager.components.TicketBuyCard import TicketBuyCard
|
||||||
from src.ez_lan_manager.services.AccountingService import InsufficientFundsError
|
from src.ezgg_lan_manager.services.AccountingService import InsufficientFundsError
|
||||||
from src.ez_lan_manager.services.TicketingService import TicketNotAvailableError, UserAlreadyHasTicketError
|
from src.ezgg_lan_manager.services.TicketingService import TicketNotAvailableError, UserAlreadyHasTicketError
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
from src.ezgg_lan_manager.types.Ticket import Ticket
|
||||||
from src.ez_lan_manager.types.Ticket import Ticket
|
from src.ezgg_lan_manager.types.User import User
|
||||||
from src.ez_lan_manager.types.User import User
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
|
|
||||||
class BuyTicketPage(Component):
|
class BuyTicketPage(Component):
|
||||||
@@ -19,14 +19,24 @@ class BuyTicketPage(Component):
|
|||||||
popup_message: str = ""
|
popup_message: str = ""
|
||||||
is_popup_success: bool = False
|
is_popup_success: bool = False
|
||||||
is_buying_enabled: bool = False
|
is_buying_enabled: bool = False
|
||||||
|
is_user_logged_in: bool = False
|
||||||
|
|
||||||
@event.on_populate
|
@event.on_populate
|
||||||
async def on_populate(self) -> None:
|
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} - Ticket kaufen")
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Ticket kaufen")
|
||||||
self.user = await self.session[UserService].get_user(self.session[SessionStorage].user_id)
|
try:
|
||||||
|
user_id = self.session[UserSession].user_id
|
||||||
|
except KeyError:
|
||||||
|
self.user = None
|
||||||
|
else:
|
||||||
|
self.user = await self.session[UserService].get_user(user_id)
|
||||||
if self.user is None: # No user logged in
|
if self.user is None: # No user logged in
|
||||||
self.is_buying_enabled = False
|
self.is_buying_enabled = False
|
||||||
|
self.is_user_logged_in = False
|
||||||
|
self.user_ticket = None
|
||||||
else: # User is logged in
|
else: # User is logged in
|
||||||
|
self.is_user_logged_in = True
|
||||||
possible_ticket = await self.session[TicketingService].get_user_ticket(self.user.user_id)
|
possible_ticket = await self.session[TicketingService].get_user_ticket(self.user.user_id)
|
||||||
self.user_ticket = possible_ticket
|
self.user_ticket = possible_ticket
|
||||||
if possible_ticket is not None: # User already has a ticket
|
if possible_ticket is not None: # User already has a ticket
|
||||||
@@ -67,17 +77,29 @@ class BuyTicketPage(Component):
|
|||||||
|
|
||||||
def build(self) -> Component:
|
def build(self) -> Component:
|
||||||
ticket_infos = self.session[ConfigurationService].get_ticket_info()
|
ticket_infos = self.session[ConfigurationService].get_ticket_info()
|
||||||
header = Text(
|
header = Column(
|
||||||
"Tickets & Preise",
|
Text(
|
||||||
style=TextStyle(
|
"Tickets & Preise",
|
||||||
fill=self.session.theme.background_color,
|
style=TextStyle(
|
||||||
font_size=1.2
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1.2
|
||||||
|
),
|
||||||
|
margin_top=2,
|
||||||
|
align_x=0.5
|
||||||
),
|
),
|
||||||
margin_top=2,
|
spacing=0.2
|
||||||
margin_bottom=2,
|
|
||||||
align_x=0.5
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not self.is_user_logged_in:
|
||||||
|
header.add(Text(
|
||||||
|
"Du musst eingeloggt sein\num ein Ticket zu kaufen",
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=0.6
|
||||||
|
),
|
||||||
|
align_x=0.5
|
||||||
|
))
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
MainViewContentBox(
|
MainViewContentBox(
|
||||||
Column(
|
Column(
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
from typing import Optional, Callable
|
from typing import Optional
|
||||||
|
|
||||||
from rio import Column, Component, event, TextStyle, Text, Spacer, Revealer, SwitcherBar, SwitcherBarChangeEvent, ProgressCircle
|
from rio import Column, Component, event, TextStyle, Text, Spacer, Revealer, SwitcherBar, SwitcherBarChangeEvent, ProgressCircle
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, CateringService
|
from src.ezgg_lan_manager import ConfigurationService, CateringService
|
||||||
from src.ez_lan_manager.components.CateringSelectionItem import CateringSelectionItem
|
from src.ezgg_lan_manager.components.CateringSelectionItem import CateringSelectionItem
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
from src.ez_lan_manager.components.ShoppingCartAndOrders import ShoppingCartAndOrders
|
from src.ezgg_lan_manager.components.ShoppingCartAndOrders import ShoppingCartAndOrders
|
||||||
from src.ez_lan_manager.types.CateringMenuItem import CateringMenuItemCategory, CateringMenuItem
|
from src.ezgg_lan_manager.services.RefreshService import RefreshService
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
from src.ezgg_lan_manager.types.CateringMenuItem import CateringMenuItemCategory, CateringMenuItem
|
||||||
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
|
|
||||||
class CateringPage(Component):
|
class CateringPage(Component):
|
||||||
@@ -15,11 +16,9 @@ class CateringPage(Component):
|
|||||||
all_menu_items: Optional[list[CateringMenuItem]] = None
|
all_menu_items: Optional[list[CateringMenuItem]] = None
|
||||||
shopping_cart_and_orders: list[ShoppingCartAndOrders] = []
|
shopping_cart_and_orders: list[ShoppingCartAndOrders] = []
|
||||||
|
|
||||||
def __post_init__(self) -> None:
|
|
||||||
self.session[SessionStorage].subscribe_to_logged_in_or_out_event(self.__class__.__name__, self.on_user_logged_in_status_changed)
|
|
||||||
|
|
||||||
@event.on_populate
|
@event.on_populate
|
||||||
async def on_populate(self) -> None:
|
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")
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Catering")
|
||||||
self.all_menu_items = await self.session[CateringService].get_menu()
|
self.all_menu_items = await self.session[CateringService].get_menu()
|
||||||
|
|
||||||
@@ -34,7 +33,10 @@ class CateringPage(Component):
|
|||||||
return list(filter(lambda item: item.category == category, all_menu_items))
|
return list(filter(lambda item: item.category == category, all_menu_items))
|
||||||
|
|
||||||
def build(self) -> Component:
|
def build(self) -> Component:
|
||||||
user_id = self.session[SessionStorage].user_id
|
try:
|
||||||
|
user_id = self.session[UserSession].user_id
|
||||||
|
except KeyError:
|
||||||
|
user_id = None
|
||||||
if len(self.shopping_cart_and_orders) == 0:
|
if len(self.shopping_cart_and_orders) == 0:
|
||||||
self.shopping_cart_and_orders.append(ShoppingCartAndOrders())
|
self.shopping_cart_and_orders.append(ShoppingCartAndOrders())
|
||||||
if len(self.shopping_cart_and_orders) > 1:
|
if len(self.shopping_cart_and_orders) > 1:
|
||||||
@@ -3,94 +3,93 @@ from typing import Optional
|
|||||||
|
|
||||||
from rio import Text, Column, TextStyle, Component, event, TextInput, MultiLineTextInput, Row, Button
|
from rio import Text, Column, TextStyle, Component, event, TextInput, MultiLineTextInput, Row, Button
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, UserService, MailingService
|
from src.ezgg_lan_manager import ConfigurationService, UserService, MailingService
|
||||||
from src.ez_lan_manager.components.AnimatedText import AnimatedText
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.types.User import User
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
from src.ez_lan_manager.types.User import User
|
|
||||||
|
|
||||||
|
|
||||||
class ContactPage(Component):
|
class ContactPage(Component):
|
||||||
# Workaround: Can not reassign this value without rio triggering refresh
|
# Workaround: Can not reassign this value without rio triggering refresh
|
||||||
# Using list to bypass this behavior
|
# Using list to bypass this behavior
|
||||||
last_message_sent: list[datetime] = [datetime(day=1, month=1, year=2000)]
|
last_message_sent: list[datetime] = [datetime(day=1, month=1, year=2000)]
|
||||||
display_printing: list[bool] = [False]
|
|
||||||
user: Optional[User] = None
|
user: Optional[User] = None
|
||||||
|
|
||||||
|
e_mail: str = ""
|
||||||
|
subject: str = ""
|
||||||
|
message: str = ""
|
||||||
|
submit_button_is_loading: bool = False
|
||||||
|
response_message: str = ""
|
||||||
|
is_success: bool = True
|
||||||
|
|
||||||
@event.on_populate
|
@event.on_populate
|
||||||
async def on_populate(self) -> None:
|
async def on_populate(self) -> None:
|
||||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Kontakt")
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Kontakt")
|
||||||
if self.session[SessionStorage].user_id is not None:
|
try:
|
||||||
self.user = await self.session[UserService].get_user(self.session[SessionStorage].user_id)
|
self.user = await self.session[UserService].get_user(self.session[UserSession].user_id)
|
||||||
else:
|
except KeyError:
|
||||||
self.user = None
|
self.user = None
|
||||||
|
self.e_mail = "" if not self.user else self.user.user_mail
|
||||||
|
|
||||||
async def on_send_pressed(self) -> None:
|
async def on_send_pressed(self) -> None:
|
||||||
error_msg = ""
|
error_msg = ""
|
||||||
self.submit_button.is_loading = True
|
self.submit_button_is_loading = True
|
||||||
self.submit_button.force_refresh()
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
if not self.email_input.text:
|
if not self.e_mail:
|
||||||
error_msg = "E-Mail darf nicht leer sein!"
|
error_msg = "E-Mail darf nicht leer sein!"
|
||||||
elif not self.subject_input.text:
|
elif not self.subject:
|
||||||
error_msg = "Betreff darf nicht leer sein!"
|
error_msg = "Betreff darf nicht leer sein!"
|
||||||
elif not self.message_input.text:
|
elif not self.message:
|
||||||
error_msg = "Nachricht darf nicht leer sein!"
|
error_msg = "Nachricht darf nicht leer sein!"
|
||||||
elif (now - self.last_message_sent[0]) < timedelta(minutes=1):
|
elif (now - self.last_message_sent[0]) < timedelta(minutes=1):
|
||||||
error_msg = "Immer mit der Ruhe!"
|
error_msg = "Immer mit der Ruhe!"
|
||||||
|
|
||||||
if error_msg:
|
if error_msg:
|
||||||
self.submit_button.is_loading = False
|
self.submit_button_is_loading = False
|
||||||
await self.animated_text.display_text(False, error_msg)
|
self.is_success = False
|
||||||
|
self.response_message = error_msg
|
||||||
return
|
return
|
||||||
|
|
||||||
mail_recipient = self.session[ConfigurationService].get_lan_info().organizer_mail
|
mail_recipient = self.session[ConfigurationService].get_lan_info().organizer_mail
|
||||||
msg = (f"Kontaktformular vom {now.strftime('%d.%m.%Y %H:%M')}:\n\n"
|
msg = (f"Kontaktformular vom {now.strftime('%d.%m.%Y %H:%M')}:\n\n"
|
||||||
f"Betreff: {self.subject_input.text}\n"
|
f"Betreff: {self.subject}\n"
|
||||||
f"Absender: {self.email_input.text}\n\n"
|
f"Absender: {self.e_mail}\n\n"
|
||||||
f"Inhalt:\n"
|
f"Inhalt:\n"
|
||||||
f"{self.message_input.text}\n")
|
f"{self.message}\n")
|
||||||
|
|
||||||
await self.session[MailingService].send_email("Kontaktformular-Mitteilung", msg, mail_recipient)
|
await self.session[MailingService].send_email("Kontaktformular-Mitteilung", msg, mail_recipient)
|
||||||
self.last_message_sent[0] = datetime.now()
|
self.last_message_sent[0] = datetime.now()
|
||||||
self.submit_button.is_loading = False
|
self.submit_button_is_loading = False
|
||||||
await self.animated_text.display_text(True, "Nachricht erfolgreich gesendet!")
|
self.is_success = True
|
||||||
|
self.response_message = "Nachricht erfolgreich gesendet!"
|
||||||
|
|
||||||
def build(self) -> Component:
|
def build(self) -> Component:
|
||||||
self.animated_text = AnimatedText(
|
email_input = TextInput(
|
||||||
margin_top=2,
|
|
||||||
margin_bottom=1,
|
|
||||||
align_x=0.1
|
|
||||||
)
|
|
||||||
|
|
||||||
self.email_input = TextInput(
|
|
||||||
label="E-Mail Adresse",
|
label="E-Mail Adresse",
|
||||||
text="" if not self.user else self.user.user_mail,
|
text=self.bind().e_mail,
|
||||||
margin_left=1,
|
margin_left=1,
|
||||||
margin_right=1,
|
margin_right=1,
|
||||||
margin_bottom=1,
|
margin_bottom=1,
|
||||||
grow_x=True
|
grow_x=True
|
||||||
)
|
)
|
||||||
|
|
||||||
self.subject_input = TextInput(
|
subject_input = TextInput(
|
||||||
label="Betreff",
|
label="Betreff",
|
||||||
text="",
|
text=self.bind().subject,
|
||||||
margin_left=1,
|
margin_left=1,
|
||||||
margin_right=1,
|
margin_right=1,
|
||||||
margin_bottom=1,
|
margin_bottom=1,
|
||||||
grow_x=True
|
grow_x=True
|
||||||
)
|
)
|
||||||
|
|
||||||
self.message_input = MultiLineTextInput(
|
message_input = MultiLineTextInput(
|
||||||
label="Deine Nachricht an uns",
|
label="Deine Nachricht an uns",
|
||||||
text="",
|
text=self.bind().message,
|
||||||
margin_left=1,
|
margin_left=1,
|
||||||
margin_right=1,
|
margin_right=1,
|
||||||
margin_bottom=1,
|
margin_bottom=1,
|
||||||
min_height=5
|
min_height=5
|
||||||
)
|
)
|
||||||
|
|
||||||
self.submit_button = Button(
|
submit_button = Button(
|
||||||
content=Text(
|
content=Text(
|
||||||
"Absenden",
|
"Absenden",
|
||||||
style=TextStyle(fill=self.session.theme.success_color, font_size=0.9),
|
style=TextStyle(fill=self.session.theme.success_color, font_size=0.9),
|
||||||
@@ -102,7 +101,8 @@ class ContactPage(Component):
|
|||||||
shape="rectangle",
|
shape="rectangle",
|
||||||
style="major",
|
style="major",
|
||||||
color="primary",
|
color="primary",
|
||||||
on_press=self.on_send_pressed
|
on_press=self.on_send_pressed,
|
||||||
|
is_loading=self.bind().submit_button_is_loading
|
||||||
)
|
)
|
||||||
return Column(
|
return Column(
|
||||||
MainViewContentBox(
|
MainViewContentBox(
|
||||||
@@ -117,12 +117,21 @@ class ContactPage(Component):
|
|||||||
margin_bottom=1,
|
margin_bottom=1,
|
||||||
align_x=0.5
|
align_x=0.5
|
||||||
),
|
),
|
||||||
self.email_input,
|
email_input,
|
||||||
self.subject_input,
|
subject_input,
|
||||||
self.message_input,
|
message_input,
|
||||||
Row(
|
Row(
|
||||||
self.animated_text,
|
Text(
|
||||||
self.submit_button,
|
text=self.bind().response_message,
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.success_color if self.is_success else self.session.theme.danger_color,
|
||||||
|
font_size=0.9
|
||||||
|
),
|
||||||
|
margin_top=2,
|
||||||
|
margin_bottom=1,
|
||||||
|
align_x=0.1
|
||||||
|
),
|
||||||
|
submit_button,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from copy import deepcopy
|
||||||
|
from random import randint
|
||||||
|
from typing import * # type: ignore
|
||||||
|
|
||||||
|
from rio import Component, event, Column, Row, Color, Rectangle
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class ConwayPage(Component):
|
||||||
|
"""
|
||||||
|
This is an Easter egg.
|
||||||
|
"""
|
||||||
|
|
||||||
|
active_generation: list[list] = []
|
||||||
|
rows: int = 36
|
||||||
|
cols: int = 20
|
||||||
|
|
||||||
|
@event.periodic(1)
|
||||||
|
async def calc_next_gen(self) -> None:
|
||||||
|
self.create_next_grid()
|
||||||
|
|
||||||
|
@event.on_populate
|
||||||
|
def prepare(self) -> None:
|
||||||
|
self.active_generation = self.create_initial_grid()
|
||||||
|
|
||||||
|
def create_initial_grid(self) -> list[list]:
|
||||||
|
grid = []
|
||||||
|
for row in range(self.rows):
|
||||||
|
grid_rows = []
|
||||||
|
for col in range(self.cols):
|
||||||
|
if randint(0, 7) == 0:
|
||||||
|
grid_rows += [1]
|
||||||
|
else:
|
||||||
|
grid_rows += [0]
|
||||||
|
grid += [grid_rows]
|
||||||
|
return grid
|
||||||
|
|
||||||
|
def create_next_grid(self) -> None:
|
||||||
|
next_grid = deepcopy(self.active_generation)
|
||||||
|
|
||||||
|
for row in range(self.rows):
|
||||||
|
for col in range(self.cols):
|
||||||
|
live_neighbors = self.get_live_neighbors(row, col, self.active_generation)
|
||||||
|
|
||||||
|
if live_neighbors < 2 or live_neighbors > 3:
|
||||||
|
next_grid[row][col] = 0
|
||||||
|
elif live_neighbors == 3 and self.active_generation[row][col] == 0:
|
||||||
|
next_grid[row][col] = 1
|
||||||
|
else:
|
||||||
|
next_grid[row][col] = self.active_generation[row][col]
|
||||||
|
|
||||||
|
self.active_generation = next_grid
|
||||||
|
|
||||||
|
def get_live_neighbors(self, row: int, col: int, grid: list[list]) -> int:
|
||||||
|
life_sum = 0
|
||||||
|
for i in range(-1, 2):
|
||||||
|
for j in range(-1, 2):
|
||||||
|
if not (i == 0 and j == 0):
|
||||||
|
life_sum += grid[((row + i) % self.rows)][((col + j) % self.cols)]
|
||||||
|
return life_sum
|
||||||
|
|
||||||
|
def grid_changing(self, next_grid: list[list]) -> bool:
|
||||||
|
for row in range(self.rows):
|
||||||
|
for col in range(self.cols):
|
||||||
|
if not self.active_generation[row][col] == next_grid[row][col]:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
rows = []
|
||||||
|
|
||||||
|
for row in self.active_generation:
|
||||||
|
rectangles = []
|
||||||
|
|
||||||
|
for cell in row:
|
||||||
|
color = Color.WHITE if cell == 1 else Color.BLACK
|
||||||
|
rectangles.append(Rectangle(fill=color, transition_time=0.3))
|
||||||
|
|
||||||
|
rows.append(Row(*rectangles))
|
||||||
|
|
||||||
|
return Column(*rows)
|
||||||
@@ -5,9 +5,9 @@ from typing import * # type: ignore
|
|||||||
|
|
||||||
from rio import Component, event, Spacer, Card, Container, Column, Row, TextStyle, Color, Text
|
from rio import Component, event, Spacer, Card, Container, Column, Row, TextStyle, Color, Text
|
||||||
|
|
||||||
from src.ez_lan_manager.services.DatabaseService import DatabaseService
|
from src.ezgg_lan_manager.services.DatabaseService import DatabaseService
|
||||||
from src.ez_lan_manager import ConfigurationService
|
from src.ezgg_lan_manager import ConfigurationService
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
|
||||||
|
|
||||||
class DbErrorPage(Component):
|
class DbErrorPage(Component):
|
||||||
@@ -62,7 +62,7 @@ class DbErrorPage(Component):
|
|||||||
Row(
|
Row(
|
||||||
Spacer(grow_x=True, grow_y=False),
|
Spacer(grow_x=True, grow_y=False),
|
||||||
Card(
|
Card(
|
||||||
content=Text(f"EZ LAN Manager Version {self.session[ConfigurationService].APP_VERSION} © EZ GG e.V.", align_x=0.5, align_y=0.5, style=TextStyle(fill=self.session.theme.primary_color, font_size=0.5)),
|
content=Text(f"EZGG LAN Manager Version {self.session[ConfigurationService].APP_VERSION} © EZ GG e.V.", align_x=0.5, align_y=0.5, style=TextStyle(fill=self.session.theme.primary_color, font_size=0.5)),
|
||||||
color=self.session.theme.neutral_color,
|
color=self.session.theme.neutral_color,
|
||||||
corner_radius=(0, 0, 0.5, 0.5),
|
corner_radius=(0, 0, 0.5, 0.5),
|
||||||
grow_x=False,
|
grow_x=False,
|
||||||
@@ -82,7 +82,7 @@ class DbErrorPage(Component):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return Text(
|
return Text(
|
||||||
"Der EZ LAN Manager wird\nauf mobilen Endgeräten nur\nim Querformat unterstützt.\nBitte drehe dein Gerät.",
|
"Der EZGG LAN Manager wird\nauf mobilen Endgeräten nur\nim Querformat unterstützt.\nBitte drehe dein Gerät.",
|
||||||
align_x=0.5,
|
align_x=0.5,
|
||||||
align_y=0.5,
|
align_y=0.5,
|
||||||
style=TextStyle(fill=Color.from_hex("FFFFFF"), font_size=0.8)
|
style=TextStyle(fill=Color.from_hex("FFFFFF"), font_size=0.8)
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
from rio import Column, Component, event, Spacer
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager import ConfigurationService
|
||||||
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
from src.ezgg_lan_manager.components.UserEditForm import UserEditForm
|
||||||
|
|
||||||
|
|
||||||
|
class EditProfilePage(Component):
|
||||||
|
@event.on_populate
|
||||||
|
async def on_populate(self) -> None:
|
||||||
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Profil bearbeiten")
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
return Column(
|
||||||
|
MainViewContentBox(UserEditForm(is_own_profile=True)),
|
||||||
|
Spacer(grow_y=True)
|
||||||
|
)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from rio import Column, Component, event, TextStyle, Text, Revealer
|
from rio import Column, Component, event, TextStyle, Text, Revealer
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService
|
from src.ezgg_lan_manager import ConfigurationService
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
|
||||||
FAQ: list[list[str]] = [
|
FAQ: list[list[str]] = [
|
||||||
["Wie melde ich mich für die LAN an?",
|
["Wie melde ich mich für die LAN an?",
|
||||||
@@ -4,8 +4,8 @@ from random import choices
|
|||||||
from email_validator import validate_email, EmailNotValidError
|
from email_validator import validate_email, EmailNotValidError
|
||||||
from rio import Column, Component, event, Text, TextStyle, TextInput, TextInputChangeEvent, Button
|
from rio import Column, Component, event, Text, TextStyle, TextInput, TextInputChangeEvent, Button
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, UserService, MailingService
|
from src.ezgg_lan_manager import ConfigurationService, UserService, MailingService
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
|
||||||
|
|
||||||
class ForgotPasswordPage(Component):
|
class ForgotPasswordPage(Component):
|
||||||
@@ -27,11 +27,11 @@ class ForgotPasswordPage(Component):
|
|||||||
user = await user_service.get_user(self.email_input.text.strip())
|
user = await user_service.get_user(self.email_input.text.strip())
|
||||||
if user is not None:
|
if user is not None:
|
||||||
new_password = "".join(choices(user_service.ALLOWED_USER_NAME_SYMBOLS, k=16))
|
new_password = "".join(choices(user_service.ALLOWED_USER_NAME_SYMBOLS, k=16))
|
||||||
user.user_password = sha256(new_password.encode(encoding="utf-8")).hexdigest()
|
user.user_fallback_password = sha256(new_password.encode(encoding="utf-8")).hexdigest()
|
||||||
await user_service.update_user(user)
|
await user_service.update_user(user)
|
||||||
await mailing_service.send_email(
|
await mailing_service.send_email(
|
||||||
subject=f"Dein neues Passwort für {lan_info.name}",
|
subject=f"Dein neues Passwort für {lan_info.name}",
|
||||||
body=f"Du hast für den EZ-LAN Manager der {lan_info.name} ein neues Passwort angefragt. "
|
body=f"Du hast für den EZGG-LAN Manager der {lan_info.name} ein neues Passwort angefragt. "
|
||||||
f"Und hier ist es schon:\n\n{new_password}\n\nSolltest du kein neues Passwort angefordert haben, "
|
f"Und hier ist es schon:\n\n{new_password}\n\nSolltest du kein neues Passwort angefordert haben, "
|
||||||
f"ignoriere diese E-Mail.\n\nLiebe Grüße\nDein {lan_info.name} - Team",
|
f"ignoriere diese E-Mail.\n\nLiebe Grüße\nDein {lan_info.name} - Team",
|
||||||
receiver=self.email_input.text.strip()
|
receiver=self.email_input.text.strip()
|
||||||
@@ -2,10 +2,10 @@ from typing import Optional
|
|||||||
|
|
||||||
from rio import Column, Component, event, TextStyle, Text, Button, Row, TextInput, Spacer, TextInputChangeEvent
|
from rio import Column, Component, event, TextStyle, Text, Button, Row, TextInput, Spacer, TextInputChangeEvent
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, UserService, TicketingService, SeatingService
|
from src.ezgg_lan_manager import ConfigurationService, UserService, TicketingService, SeatingService
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
from src.ez_lan_manager.types.Seat import Seat
|
from src.ezgg_lan_manager.types.Seat import Seat
|
||||||
from src.ez_lan_manager.types.User import User
|
from src.ezgg_lan_manager.types.User import User
|
||||||
|
|
||||||
|
|
||||||
class GuestsPage(Component):
|
class GuestsPage(Component):
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from rio import Text, Column, TextStyle, Component, event, Link, Color
|
from rio import Text, Column, TextStyle, Component, event, Link, Color
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService
|
from src.ezgg_lan_manager import ConfigurationService
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
|
||||||
|
|
||||||
class ImprintPage(Component):
|
class ImprintPage(Component):
|
||||||
@@ -5,11 +5,11 @@ from typing import Optional, Callable
|
|||||||
|
|
||||||
from rio import Column, Component, event, TextStyle, Text, Spacer, PointerEvent, Button, Popup, Card, Row
|
from rio import Column, Component, event, TextStyle, Text, Spacer, PointerEvent, Button, Popup, Card, Row
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, CateringService, SeatingService, AccountingService
|
from src.ezgg_lan_manager import ConfigurationService, CateringService, SeatingService, AccountingService
|
||||||
from src.ez_lan_manager.components.CateringManagementOrderDisplay import CateringManagementOrderDisplay
|
from src.ezgg_lan_manager.components.CateringManagementOrderDisplay import CateringManagementOrderDisplay
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
from src.ez_lan_manager.types.CateringOrder import CateringOrder, CateringOrderStatus
|
from src.ezgg_lan_manager.types.CateringOrder import CateringOrder, CateringOrderStatus
|
||||||
from src.ez_lan_manager.types.Seat import Seat
|
from src.ezgg_lan_manager.types.Seat import Seat
|
||||||
|
|
||||||
logger = logging.getLogger(__name__.split(".")[-1])
|
logger = logging.getLogger(__name__.split(".")[-1])
|
||||||
|
|
||||||
@@ -5,11 +5,11 @@ from time import strptime
|
|||||||
|
|
||||||
from rio import Column, Component, event, TextStyle, Text
|
from rio import Column, Component, event, TextStyle, Text
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, UserService
|
from src.ezgg_lan_manager import ConfigurationService, UserService
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
from src.ez_lan_manager.components.NewsPost import EditableNewsPost
|
from src.ezgg_lan_manager.components.NewsPost import EditableNewsPost
|
||||||
from src.ez_lan_manager.services.NewsService import NewsService
|
from src.ezgg_lan_manager.services.NewsService import NewsService
|
||||||
from src.ez_lan_manager.types.News import News
|
from src.ezgg_lan_manager.types.News import News
|
||||||
|
|
||||||
logger = logging.getLogger(__name__.split(".")[-1])
|
logger = logging.getLogger(__name__.split(".")[-1])
|
||||||
|
|
||||||
@@ -78,8 +78,8 @@ class ManageNewsPage(Component):
|
|||||||
Column(
|
Column(
|
||||||
Text(
|
Text(
|
||||||
text="News Verwaltung",
|
text="News Verwaltung",
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
style=TextStyle(
|
style=TextStyle(
|
||||||
fill=self.session.theme.background_color,
|
|
||||||
font_size=1.2
|
font_size=1.2
|
||||||
),
|
),
|
||||||
margin_top=2,
|
margin_top=2,
|
||||||
@@ -88,8 +88,8 @@ class ManageNewsPage(Component):
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
text="Neuen News Post erstellen",
|
text="Neuen News Post erstellen",
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
style=TextStyle(
|
style=TextStyle(
|
||||||
fill=self.session.theme.background_color,
|
|
||||||
font_size=1.1
|
font_size=1.1
|
||||||
),
|
),
|
||||||
margin_top=2,
|
margin_top=2,
|
||||||
@@ -106,8 +106,8 @@ class ManageNewsPage(Component):
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
text="Post erfolgreich erstellt",
|
text="Post erfolgreich erstellt",
|
||||||
|
fill=self.session.theme.success_color,
|
||||||
style=TextStyle(
|
style=TextStyle(
|
||||||
fill=self.session.theme.success_color,
|
|
||||||
font_size=0.7 if self.show_success_message else 0
|
font_size=0.7 if self.show_success_message else 0
|
||||||
),
|
),
|
||||||
margin_top=0.1,
|
margin_top=0.1,
|
||||||
@@ -116,8 +116,8 @@ class ManageNewsPage(Component):
|
|||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
text="Bisherige Posts",
|
text="Bisherige Posts",
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
style=TextStyle(
|
style=TextStyle(
|
||||||
fill=self.session.theme.background_color,
|
|
||||||
font_size=1.1
|
font_size=1.1
|
||||||
),
|
),
|
||||||
margin_top=2,
|
margin_top=2,
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
import logging
|
||||||
|
from datetime import datetime
|
||||||
|
from functools import partial
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from from_root import from_root
|
||||||
|
from rio import Column, Component, event, TextStyle, Text, Spacer, Row, Image, Tooltip, IconButton, Popup, Rectangle, Dropdown, ThemeContextSwitcher, Button
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager import ConfigurationService, TournamentService, UserService
|
||||||
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
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
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__.split(".")[-1])
|
||||||
|
|
||||||
|
class ManageTournamentsPage(Component):
|
||||||
|
tournaments: list[Tournament] = []
|
||||||
|
remove_participant_popup_open: bool = False
|
||||||
|
cancel_options: dict[str, Optional[Participant]] = {"": None}
|
||||||
|
tournament_id_selected_for_participant_removal: Optional[int] = None
|
||||||
|
participant_selected_for_removal: Optional[Participant] = None
|
||||||
|
|
||||||
|
@event.on_populate
|
||||||
|
async def on_populate(self) -> None:
|
||||||
|
self.tournaments = await self.session[TournamentService].get_tournaments()
|
||||||
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Turnier Verwaltung")
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
async def on_cancel_pressed(self, tournament_id: int) -> None:
|
||||||
|
logger.info(f"Canceling tournament with ID {tournament_id}")
|
||||||
|
await self.session[TournamentService].cancel_tournament(tournament_id)
|
||||||
|
|
||||||
|
async def on_remove_participant_pressed(self, tournament_id: int) -> None:
|
||||||
|
tournament = await self.session[TournamentService].get_tournament_by_id(tournament_id)
|
||||||
|
if tournament is None:
|
||||||
|
return
|
||||||
|
users = await self.session[UserService].get_all_users()
|
||||||
|
try:
|
||||||
|
cancel_options = {next(filter(lambda u: u.user_id == p.id, users)).user_name: p for p in tournament.participants}
|
||||||
|
if cancel_options:
|
||||||
|
self.cancel_options = cancel_options
|
||||||
|
else:
|
||||||
|
self.cancel_options = {"": None}
|
||||||
|
except StopIteration as e:
|
||||||
|
logger.error(f"Error trying to find user for participant: {e}")
|
||||||
|
self.tournament_id_selected_for_participant_removal = tournament_id
|
||||||
|
self.remove_participant_popup_open = True
|
||||||
|
|
||||||
|
async def on_remove_participant_confirm_pressed(self) -> None:
|
||||||
|
if self.participant_selected_for_removal is not None and self.tournament_id_selected_for_participant_removal is not None:
|
||||||
|
logger.info(f"Removing participant with ID {self.participant_selected_for_removal.id} from tournament with ID {self.tournament_id_selected_for_participant_removal}")
|
||||||
|
await self.session[TournamentService].unregister_user_from_tournament(self.participant_selected_for_removal.id, self.tournament_id_selected_for_participant_removal)
|
||||||
|
await self.on_remove_participant_cancel_pressed()
|
||||||
|
|
||||||
|
async def on_remove_participant_cancel_pressed(self) -> None:
|
||||||
|
self.tournament_id_selected_for_participant_removal = None
|
||||||
|
self.participant_selected_for_removal = None
|
||||||
|
self.remove_participant_popup_open = False
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
tournament_rows = []
|
||||||
|
for tournament in self.tournaments:
|
||||||
|
start_time_color = self.session.theme.background_color
|
||||||
|
if tournament.start_time < datetime.now() and tournament.status == TournamentStatus.OPEN:
|
||||||
|
start_time_color = self.session.theme.warning_color
|
||||||
|
|
||||||
|
tournament_rows.append(
|
||||||
|
Row(
|
||||||
|
Image(image=from_root(f"src/ezgg_lan_manager/assets/img/games/{tournament.game_title.image_name}"), min_width=1.5, margin_right=1),
|
||||||
|
Text(tournament.name, style=TextStyle(fill=self.session.theme.background_color, font_size=0.8), justify="left", margin_right=1.5),
|
||||||
|
Text(f"{weekday_to_display_text(tournament.start_time.weekday())[:2]}.{tournament.start_time.strftime('%H:%M')} Uhr", style=TextStyle(fill=start_time_color, font_size=0.8), justify="left", margin_right=1),
|
||||||
|
Spacer(),
|
||||||
|
Tooltip(anchor=IconButton("material/play_arrow", min_size=2, margin_right=0.5, on_press=partial(self.on_start_pressed, tournament.id)), tip="Starten"),
|
||||||
|
Tooltip(anchor=IconButton("material/cancel_schedule_send", min_size=2, margin_right=0.5, on_press=partial(self.on_cancel_pressed, tournament.id)), tip="Absagen"),
|
||||||
|
Tooltip(anchor=IconButton("material/person_cancel", min_size=2, on_press=partial(self.on_remove_participant_pressed, tournament.id)), tip="Spieler entfernen"),
|
||||||
|
margin=1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return Column(
|
||||||
|
Popup(
|
||||||
|
anchor=MainViewContentBox(
|
||||||
|
Column(
|
||||||
|
Text(
|
||||||
|
text="Turnier Verwaltung",
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1.2
|
||||||
|
),
|
||||||
|
margin_top=2,
|
||||||
|
margin_bottom=2,
|
||||||
|
align_x=0.5
|
||||||
|
),
|
||||||
|
*tournament_rows
|
||||||
|
)
|
||||||
|
),
|
||||||
|
content=Rectangle(
|
||||||
|
content=Row(
|
||||||
|
ThemeContextSwitcher(
|
||||||
|
content=Dropdown(options=self.cancel_options, min_width=20, selected_value=self.bind().participant_selected_for_removal), color=self.session.theme.hud_color
|
||||||
|
),
|
||||||
|
Button(content="REMOVE", shape="rectangle", grow_x=False, on_press=self.on_remove_participant_confirm_pressed),
|
||||||
|
Button(content="CANCEL", shape="rectangle", grow_x=False, on_press=self.on_remove_participant_cancel_pressed),
|
||||||
|
margin=0.5
|
||||||
|
),
|
||||||
|
min_width=30,
|
||||||
|
min_height=4,
|
||||||
|
fill=self.session.theme.primary_color,
|
||||||
|
margin_top=3.5,
|
||||||
|
stroke_width=0.3,
|
||||||
|
stroke_color=self.session.theme.neutral_color,
|
||||||
|
),
|
||||||
|
is_open=self.remove_participant_popup_open,
|
||||||
|
color="none"
|
||||||
|
),
|
||||||
|
Spacer()
|
||||||
|
)
|
||||||
@@ -3,17 +3,17 @@ from dataclasses import field
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from rio import Column, Component, event, TextStyle, Text, TextInput, ThemeContextSwitcher, Grid, \
|
from rio import Column, Component, event, TextStyle, Text, TextInput, ThemeContextSwitcher, Grid, \
|
||||||
PointerEventListener, PointerEvent, Rectangle, CursorStyle, Color, TextInputChangeEvent, Spacer, Row, Switch, \
|
PointerEventListener, PointerEvent, Rectangle, Color, TextInputChangeEvent, Spacer, Row, Switch, \
|
||||||
SwitchChangeEvent, EventHandler
|
SwitchChangeEvent, EventHandler
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, UserService, AccountingService, SeatingService
|
from src.ezgg_lan_manager import ConfigurationService, UserService, AccountingService, SeatingService, MailingService
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
from src.ez_lan_manager.components.NewTransactionForm import NewTransactionForm
|
from src.ezgg_lan_manager.components.NewTransactionForm import NewTransactionForm
|
||||||
from src.ez_lan_manager.components.UserEditForm import UserEditForm
|
from src.ezgg_lan_manager.components.UserEditForm import UserEditForm
|
||||||
from src.ez_lan_manager.services.AccountingService import InsufficientFundsError
|
from src.ezgg_lan_manager.services.AccountingService import InsufficientFundsError
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
from src.ezgg_lan_manager.types.Transaction import Transaction
|
||||||
from src.ez_lan_manager.types.Transaction import Transaction
|
from src.ezgg_lan_manager.types.User import User
|
||||||
from src.ez_lan_manager.types.User import User
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
logger = logging.getLogger(__name__.split(".")[-1])
|
logger = logging.getLogger(__name__.split(".")[-1])
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ class ClickableGridContent(Component):
|
|||||||
grow_x=True
|
grow_x=True
|
||||||
),
|
),
|
||||||
fill=Color.TRANSPARENT,
|
fill=Color.TRANSPARENT,
|
||||||
cursor=CursorStyle.POINTER
|
cursor="pointer"
|
||||||
),
|
),
|
||||||
on_pointer_enter=self.on_mouse_enter,
|
on_pointer_enter=self.on_mouse_enter,
|
||||||
on_pointer_leave=self.on_mouse_leave,
|
on_pointer_leave=self.on_mouse_leave,
|
||||||
@@ -84,7 +84,11 @@ class ManageUsersPage(Component):
|
|||||||
await self.session[UserService].update_user(self.selected_user)
|
await self.session[UserService].update_user(self.selected_user)
|
||||||
|
|
||||||
async def on_new_transaction(self, transaction: Transaction) -> None:
|
async def on_new_transaction(self, transaction: Transaction) -> None:
|
||||||
if not self.session[SessionStorage].is_team_member: # Better safe than sorry
|
try:
|
||||||
|
user = await self.session[UserService].get_user(self.session[UserSession].user_id)
|
||||||
|
if not user.is_team_member: # Better safe than sorry
|
||||||
|
return
|
||||||
|
except KeyError:
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.info(f"Got new transaction for user with ID '{transaction.user_id}' over "
|
logger.info(f"Got new transaction for user with ID '{transaction.user_id}' over "
|
||||||
@@ -104,11 +108,17 @@ class ManageUsersPage(Component):
|
|||||||
self.accounting_section_result_success = False
|
self.accounting_section_result_success = False
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
await self.session[AccountingService].add_balance(
|
new_total_balance = await self.session[AccountingService].add_balance(
|
||||||
transaction.user_id,
|
transaction.user_id,
|
||||||
transaction.value,
|
transaction.value,
|
||||||
transaction.reference
|
transaction.reference
|
||||||
)
|
)
|
||||||
|
user = await self.session[UserService].get_user(transaction.user_id)
|
||||||
|
await self.session[MailingService].send_email(
|
||||||
|
"Dein Guthaben wurde aufgeladen",
|
||||||
|
self.session[MailingService].generate_account_balance_added_mail_body(user, transaction.value, new_total_balance),
|
||||||
|
user.user_mail
|
||||||
|
)
|
||||||
|
|
||||||
self.accounting_section_result_text = f"Guthaben {'entfernt' if transaction.is_debit else 'hinzugefügt'}!"
|
self.accounting_section_result_text = f"Guthaben {'entfernt' if transaction.is_debit else 'hinzugefügt'}!"
|
||||||
self.accounting_section_result_success = True
|
self.accounting_section_result_success = True
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
from rio import Column, Component, event
|
from rio import Column, Component, event
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, NewsService
|
from src.ezgg_lan_manager import ConfigurationService, NewsService
|
||||||
from src.ez_lan_manager.components.NewsPost import NewsPost
|
from src.ezgg_lan_manager.components.NewsPost import NewsPost
|
||||||
from src.ez_lan_manager.types.News import News
|
from src.ezgg_lan_manager.types.News import News
|
||||||
|
|
||||||
|
|
||||||
class NewsPage(Component):
|
class NewsPage(Component):
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
from rio import Column, Component, event, Text, Spacer, Row, Link
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager import ConfigurationService, TicketingService
|
||||||
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
|
||||||
|
|
||||||
|
class OverviewPage(Component):
|
||||||
|
@event.on_populate
|
||||||
|
async def on_populate(self) -> None:
|
||||||
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Übersicht")
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
lan_info = self.session[ConfigurationService].get_lan_info()
|
||||||
|
return Column(
|
||||||
|
MainViewContentBox(
|
||||||
|
Column(
|
||||||
|
Text(lan_info.name, font_size=2, justify="center", fill=self.session.theme.neutral_color, margin_top=0.5),
|
||||||
|
Text(f"Edition {lan_info.iteration}", font_size=0.9, justify="center", fill=self.session.theme.neutral_color, margin_bottom=1.5)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
MainViewContentBox(
|
||||||
|
Column(
|
||||||
|
Text("Allgemeines", font_size=2, justify="center", fill=self.session.theme.neutral_color, margin_top=0.5, margin_bottom=1),
|
||||||
|
Column(
|
||||||
|
Row(
|
||||||
|
Text("Wann?", fill=self.session.theme.neutral_color, margin_left=1),
|
||||||
|
Spacer(),
|
||||||
|
Text(f"{lan_info.date_from.strftime("%d.%m.")} bis {lan_info.date_till.strftime("%d.%m.%Y")}", fill=self.session.theme.neutral_color, margin_right=1),
|
||||||
|
margin_bottom=0.3
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
Text("Wo?", fill=self.session.theme.neutral_color, margin_left=1),
|
||||||
|
Spacer(),
|
||||||
|
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("Freitag %H:%M Uhr"), fill=self.session.theme.neutral_color, margin_right=1),
|
||||||
|
margin_bottom=0.3
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
Text("Ende", fill=self.session.theme.neutral_color, margin_left=1),
|
||||||
|
Spacer(),
|
||||||
|
Text(lan_info.date_till.strftime("Sonntag %H:%M Uhr"), fill=self.session.theme.neutral_color, margin_right=1),
|
||||||
|
margin_bottom=0.3
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
Text("Anmeldung", fill=self.session.theme.neutral_color, margin_left=1),
|
||||||
|
Spacer(),
|
||||||
|
Text("Geöffnet", fill=self.session.theme.success_color, margin_right=1),
|
||||||
|
margin_bottom=0.3
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
Text("Teilnehmer", fill=self.session.theme.neutral_color, margin_left=1),
|
||||||
|
Spacer(),
|
||||||
|
Text(str(self.session[TicketingService].get_total_tickets()), fill=self.session.theme.neutral_color, margin_right=1),
|
||||||
|
margin_bottom=0.3
|
||||||
|
)
|
||||||
|
,
|
||||||
|
Row(
|
||||||
|
Text("Ticket Preise", fill=self.session.theme.neutral_color, margin_left=1),
|
||||||
|
Spacer(),
|
||||||
|
Link(Text(f"Preisliste", fill=self.session.theme.secondary_color, margin_right=1), target_url="./buy_ticket", open_in_new_tab=False),
|
||||||
|
margin_bottom=0.3
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
MainViewContentBox(
|
||||||
|
Column(
|
||||||
|
Text("Technisches", font_size=2, justify="center", fill=self.session.theme.neutral_color, margin_top=0.5, margin_bottom=1),
|
||||||
|
Column(
|
||||||
|
Row(
|
||||||
|
Text("Internet", fill=self.session.theme.neutral_color, margin_left=1),
|
||||||
|
Spacer(),
|
||||||
|
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"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"vorhanden", fill=self.session.theme.neutral_color, margin_right=1),
|
||||||
|
margin_bottom=0.3
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
MainViewContentBox(
|
||||||
|
Column(
|
||||||
|
Text("Sonstiges", font_size=2, justify="center", fill=self.session.theme.neutral_color, margin_top=0.5, margin_bottom=1),
|
||||||
|
Column(
|
||||||
|
Row(
|
||||||
|
Text("Schlafen", fill=self.session.theme.neutral_color, margin_left=1, justify="center"),
|
||||||
|
margin_bottom=0.3
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
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
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
Text("Essen & Trinken", fill=self.session.theme.neutral_color, margin_left=1, justify="center"),
|
||||||
|
margin_bottom=0.3
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
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
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Spacer()
|
||||||
|
)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from rio import Column, Component, event
|
from rio import Column, Component, event
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService
|
from src.ezgg_lan_manager import ConfigurationService
|
||||||
from src.ez_lan_manager.components.NewsPost import NewsPost
|
from src.ezgg_lan_manager.components.NewsPost import NewsPost
|
||||||
|
|
||||||
|
|
||||||
class PlaceholderPage(Component):
|
class PlaceholderPage(Component):
|
||||||
@@ -0,0 +1,202 @@
|
|||||||
|
import logging
|
||||||
|
from asyncio import sleep, create_task
|
||||||
|
|
||||||
|
from email_validator import validate_email, EmailNotValidError
|
||||||
|
from rio import Column, Component, event, Text, TextStyle, TextInput, TextInputChangeEvent, Button
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager import ConfigurationService, UserService, MailingService
|
||||||
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
|
||||||
|
MINIMUM_PASSWORD_LENGTH = 6
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__.split(".")[-1])
|
||||||
|
|
||||||
|
|
||||||
|
class RegisterPage(Component):
|
||||||
|
pw_1: str = ""
|
||||||
|
pw_2: str = ""
|
||||||
|
email: str = ""
|
||||||
|
user_name: str = ""
|
||||||
|
pw_1_valid: bool = True
|
||||||
|
pw_2_valid: bool = True
|
||||||
|
email_valid: bool = True
|
||||||
|
submit_button_loading: bool = False
|
||||||
|
display_text: str = ""
|
||||||
|
display_text_style: TextStyle = TextStyle()
|
||||||
|
|
||||||
|
def on_pw_focus_loss(self, _: TextInputChangeEvent) -> None:
|
||||||
|
if not (self.pw_1 == self.pw_2) or len(self.pw_1) < MINIMUM_PASSWORD_LENGTH:
|
||||||
|
self.pw_1_valid = False
|
||||||
|
self.pw_2_valid = False
|
||||||
|
return
|
||||||
|
self.pw_1_valid = True
|
||||||
|
self.pw_2_valid = True
|
||||||
|
|
||||||
|
def on_email_focus_loss(self, change_event: TextInputChangeEvent) -> None:
|
||||||
|
try:
|
||||||
|
validate_email(change_event.text, check_deliverability=False)
|
||||||
|
self.email_valid = True
|
||||||
|
except EmailNotValidError:
|
||||||
|
self.email_valid = False
|
||||||
|
|
||||||
|
def on_user_name_focus_loss(self, _: TextInputChangeEvent) -> None:
|
||||||
|
current_text = self.user_name
|
||||||
|
if len(current_text) > UserService.MAX_USERNAME_LENGTH:
|
||||||
|
self.user_name = current_text[:UserService.MAX_USERNAME_LENGTH]
|
||||||
|
|
||||||
|
async def on_submit_button_pressed(self) -> None:
|
||||||
|
self.submit_button_loading = True
|
||||||
|
|
||||||
|
if len(self.user_name) < 1:
|
||||||
|
await self.display_animated_text(False, "Nutzername darf nicht leer sein!")
|
||||||
|
self.submit_button_loading = False
|
||||||
|
return
|
||||||
|
|
||||||
|
if not (self.pw_1 == self.pw_2):
|
||||||
|
await self.display_animated_text(False, "Passwörter stimmen nicht überein!")
|
||||||
|
self.submit_button_loading = False
|
||||||
|
return
|
||||||
|
|
||||||
|
if len(self.pw_1) < MINIMUM_PASSWORD_LENGTH:
|
||||||
|
await self.display_animated_text(False, f"Passwort muss mindestens {MINIMUM_PASSWORD_LENGTH} Zeichen lang sein!")
|
||||||
|
self.submit_button_loading = False
|
||||||
|
return
|
||||||
|
|
||||||
|
if not self.email_valid or len(self.email) < 3:
|
||||||
|
await self.display_animated_text(False, "E-Mail Adresse ungültig!")
|
||||||
|
self.submit_button_loading = False
|
||||||
|
return
|
||||||
|
|
||||||
|
user_service = self.session[UserService]
|
||||||
|
mailing_service = self.session[MailingService]
|
||||||
|
lan_info = self.session[ConfigurationService].get_lan_info()
|
||||||
|
|
||||||
|
if await user_service.get_user(self.email) is not None or await user_service.get_user(self.user_name) is not None:
|
||||||
|
await self.display_animated_text(False, "Benutzername oder E-Mail bereits registriert!")
|
||||||
|
self.submit_button_loading = False
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
new_user = await user_service.create_user(self.user_name, self.email, self.pw_1)
|
||||||
|
if not new_user:
|
||||||
|
logger.error(f"create_user returned: {new_user}")
|
||||||
|
raise Exception(f"create_user returned: {new_user}")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Unknown error during new user registration: {e}")
|
||||||
|
await self.display_animated_text(False, "Es ist ein unbekannter Fehler aufgetreten :(")
|
||||||
|
self.submit_button_loading = False
|
||||||
|
return
|
||||||
|
|
||||||
|
await mailing_service.send_email(
|
||||||
|
subject="Erfolgreiche Registrierung",
|
||||||
|
body=f"Hallo {self.user_name},\n\n"
|
||||||
|
f"Du hast dich erfolgreich beim EZGG-LAN Manager für {lan_info.name} {lan_info.iteration} registriert.\n\n"
|
||||||
|
f"Wenn du dich nicht registriert hast, kontaktiere bitte unser Team über unsere Homepage.\n\n"
|
||||||
|
f"Liebe Grüße\nDein {lan_info.name} - Team",
|
||||||
|
receiver=self.email
|
||||||
|
)
|
||||||
|
|
||||||
|
self.submit_button_loading = False
|
||||||
|
await self.display_animated_text(True, "Erfolgreich registriert!")
|
||||||
|
|
||||||
|
@event.on_populate
|
||||||
|
async def on_populate(self) -> None:
|
||||||
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Registrieren")
|
||||||
|
|
||||||
|
async def display_animated_text(self, success: bool, text: str) -> None:
|
||||||
|
self.display_text = ""
|
||||||
|
style = TextStyle(
|
||||||
|
fill=self.session.theme.success_color if success else self.session.theme.danger_color,
|
||||||
|
font_size=0.9
|
||||||
|
)
|
||||||
|
|
||||||
|
self.display_text_style = style
|
||||||
|
_ = create_task(self._animate_text(text))
|
||||||
|
|
||||||
|
async def _animate_text(self, text: str) -> None:
|
||||||
|
for c in text:
|
||||||
|
self.display_text += c
|
||||||
|
await sleep(0.06)
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
user_name_input = TextInput(
|
||||||
|
label="Benutzername",
|
||||||
|
text=self.bind().user_name,
|
||||||
|
margin_left=1,
|
||||||
|
margin_right=1,
|
||||||
|
margin_bottom=1,
|
||||||
|
grow_x=True,
|
||||||
|
on_lose_focus=self.on_user_name_focus_loss
|
||||||
|
)
|
||||||
|
email_input = TextInput(
|
||||||
|
label="E-Mail Adresse",
|
||||||
|
text=self.bind().email,
|
||||||
|
margin_left=1,
|
||||||
|
margin_right=1,
|
||||||
|
margin_bottom=1,
|
||||||
|
grow_x=True,
|
||||||
|
on_lose_focus=self.on_email_focus_loss,
|
||||||
|
is_valid=self.email_valid
|
||||||
|
)
|
||||||
|
pw_1_input = TextInput(
|
||||||
|
label="Passwort",
|
||||||
|
text=self.bind().pw_1,
|
||||||
|
margin_left=1,
|
||||||
|
margin_right=1,
|
||||||
|
margin_bottom=1,
|
||||||
|
grow_x=True,
|
||||||
|
is_secret=True,
|
||||||
|
on_lose_focus=self.on_pw_focus_loss,
|
||||||
|
is_valid=self.pw_1_valid
|
||||||
|
)
|
||||||
|
pw_2_input = TextInput(
|
||||||
|
label="Passwort wiederholen",
|
||||||
|
text=self.bind().pw_2,
|
||||||
|
margin_left=1,
|
||||||
|
margin_right=1,
|
||||||
|
margin_bottom=1,
|
||||||
|
grow_x=True,
|
||||||
|
is_secret=True,
|
||||||
|
on_lose_focus=self.on_pw_focus_loss,
|
||||||
|
is_valid=self.pw_2_valid
|
||||||
|
)
|
||||||
|
submit_button = Button(
|
||||||
|
content=Text(
|
||||||
|
"Registrieren",
|
||||||
|
style=TextStyle(fill=self.session.theme.background_color, font_size=0.9),
|
||||||
|
align_x=0.5
|
||||||
|
),
|
||||||
|
grow_x=True,
|
||||||
|
margin_top=2,
|
||||||
|
margin_left=1,
|
||||||
|
margin_right=1,
|
||||||
|
margin_bottom=1,
|
||||||
|
shape="rectangle",
|
||||||
|
style="minor",
|
||||||
|
color=self.session.theme.secondary_color,
|
||||||
|
on_press=self.on_submit_button_pressed,
|
||||||
|
is_loading=self.submit_button_loading
|
||||||
|
)
|
||||||
|
return Column(
|
||||||
|
MainViewContentBox(
|
||||||
|
content=Column(
|
||||||
|
Text(
|
||||||
|
"Neues Konto anlegen",
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1.2
|
||||||
|
),
|
||||||
|
margin_top=2,
|
||||||
|
margin_bottom=2,
|
||||||
|
align_x=0.5
|
||||||
|
),
|
||||||
|
user_name_input,
|
||||||
|
email_input,
|
||||||
|
pw_1_input,
|
||||||
|
pw_2_input,
|
||||||
|
submit_button,
|
||||||
|
Text(self.display_text, margin_top=2, margin_left=1, margin_right=1, margin_bottom=2, style=self.display_text_style)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
align_y=0,
|
||||||
|
)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from rio import Column, Component, event, TextStyle, Text, Revealer
|
from rio import Column, Component, event, TextStyle, Text, Revealer
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService
|
from src.ezgg_lan_manager import ConfigurationService
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
|
||||||
RULES: list[str] = [
|
RULES: list[str] = [
|
||||||
"Respektvolles Verhalten: Sei höflich und respektvoll gegenüber anderen Gästen und dem Team.",
|
"Respektvolles Verhalten: Sei höflich und respektvoll gegenüber anderen Gästen und dem Team.",
|
||||||
@@ -5,15 +5,15 @@ from typing import Optional
|
|||||||
|
|
||||||
from rio import Text, Column, TextStyle, Component, event, PressEvent, ProgressCircle
|
from rio import Text, Column, TextStyle, Component, event, PressEvent, ProgressCircle
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService, SeatingService, TicketingService, UserService
|
from src.ezgg_lan_manager import ConfigurationService, SeatingService, TicketingService, UserService
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
from src.ez_lan_manager.components.SeatingPlan import SeatingPlan, SeatingPlanLegend
|
from src.ezgg_lan_manager.components.SeatingPlan import SeatingPlan, SeatingPlanLegend
|
||||||
from src.ez_lan_manager.components.SeatingPlanInfoBox import SeatingPlanInfoBox
|
from src.ezgg_lan_manager.components.SeatingPlanInfoBox import SeatingPlanInfoBox
|
||||||
from src.ez_lan_manager.components.SeatingPurchaseBox import SeatingPurchaseBox
|
from src.ezgg_lan_manager.components.SeatingPurchaseBox import SeatingPurchaseBox
|
||||||
from src.ez_lan_manager.services.SeatingService import NoTicketError, SeatNotFoundError, WrongCategoryError, SeatAlreadyTakenError
|
from src.ezgg_lan_manager.services.SeatingService import NoTicketError, SeatNotFoundError, WrongCategoryError, SeatAlreadyTakenError
|
||||||
from src.ez_lan_manager.types.Seat import Seat
|
from src.ezgg_lan_manager.types.Seat import Seat
|
||||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
from src.ezgg_lan_manager.types.User import User
|
||||||
from src.ez_lan_manager.types.User import User
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
logger = logging.getLogger(__name__.split(".")[-1])
|
logger = logging.getLogger(__name__.split(".")[-1])
|
||||||
|
|
||||||
@@ -30,13 +30,17 @@ class SeatingPlanPage(Component):
|
|||||||
purchase_box_loading: bool = False
|
purchase_box_loading: bool = False
|
||||||
purchase_box_success_msg: Optional[str] = None
|
purchase_box_success_msg: Optional[str] = None
|
||||||
purchase_box_error_msg: Optional[str] = None
|
purchase_box_error_msg: Optional[str] = None
|
||||||
|
seating_info_text = ""
|
||||||
is_booking_blocked: bool = False
|
is_booking_blocked: bool = False
|
||||||
|
|
||||||
@event.on_populate
|
@event.on_populate
|
||||||
async def on_populate(self) -> None:
|
async def on_populate(self) -> None:
|
||||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Sitzplan")
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Sitzplan")
|
||||||
self.seating_info = await self.session[SeatingService].get_seating()
|
self.seating_info = await self.session[SeatingService].get_seating()
|
||||||
self.user = await self.session[UserService].get_user(self.session[SessionStorage].user_id)
|
try:
|
||||||
|
self.user = await self.session[UserService].get_user(self.session[UserSession].user_id)
|
||||||
|
except KeyError:
|
||||||
|
self.user = None
|
||||||
if not self.user:
|
if not self.user:
|
||||||
self.is_booking_blocked = True
|
self.is_booking_blocked = True
|
||||||
else:
|
else:
|
||||||
@@ -47,6 +51,7 @@ class SeatingPlanPage(Component):
|
|||||||
self.is_booking_blocked = True
|
self.is_booking_blocked = True
|
||||||
|
|
||||||
async def on_seat_clicked(self, seat_id: str, _: PressEvent) -> None:
|
async def on_seat_clicked(self, seat_id: str, _: PressEvent) -> None:
|
||||||
|
self.seating_info_text = ""
|
||||||
self.show_info_box = True
|
self.show_info_box = True
|
||||||
self.show_purchase_box = False
|
self.show_purchase_box = False
|
||||||
seat = next(filter(lambda s: s.seat_id == seat_id, self.seating_info), None)
|
seat = next(filter(lambda s: s.seat_id == seat_id, self.seating_info), None)
|
||||||
@@ -62,6 +67,12 @@ class SeatingPlanPage(Component):
|
|||||||
else:
|
else:
|
||||||
self.current_seat_occupant = None
|
self.current_seat_occupant = None
|
||||||
|
|
||||||
|
async def on_info_clicked(self, text: str) -> None:
|
||||||
|
self.show_info_box = True
|
||||||
|
self.show_purchase_box = False
|
||||||
|
self.current_seat_id = None
|
||||||
|
self.seating_info_text = text
|
||||||
|
|
||||||
def set_error(self, msg: str) -> None:
|
def set_error(self, msg: str) -> None:
|
||||||
self.purchase_box_error_msg = msg
|
self.purchase_box_error_msg = msg
|
||||||
self.purchase_box_success_msg = None
|
self.purchase_box_success_msg = None
|
||||||
@@ -119,7 +130,7 @@ class SeatingPlanPage(Component):
|
|||||||
Column(
|
Column(
|
||||||
SeatingPlanInfoBox(seat_id=self.current_seat_id, seat_occupant=self.current_seat_occupant, seat_price=self.current_seat_price,
|
SeatingPlanInfoBox(seat_id=self.current_seat_id, seat_occupant=self.current_seat_occupant, seat_price=self.current_seat_price,
|
||||||
is_blocked=self.current_seat_is_blocked, is_booking_blocked=self.is_booking_blocked, show=self.show_info_box,
|
is_blocked=self.current_seat_is_blocked, is_booking_blocked=self.is_booking_blocked, show=self.show_info_box,
|
||||||
purchase_cb=self.on_purchase_clicked),
|
purchase_cb=self.on_purchase_clicked, override_text=self.seating_info_text),
|
||||||
SeatingPurchaseBox(
|
SeatingPurchaseBox(
|
||||||
show=self.show_purchase_box,
|
show=self.show_purchase_box,
|
||||||
seat_id=self.current_seat_id,
|
seat_id=self.current_seat_id,
|
||||||
@@ -132,7 +143,7 @@ class SeatingPlanPage(Component):
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
MainViewContentBox(
|
MainViewContentBox(
|
||||||
SeatingPlan(seat_clicked_cb=self.on_seat_clicked, seating_info=self.seating_info) if self.seating_info else
|
SeatingPlan(seat_clicked_cb=self.on_seat_clicked, seating_info=self.seating_info, info_clicked_cb=self.on_info_clicked) if self.seating_info else
|
||||||
Column(ProgressCircle(color=self.session.theme.secondary_color, margin=3),
|
Column(ProgressCircle(color=self.session.theme.secondary_color, margin=3),
|
||||||
Text("Sitzplan wird geladen", style=TextStyle(fill=self.session.theme.neutral_color), align_x=0.5, margin=1))
|
Text("Sitzplan wird geladen", style=TextStyle(fill=self.session.theme.neutral_color), align_x=0.5, margin=1))
|
||||||
),
|
),
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from rio import Column, Component, event, TextStyle, Text
|
from rio import Column, Component, event, TextStyle, Text
|
||||||
|
|
||||||
from src.ez_lan_manager import ConfigurationService
|
from src.ezgg_lan_manager import ConfigurationService
|
||||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
|
||||||
|
|
||||||
class PAGENAME(Component):
|
class PAGENAME(Component):
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
from asyncio import sleep
|
||||||
|
|
||||||
|
from rio import event, ProgressCircle, PointerEventListener, PointerEvent, Popup, Color
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager import ConfigurationService
|
||||||
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
from src.ezgg_lan_manager.components.TeamRevealer import TeamRevealer
|
||||||
|
from src.ezgg_lan_manager.components.TeamsDialogHandler import *
|
||||||
|
from src.ezgg_lan_manager.services.RefreshService import RefreshService
|
||||||
|
from src.ezgg_lan_manager.services.TeamService import TeamService
|
||||||
|
from src.ezgg_lan_manager.services.UserService import UserService
|
||||||
|
from src.ezgg_lan_manager.types.Team import Team
|
||||||
|
from src.ezgg_lan_manager.types.User import User
|
||||||
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
|
|
||||||
|
class TeamsPage(Component):
|
||||||
|
all_teams: Optional[list[Team]] = None
|
||||||
|
user: Optional[User] = None
|
||||||
|
|
||||||
|
# Dialog handling
|
||||||
|
popup_open: bool = False
|
||||||
|
join_active: bool = False
|
||||||
|
leave_active: bool = True
|
||||||
|
create_active: bool = False
|
||||||
|
selected_team_for_join_or_leave: Optional[Team] = None
|
||||||
|
|
||||||
|
@event.on_populate
|
||||||
|
async def on_populate(self) -> None:
|
||||||
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Teams")
|
||||||
|
self.session[RefreshService].subscribe(self.on_populate)
|
||||||
|
self.all_teams = await self.session[TeamService].get_all_teams()
|
||||||
|
try:
|
||||||
|
self.user = await self.session[UserService].get_user(self.session[UserSession].user_id)
|
||||||
|
except KeyError:
|
||||||
|
self.user = None
|
||||||
|
|
||||||
|
async def on_join_button_pressed(self, team: Team) -> None:
|
||||||
|
if self.user is None:
|
||||||
|
return
|
||||||
|
self.selected_team_for_join_or_leave = team
|
||||||
|
self.join_active, self.leave_active, self.create_active = True, False, False
|
||||||
|
self.popup_open = True
|
||||||
|
|
||||||
|
async def on_leave_button_pressed(self, team: Team) -> None:
|
||||||
|
if self.user is None:
|
||||||
|
return
|
||||||
|
self.selected_team_for_join_or_leave = team
|
||||||
|
self.join_active, self.leave_active, self.create_active = False, True, False
|
||||||
|
self.popup_open = True
|
||||||
|
|
||||||
|
async def on_create_button_pressed(self, _: PointerEvent) -> None:
|
||||||
|
if self.user is None:
|
||||||
|
return
|
||||||
|
self.join_active, self.leave_active, self.create_active = False, False, True
|
||||||
|
self.popup_open = True
|
||||||
|
|
||||||
|
async def popup_action_cancelled(self) -> None:
|
||||||
|
self.popup_open = False
|
||||||
|
await sleep(0.2) # Waits for the animation to play before resetting its contents
|
||||||
|
self.join_active, self.leave_active, self.create_active = False, False, False
|
||||||
|
self.selected_team_for_join_or_leave = None
|
||||||
|
self.all_teams = await self.session[TeamService].get_all_teams()
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
if self.all_teams is None:
|
||||||
|
return Column(
|
||||||
|
MainViewContentBox(
|
||||||
|
ProgressCircle(
|
||||||
|
color="secondary",
|
||||||
|
align_x=0.5,
|
||||||
|
margin_top=1,
|
||||||
|
margin_bottom=1
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Spacer()
|
||||||
|
)
|
||||||
|
|
||||||
|
team_list = []
|
||||||
|
for team in self.all_teams:
|
||||||
|
team_list.append(
|
||||||
|
TeamRevealer(
|
||||||
|
user=self.user,
|
||||||
|
team=team,
|
||||||
|
mode="leave" if self.user in team.members.keys() else "join",
|
||||||
|
on_button_pressed=self.on_leave_button_pressed if self.user in team.members.keys() else self.on_join_button_pressed
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if team_list:
|
||||||
|
team_list[-1].margin_bottom = 1
|
||||||
|
|
||||||
|
own_teams_content = Spacer(grow_x=False, grow_y=False)
|
||||||
|
if self.user is not None:
|
||||||
|
user_team_list = []
|
||||||
|
for team in self.all_teams:
|
||||||
|
if self.user in team.members.keys():
|
||||||
|
user_team_list.append(TeamRevealer(user=self.user, team=team, mode="leave", on_button_pressed=self.on_leave_button_pressed))
|
||||||
|
|
||||||
|
if not user_team_list:
|
||||||
|
user_team_list.append(Text(
|
||||||
|
text="Du bist noch in keinem Team.",
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1
|
||||||
|
),
|
||||||
|
margin_top=1,
|
||||||
|
margin_bottom=1,
|
||||||
|
align_x=0.5
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
user_team_list[-1].margin_bottom = 1
|
||||||
|
own_teams_content = MainViewContentBox(
|
||||||
|
Column(
|
||||||
|
Row(
|
||||||
|
Text(
|
||||||
|
text="Deine Teams",
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1.2
|
||||||
|
),
|
||||||
|
grow_x=True,
|
||||||
|
justify="right",
|
||||||
|
margin_right=3
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
PointerEventListener(Rectangle(
|
||||||
|
content=Text(text="Team erstellen", style=TextStyle(fill=self.session.theme.background_color, font_size=0.7), margin=0.1, selectable=False),
|
||||||
|
stroke_width=0.1,
|
||||||
|
stroke_color=self.session.theme.hud_color,
|
||||||
|
cursor="pointer",
|
||||||
|
hover_fill=self.session.theme.hud_color,
|
||||||
|
transition_time=0
|
||||||
|
), on_press=self.on_create_button_pressed),
|
||||||
|
Spacer(),
|
||||||
|
margin_right=2
|
||||||
|
),
|
||||||
|
margin_top=1,
|
||||||
|
margin_bottom=1
|
||||||
|
),
|
||||||
|
*user_team_list
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return Popup(
|
||||||
|
anchor=Column(
|
||||||
|
own_teams_content,
|
||||||
|
MainViewContentBox(
|
||||||
|
Column(
|
||||||
|
Text(
|
||||||
|
text="Alle Teams",
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1.2
|
||||||
|
),
|
||||||
|
margin_top=1,
|
||||||
|
margin_bottom=1,
|
||||||
|
align_x=0.5
|
||||||
|
),
|
||||||
|
*team_list
|
||||||
|
)
|
||||||
|
),
|
||||||
|
align_y=0,
|
||||||
|
),
|
||||||
|
content=Column(
|
||||||
|
TeamsDialogJoinHandler(is_active=self.join_active, cancel=self.popup_action_cancelled, user=self.user, team=self.selected_team_for_join_or_leave),
|
||||||
|
TeamsDialogLeaveHandler(is_active=self.leave_active, cancel=self.popup_action_cancelled, user=self.user, team=self.selected_team_for_join_or_leave),
|
||||||
|
TeamsDialogCreateHandler(is_active=self.create_active, cancel=self.popup_action_cancelled, user=self.user)
|
||||||
|
),
|
||||||
|
is_open=self.popup_open,
|
||||||
|
modal=False,
|
||||||
|
corner_radius=(0.5, 0.5, 0.5, 0.5),
|
||||||
|
color=Color.TRANSPARENT,
|
||||||
|
user_closable=False,
|
||||||
|
position="top"
|
||||||
|
)
|
||||||
@@ -0,0 +1,394 @@
|
|||||||
|
import logging
|
||||||
|
from asyncio import sleep
|
||||||
|
from functools import partial
|
||||||
|
from typing import Optional, Union, Literal
|
||||||
|
|
||||||
|
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.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.User import User
|
||||||
|
from src.ezgg_lan_manager.types.UserSession import UserSession
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__.split(".")[-1])
|
||||||
|
|
||||||
|
|
||||||
|
class TournamentDetailsPage(Component):
|
||||||
|
tournament: Optional[Union[Tournament, str]] = None
|
||||||
|
rules_accepted: bool = False
|
||||||
|
user: Optional[User] = None
|
||||||
|
user_teams: list[Team] = []
|
||||||
|
loading: bool = False
|
||||||
|
participant_revealer_open: bool = False
|
||||||
|
current_tournament_user_or_team_list: Union[list[User], list[Team]] = []
|
||||||
|
team_dialog_open: bool = False
|
||||||
|
team_register_options: dict[str, Optional[Team]] = {"": None}
|
||||||
|
team_selected_for_register: Optional[Team] = None
|
||||||
|
|
||||||
|
# State for message above register button
|
||||||
|
message: str = ""
|
||||||
|
is_success: 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 self.tournament is not None:
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
self.user_teams = await self.session[TeamService].get_teams_for_user_by_id(user_id)
|
||||||
|
except KeyError:
|
||||||
|
self.user = None
|
||||||
|
self.user_teams = []
|
||||||
|
|
||||||
|
self.loading_done()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
async def artificial_delay() -> None:
|
||||||
|
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)
|
||||||
|
|
||||||
|
def open_close_participant_revealer(self, _: PointerEvent) -> None:
|
||||||
|
self.participant_revealer_open = not self.participant_revealer_open
|
||||||
|
|
||||||
|
async def register_pressed(self) -> None:
|
||||||
|
self.loading = True
|
||||||
|
if not self.user:
|
||||||
|
return
|
||||||
|
|
||||||
|
user_ticket = await self.session[TicketingService].get_user_ticket(self.user.user_id)
|
||||||
|
if user_ticket is None:
|
||||||
|
self.is_success = False
|
||||||
|
self.message = "Turnieranmeldung nur mit Ticket"
|
||||||
|
else:
|
||||||
|
# Register single player
|
||||||
|
if self.tournament.participant_type == ParticipantType.PLAYER:
|
||||||
|
try:
|
||||||
|
await self.session[TournamentService].register_user_for_tournament(self.user.user_id, self.tournament.id)
|
||||||
|
await self.artificial_delay()
|
||||||
|
self.is_success = True
|
||||||
|
self.message = f"Erfolgreich angemeldet!"
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(e)
|
||||||
|
self.is_success = False
|
||||||
|
self.message = f"Fehler: {e}"
|
||||||
|
# Register team
|
||||||
|
elif self.tournament.participant_type == ParticipantType.TEAM:
|
||||||
|
try:
|
||||||
|
team_register_options = {"": None}
|
||||||
|
for team in self.user_teams:
|
||||||
|
if team.members[self.user] == TeamStatus.OFFICER or team.members[self.user] == TeamStatus.LEADER:
|
||||||
|
team_register_options[team.name] = team
|
||||||
|
if team_register_options:
|
||||||
|
self.team_register_options = team_register_options
|
||||||
|
else:
|
||||||
|
self.team_register_options = {"": None}
|
||||||
|
except StopIteration as e:
|
||||||
|
logger.error(f"Error trying to teams to register: {e}")
|
||||||
|
self.team_dialog_open = True
|
||||||
|
return # Model should handle loading state now
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
await self.update()
|
||||||
|
self.loading = False
|
||||||
|
|
||||||
|
async def on_team_register_confirmed(self) -> None:
|
||||||
|
if self.team_selected_for_register is None:
|
||||||
|
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
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(e)
|
||||||
|
self.message = f"Fehler: {e}"
|
||||||
|
self.is_success = False
|
||||||
|
await self.update()
|
||||||
|
self.loading = False
|
||||||
|
|
||||||
|
async def on_team_register_canceled(self) -> None:
|
||||||
|
self.team_dialog_open = False
|
||||||
|
self.team_selected_for_register = None
|
||||||
|
self.loading = False
|
||||||
|
|
||||||
|
async def unregister_pressed(self, team: Optional[Team] = None) -> None:
|
||||||
|
self.loading = True
|
||||||
|
if not self.user:
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
if 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:
|
||||||
|
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:
|
||||||
|
raise PermissionError("Nur Leiter und Offiziere können das Team abmelden")
|
||||||
|
await self.artificial_delay()
|
||||||
|
self.is_success = True
|
||||||
|
self.message = f"Erfolgreich abgemeldet!"
|
||||||
|
except Exception as e:
|
||||||
|
self.is_success = False
|
||||||
|
self.message = f"Fehler: {e}"
|
||||||
|
await self.update()
|
||||||
|
self.loading = False
|
||||||
|
|
||||||
|
async def tree_button_clicked(self) -> None:
|
||||||
|
pass # ToDo: Implement tournament tree view
|
||||||
|
|
||||||
|
def loading_done(self) -> None:
|
||||||
|
if self.tournament is None:
|
||||||
|
self.tournament = "Turnier konnte nicht gefunden werden"
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
if self.tournament is None:
|
||||||
|
content = Column(
|
||||||
|
ProgressCircle(
|
||||||
|
color="secondary",
|
||||||
|
align_x=0.5,
|
||||||
|
margin_top=0,
|
||||||
|
margin_bottom=0
|
||||||
|
),
|
||||||
|
min_height=10
|
||||||
|
)
|
||||||
|
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:
|
||||||
|
tournament_status_color = self.session.theme.background_color
|
||||||
|
tree_button = Spacer(grow_x=False, grow_y=False)
|
||||||
|
if self.tournament.status == TournamentStatus.OPEN:
|
||||||
|
tournament_status_color = self.session.theme.success_color
|
||||||
|
elif self.tournament.status == TournamentStatus.CLOSED:
|
||||||
|
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
|
||||||
|
)
|
||||||
|
|
||||||
|
ids_of_participants = [p.id for p in self.tournament.participants]
|
||||||
|
color_key: Literal["hud", "danger"] = "hud"
|
||||||
|
on_press_function = self.register_pressed
|
||||||
|
if self.tournament.participant_type == ParticipantType.PLAYER:
|
||||||
|
self.current_tournament_user_or_team_list: list[User] # IDE TypeHint
|
||||||
|
participant_names = "\n".join([u.user_name for u in self.current_tournament_user_or_team_list])
|
||||||
|
if self.user and self.user.user_id in ids_of_participants: # User already registered for tournament
|
||||||
|
button_text = "Abmelden"
|
||||||
|
button_sensitive_hook = True # User has already accepted the rules previously
|
||||||
|
color_key = "danger"
|
||||||
|
on_press_function = self.unregister_pressed
|
||||||
|
elif self.user and self.user.user_id not in ids_of_participants:
|
||||||
|
button_text = "Anmelden"
|
||||||
|
button_sensitive_hook = self.rules_accepted
|
||||||
|
else:
|
||||||
|
# This should NEVER happen
|
||||||
|
button_text = "Anmelden"
|
||||||
|
button_sensitive_hook = False
|
||||||
|
elif self.tournament.participant_type == ParticipantType.TEAM:
|
||||||
|
self.current_tournament_user_or_team_list: list[Team] # IDE TypeHint
|
||||||
|
participant_names = "\n".join([t.name for t in self.current_tournament_user_or_team_list])
|
||||||
|
user_team_registered = []
|
||||||
|
for team in self.user_teams:
|
||||||
|
if team.id in ids_of_participants:
|
||||||
|
user_team_registered.append(team)
|
||||||
|
if self.user and len(user_team_registered) > 0: # Any of the users teams already registered for tournament
|
||||||
|
button_text = f"{user_team_registered[0].abbreviation} abmelden"
|
||||||
|
button_sensitive_hook = True # User has already accepted the rules previously
|
||||||
|
color_key = "danger"
|
||||||
|
on_press_function = partial(self.unregister_pressed, user_team_registered[0])
|
||||||
|
elif self.user and len(user_team_registered) == 0:
|
||||||
|
button_text = "Anmelden"
|
||||||
|
button_sensitive_hook = self.rules_accepted
|
||||||
|
else:
|
||||||
|
# This should NEVER happen
|
||||||
|
button_text = "Anmelden"
|
||||||
|
button_sensitive_hook = False
|
||||||
|
else:
|
||||||
|
logger.fatal("Did someone add new values to ParticipantType ? ;)")
|
||||||
|
return Column()
|
||||||
|
|
||||||
|
|
||||||
|
if self.tournament.status != TournamentStatus.OPEN or self.tournament.is_full:
|
||||||
|
button_sensitive_hook = False # Override button controls if tournament is not open anymore or full
|
||||||
|
|
||||||
|
if self.user:
|
||||||
|
accept_rules_row = Row(
|
||||||
|
ThemeContextSwitcher(content=Checkbox(is_on=self.bind().rules_accepted, margin_left=4), color=self.session.theme.hud_color),
|
||||||
|
Text("Ich akzeptiere die ", margin_left=1, style=TextStyle(fill=self.session.theme.background_color, font_size=0.8), overflow="nowrap", justify="right"),
|
||||||
|
Link(Text("Turnierregeln", margin_right=4, style=TextStyle(fill=self.session.theme.background_color, font_size=0.8, italic=True), overflow="nowrap", justify="left"), "./tournament-rules", open_in_new_tab=True)
|
||||||
|
)
|
||||||
|
button = Button(
|
||||||
|
content=button_text,
|
||||||
|
shape="rectangle",
|
||||||
|
style="major",
|
||||||
|
color=color_key,
|
||||||
|
margin_left=2,
|
||||||
|
margin_right=2,
|
||||||
|
is_sensitive=button_sensitive_hook,
|
||||||
|
on_press=on_press_function,
|
||||||
|
is_loading=self.loading
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# No UI here if user not logged in
|
||||||
|
accept_rules_row, button = Spacer(), Spacer()
|
||||||
|
|
||||||
|
content = Column(
|
||||||
|
Row(
|
||||||
|
Image(image=from_root(f"src/ezgg_lan_manager/assets/img/games/{self.tournament.game_title.image_name}"), margin_right=1),
|
||||||
|
Text(
|
||||||
|
text=self.tournament.name,
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1.2
|
||||||
|
),
|
||||||
|
margin_top=1,
|
||||||
|
margin_bottom=1,
|
||||||
|
align_x=0.5
|
||||||
|
),
|
||||||
|
margin_right=6,
|
||||||
|
margin_left=6
|
||||||
|
),
|
||||||
|
Spacer(min_height=1),
|
||||||
|
TournamentDetailsInfoRow("Status", tournament_status_to_display_text(self.tournament.status), value_color=tournament_status_color),
|
||||||
|
TournamentDetailsInfoRow("Startzeit", f"{weekday_to_display_text(self.tournament.start_time.weekday())}, {self.tournament.start_time.strftime('%H:%M')} Uhr"),
|
||||||
|
TournamentDetailsInfoRow("Format", tournament_format_to_display_texts(self.tournament.format)[0]),
|
||||||
|
TournamentDetailsInfoRow("Best of", tournament_format_to_display_texts(self.tournament.format)[1]),
|
||||||
|
PointerEventListener(
|
||||||
|
content=Rectangle(
|
||||||
|
content=TournamentDetailsInfoRow(
|
||||||
|
"Teilnehmer ▴" if self.participant_revealer_open else "Teilnehmer ▾",
|
||||||
|
f"{len(self.current_tournament_user_or_team_list)} / {self.tournament.max_participants}",
|
||||||
|
value_color=self.session.theme.danger_color if self.tournament.is_full else self.session.theme.background_color,
|
||||||
|
key_color=self.session.theme.secondary_color
|
||||||
|
),
|
||||||
|
fill=Color.TRANSPARENT,
|
||||||
|
cursor="pointer"
|
||||||
|
),
|
||||||
|
on_press=self.open_close_participant_revealer
|
||||||
|
),
|
||||||
|
Revealer(
|
||||||
|
header=None,
|
||||||
|
content=Text(
|
||||||
|
participant_names,
|
||||||
|
style=TextStyle(fill=self.session.theme.background_color)
|
||||||
|
),
|
||||||
|
is_open=self.participant_revealer_open,
|
||||||
|
margin_left=4,
|
||||||
|
margin_right=4
|
||||||
|
),
|
||||||
|
tree_button,
|
||||||
|
Row(
|
||||||
|
Text(
|
||||||
|
text="Info",
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1.2
|
||||||
|
),
|
||||||
|
margin_top=1,
|
||||||
|
margin_bottom=1,
|
||||||
|
align_x=0.5
|
||||||
|
)
|
||||||
|
),
|
||||||
|
# FixMe: Use rio.Markdown with correct TextStyle instead to allow basic text formatting from DB-side.
|
||||||
|
Text(self.tournament.description, margin_left=2, margin_right=2, style=TextStyle(fill=self.session.theme.background_color, font_size=1), overflow="wrap"),
|
||||||
|
Spacer(min_height=2),
|
||||||
|
accept_rules_row,
|
||||||
|
Spacer(min_height=0.5),
|
||||||
|
Text(self.message, margin_left=2, margin_right=2, style=TextStyle(fill=self.session.theme.success_color if self.is_success else self.session.theme.danger_color, font_size=1), overflow="wrap", justify="center"),
|
||||||
|
Spacer(min_height=0.5),
|
||||||
|
button
|
||||||
|
)
|
||||||
|
|
||||||
|
if self.tournament and self.tournament.participant_type == ParticipantType.TEAM:
|
||||||
|
content = Popup(
|
||||||
|
anchor=content,
|
||||||
|
content=Rectangle(
|
||||||
|
content=Column(
|
||||||
|
Text("Welches Team anmelden?", style=TextStyle(fill=self.session.theme.background_color, font_size=1.2), justify="center", margin_bottom=1),
|
||||||
|
ThemeContextSwitcher(
|
||||||
|
content=Dropdown(
|
||||||
|
options=self.team_register_options,
|
||||||
|
min_width=20,
|
||||||
|
selected_value=self.bind().team_selected_for_register
|
||||||
|
),
|
||||||
|
color=self.session.theme.hud_color,
|
||||||
|
margin_bottom=1
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
Button(content="Abbrechen", shape="rectangle", grow_x=False, on_press=self.on_team_register_canceled),
|
||||||
|
Button(content="Anmelden", shape="rectangle", grow_x=False, on_press=self.on_team_register_confirmed),
|
||||||
|
spacing=1
|
||||||
|
),
|
||||||
|
margin=0.5
|
||||||
|
),
|
||||||
|
min_width=30,
|
||||||
|
min_height=4,
|
||||||
|
fill=self.session.theme.primary_color,
|
||||||
|
margin_top=3.5,
|
||||||
|
stroke_width=0.3,
|
||||||
|
stroke_color=self.session.theme.neutral_color,
|
||||||
|
),
|
||||||
|
is_open=self.team_dialog_open,
|
||||||
|
color="none"
|
||||||
|
)
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
MainViewContentBox(
|
||||||
|
Column(
|
||||||
|
Spacer(min_height=1),
|
||||||
|
content,
|
||||||
|
Spacer(min_height=1)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
align_y=0
|
||||||
|
)
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
from rio import Column, Component, event, TextStyle, Text, Spacer
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager import ConfigurationService
|
||||||
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
|
||||||
|
RULES: list[str] = [
|
||||||
|
"Den Anweisungen der Turnierleitung ist stets Folge zu leisten.",
|
||||||
|
"Teilnehmer müssen aktiv dafür sorgen, dass Spiele ohne Verzögerungen stattfinden.",
|
||||||
|
"Unvollständige Teams werden ggf. zum Turnierstart entfernt.",
|
||||||
|
"Verzögerungen und Ausfälle sind er Turnierleitung sofort zu melden.",
|
||||||
|
"Jeder Spieler erstellt Screenshots am Rundenende zur Ergebnisdokumentation.",
|
||||||
|
"Der Verlierer trägt das Ergebnis ein, der Gewinner überprüft es.",
|
||||||
|
"Bei fehlendem oder falschem Ergebnis, ist sofort die Turnierorganisation zu informieren.",
|
||||||
|
"Von 02:00–11:00 Uhr besteht keine Spielpflicht",
|
||||||
|
"Täuschung, Falschangaben sowie Bugusing und Cheaten führen zur sofortigen Disqualifikation."
|
||||||
|
]
|
||||||
|
|
||||||
|
class TournamentRulesPage(Component):
|
||||||
|
@event.on_populate
|
||||||
|
async def on_populate(self) -> None:
|
||||||
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Turnierregeln")
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
return Column(
|
||||||
|
MainViewContentBox(
|
||||||
|
Column(
|
||||||
|
Text(
|
||||||
|
text="Turnierregeln",
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1.2
|
||||||
|
),
|
||||||
|
margin_top=2,
|
||||||
|
margin_bottom=2,
|
||||||
|
align_x=0.5
|
||||||
|
),
|
||||||
|
*[Text(
|
||||||
|
f"{idx + 1}. {rule}",
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=0.9
|
||||||
|
),
|
||||||
|
margin_bottom=0.8,
|
||||||
|
margin_left=1,
|
||||||
|
margin_right=1,
|
||||||
|
overflow="wrap"
|
||||||
|
) for idx, rule in enumerate(RULES)],
|
||||||
|
Spacer(min_height=1)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Spacer(grow_y=True)
|
||||||
|
)
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
from rio import Column, Component, event, TextStyle, Text, Spacer, ProgressCircle
|
||||||
|
|
||||||
|
from src.ezgg_lan_manager import ConfigurationService, TournamentService
|
||||||
|
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||||
|
from src.ezgg_lan_manager.components.TournamentPageRow import TournamentPageRow
|
||||||
|
from src.ezgg_lan_manager.types.Tournament import Tournament
|
||||||
|
|
||||||
|
|
||||||
|
class TournamentsPage(Component):
|
||||||
|
tournament_data: list[Tournament] = []
|
||||||
|
|
||||||
|
@event.on_populate
|
||||||
|
async def on_populate(self) -> None:
|
||||||
|
self.tournament_data = await self.session[TournamentService].get_tournaments()
|
||||||
|
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Turniere")
|
||||||
|
|
||||||
|
def tournament_clicked(self, tournament_id: int) -> None:
|
||||||
|
self.session.navigate_to(f"tournament?id={tournament_id}")
|
||||||
|
|
||||||
|
def build(self) -> Component:
|
||||||
|
tournament_page_rows = []
|
||||||
|
for tournament in self.tournament_data:
|
||||||
|
tournament_page_rows.append(
|
||||||
|
TournamentPageRow(
|
||||||
|
tournament.id,
|
||||||
|
tournament.name,
|
||||||
|
tournament.game_title.image_name,
|
||||||
|
len(tournament.participants),
|
||||||
|
tournament.max_participants,
|
||||||
|
tournament.status,
|
||||||
|
self.tournament_clicked
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if len(self.tournament_data) == 0:
|
||||||
|
content = [Column(
|
||||||
|
ProgressCircle(
|
||||||
|
color="secondary",
|
||||||
|
align_x=0.5,
|
||||||
|
margin_top=0,
|
||||||
|
margin_bottom=0
|
||||||
|
),
|
||||||
|
min_height=10
|
||||||
|
)]
|
||||||
|
else:
|
||||||
|
content = tournament_page_rows
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
MainViewContentBox(
|
||||||
|
Column(
|
||||||
|
Text(
|
||||||
|
text="Turniere",
|
||||||
|
style=TextStyle(
|
||||||
|
fill=self.session.theme.background_color,
|
||||||
|
font_size=1.2
|
||||||
|
),
|
||||||
|
margin_top=2,
|
||||||
|
margin_bottom=2,
|
||||||
|
align_x=0.5
|
||||||
|
),
|
||||||
|
*content,
|
||||||
|
Spacer(min_height=1)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
align_y=0
|
||||||
|
)
|
||||||
@@ -19,3 +19,9 @@ from .ManageNewsPage import ManageNewsPage
|
|||||||
from .ManageUsersPage import ManageUsersPage
|
from .ManageUsersPage import ManageUsersPage
|
||||||
from .ManageCateringPage import ManageCateringPage
|
from .ManageCateringPage import ManageCateringPage
|
||||||
from .ManageTournamentsPage import ManageTournamentsPage
|
from .ManageTournamentsPage import ManageTournamentsPage
|
||||||
|
from .OverviewPage import OverviewPage
|
||||||
|
from .TournamentDetailsPage import TournamentDetailsPage
|
||||||
|
from .TournamentRulesPage import TournamentRulesPage
|
||||||
|
from .ConwayPage import ConwayPage
|
||||||
|
from .TeamsPage import TeamsPage
|
||||||
|
from .AdminNavigationPage import AdminNavigationPage
|
||||||