From 14da622e5ecabc8404d5048baf0369bf5611d732 Mon Sep 17 00:00:00 2001 From: tylen Date: Tue, 5 May 2026 21:02:25 +0300 Subject: [PATCH] update for summer theme --- backend/src/db_client.py | 77 +++---------------- backend/src/user.py | 62 --------------- frontend/src/App.css | 18 ++--- frontend/src/App.tsx | 10 +-- frontend/src/components/CenteredConatiner.css | 2 +- frontend/src/components/Leafs.css | 38 +++++++++ .../components/{Snowflakes.tsx => Leafs.tsx} | 18 ++--- frontend/src/components/Loading.css | 4 +- frontend/src/components/Loading.tsx | 2 +- frontend/src/components/Snowflakes.css | 39 ---------- 10 files changed, 72 insertions(+), 198 deletions(-) create mode 100644 frontend/src/components/Leafs.css rename frontend/src/components/{Snowflakes.tsx => Leafs.tsx} (56%) delete mode 100644 frontend/src/components/Snowflakes.css diff --git a/backend/src/db_client.py b/backend/src/db_client.py index 051ede6..860f2b1 100644 --- a/backend/src/db_client.py +++ b/backend/src/db_client.py @@ -16,10 +16,10 @@ STARTUP_TABLE_CREATION_QUERIES = { Name varchar(255) );""", "hosting": """CREATE TABLE IF NOT EXISTS hosting ( - id SERIAL, - Name varchar(255), + id BIGINT AUTO_INCREMENT PRIMARY KEY, + Name VARCHAR(255), Capacity INT, - reservedBy varchar(255) + reservedBy VARCHAR(255) );""", "santa": """CREATE TABLE IF NOT EXISTS santa ( Name varchar(255), @@ -28,19 +28,13 @@ STARTUP_TABLE_CREATION_QUERIES = { } INJECT_TABLE_CREATION_QUERIES = { - "hosting": """ -INSERT INTO hosting (Name, Capacity, reservedBy) -SELECT name, capacity, reservedBy FROM ( - SELECT 'Матрац 160см' AS name, 2 AS capacity, '' AS reservedBy - UNION ALL - SELECT 'Кровать 120см', 2, '' - UNION ALL - SELECT 'Матрац 90см', 1, '' - UNION ALL - SELECT 'Диван', 1, '' -) AS temp -WHERE NOT EXISTS (SELECT 1 FROM hosting WHERE Name = temp.name); -""", +"hosting": """ +INSERT IGNORE INTO hosting (Name, Capacity, reservedBy) VALUES +('Матрац 160cм', 2, ''), +('Кровать 120cм', 2, ''), +('Матрац 90cм', 1, ''), +('Диван', 1, ''); +""" } class Severity(Enum): @@ -61,7 +55,6 @@ class DBClient: self.pool = self.create_pool() # Create a connection pool self.initialize_database() - #self.initialize_secret_santa() # Initialize Secret Santa def validate_env_variables(self): if not self.db_server or not self.db_port or not self.password or not self.database: @@ -84,56 +77,6 @@ class DBClient: self.query(STARTUP_TABLE_CREATION_QUERIES['sessions']) self.query(STARTUP_TABLE_CREATION_QUERIES['hosting']) self.query(INJECT_TABLE_CREATION_QUERIES['hosting']) - - def initialize_secret_santa(self): - table_exists = self.query("SHOW TABLES LIKE 'santa';") - - if not table_exists: - self.query(STARTUP_TABLE_CREATION_QUERIES['santa']) - - count_query = self.query('SELECT COUNT(*) FROM santa;') - if count_query[0][0] > 0: - self.app.logger.warning('The santa table is not empty. No assignments will be made.') - return - - attendees = self.query('SELECT Name FROM users WHERE Attendance = 1;') - - if not attendees: - return - - attendees = [user[0] for user in attendees] - couples = [("Тюлень", "Тюлениха"), ("Медведь", "Ксения")] - - max_attempts = 1000 - - for attempt in range(max_attempts): - shuffled_attendees = attendees.copy() - random.shuffle(shuffled_attendees) - - santa_assignments = {} - valid = True - - for index, user in enumerate(shuffled_attendees): - prev_user = shuffled_attendees[index - 1] - next_user = shuffled_attendees[(index + 1) % len(shuffled_attendees)] - - if any(user in couple and (prev_user in couple or next_user in couple) for couple in couples): - valid = False - break - - santa_assignments[user] = prev_user - - if valid: - break - - else: - self.app.logger.warning('Could not find valid Santa assignments after multiple attempts.') - return - - self.app.logger.info(f'Santa assignments: {santa_assignments}') - - for user, santa in santa_assignments.items(): - self.query('INSERT INTO santa (Name, Santa) VALUES (%s, %s);', (user, santa)) def query(self, query_str, params=None): diff --git a/backend/src/user.py b/backend/src/user.py index 5b5e555..1b338ae 100644 --- a/backend/src/user.py +++ b/backend/src/user.py @@ -164,65 +164,3 @@ def registerUserEndpoints(app, database): except Exception as e: return jsonify(success=False, message=str(e)), 500 - - - @app.route('/users/wishlist', methods=['PUT']) - def update_wishlist(): - data = request.json - token = data.get('token') - wishlist_url = data.get('wishlist') - - if wishlist_url is None: - return jsonify(success=False, message="Wishlist URL is required"), 400 - - query_session = "SELECT * FROM sessions WHERE Token=%s" - try: - result = database.query(query_session, params=(token,)) - if not result: - return jsonify(success=False, message="Token is invalid or expired"), 401 - - user_name = result[0][1] - wishlist_query = "UPDATE users SET WishListUrl = %s WHERE Name = %s" - update_result = database.query(wishlist_query, params=(wishlist_url, user_name)) - - return jsonify(success=True, message="WishListUrl updated successfully"), 200 - - except Exception as e: - return jsonify(success=False, message=str(e)), 500 - - @app.route('/users/santa', methods=['GET']) - def get_santainfo(): - token = request.args.get('token') - - if not token: - return jsonify(success=False, message="Token is required"), 400 - - query_session = "SELECT * FROM sessions WHERE Token=%s" - - try: - result = database.query(query_session, params=(token,)) - if not result: - return jsonify(success=False, message="Token is invalid or expired"), 401 - - user_name = result[0][1] - - santa_query = "SELECT Name FROM santa WHERE Santa = %s" - santa_result = database.query(santa_query, params=(user_name,)) - - if not santa_result: - return jsonify(success=False, message=f"User's {user_name} Santa info not found"), 404 - - santa_to = santa_result[0][0] - - wishlist_query = "SELECT WishListUrl FROM users WHERE Name = %s" - wishlist_result = database.query(wishlist_query, params=(santa_to,)) - - santa_info = { - "santa_to": santa_to, - "wishlist": wishlist_result[0][0] - } - - return jsonify(success=True, santa_info=santa_info), 200 - - except Exception as e: - return jsonify(success=False, message=str(e)), 500 diff --git a/frontend/src/App.css b/frontend/src/App.css index 9bbba9d..ee506af 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -42,7 +42,7 @@ body { background-color: #ffffff; /* Light background for contrast */ - background-image: url('./assets/snowflakes.png'); + background-image: url('./assets/leafs.png'); /* Background image */ background-size: cover; /* Cover the entire screen */ @@ -114,7 +114,7 @@ section { /* Festive Buttons */ button { - background-color: #b77de5; + background-color: #b5bb08; /* Purple with a slight festive flair */ color: white; border: none; @@ -126,7 +126,7 @@ button { } button:hover { - background-color: #9b6bb5; + background-color: #48844e; /* Darker purple on hover */ } @@ -177,7 +177,7 @@ table { /* Table header styles */ th { - background-color: #060698; + background-color: #06984a; /* Christmas red */ color: white; padding: 10px 15px; @@ -218,7 +218,7 @@ table { /* Add some festive decorations */ th::after { - content: '🎄'; + content: '🌳'; /* Small Christmas tree icon in the header */ margin-left: 10px; font-size: 1.2em; @@ -234,8 +234,8 @@ td::before { content: ''; /* Placeholder for decoration */ position: absolute; - background-image: url('path/to/snowflake-icon.png'); - /* Snowflake icon */ + background-image: url('path/to/leaf-icon.png'); + /* leaf icon */ width: 16px; /* Adjust as necessary */ height: 16px; @@ -250,7 +250,7 @@ td::before { nav { top: 0; /* Align it to the top */ - background-color: rgba(0, 42, 255, 0.6);; /* Background color */ + background-color: #06984aef; /* Background color */ border-radius: 20px; z-index: 1000; /* Make sure it stays above other content */ padding: 1rem; @@ -293,7 +293,7 @@ nav a:hover { @media (max-width: 768px) { .nav-toggle { display: block; - background-color: rgba(0, 42, 255, 0.6); /* Button color */ + background-color: rgba(255, 255, 0, 0.6); /* Button color */ border: none; padding: 10px 20px; cursor: pointer; diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index c902488..52b5f87 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -4,7 +4,7 @@ import Greeting from './components/Greeting'; import Hosting from './components/Hosting'; import InitialSetup from './components/InitialSetup'; import Program from './components/Program'; -import Snowflakes from './components/Snowflakes'; +import Leafs from './components/Leafs'; import { FullScreenLoading } from './components/Loading'; import SecretSanta from './components/SecretSanta'; import Suggestions from './components/Suggestions'; @@ -31,7 +31,7 @@ function App() { return ( <> - +