Spaces:
Build error

0Mart00 commited on
Commit
4868bc6
·
1 Parent(s): a19cdb5

Remove deprecated old Python files from root directory

Browse files

Cleaning up:
- Removed main.py (replaced by src/wordgame/main.py)
- Removed database.py (replaced by src/wordgame/core/database.py)
- Removed room.py (replaced by src/wordgame/api/routes/room_routes.py)
- Removed gameChange.py (replaced by src/wordgame/api/routes/game_routes.py)
- Removed paddle.py (replaced by src/wordgame/api/routes/paddle_routes.py)
- Removed slang.py (replaced by src/wordgame/api/routes/slang_routes.py)
- Removed old features/ directory (replaced by src/wordgame/features/)
- Removed __pycache__/ directory

Note: Old files contained hardcoded Supabase credentials which are now properly managed via .env

Files changed (49) hide show
  1. __pycache__/database.cpython-314.pyc +0 -0
  2. __pycache__/main.cpython-314.pyc +0 -0
  3. __pycache__/room.cpython-314.pyc +0 -0
  4. __pycache__/roomFriend.cpython-314.pyc +0 -0
  5. database.py +0 -6
  6. features/__init__.py +0 -2
  7. features/__pycache__/__init__.cpython-314.pyc +0 -0
  8. features/user_dashboard/__init__.py +0 -4
  9. features/user_dashboard/__pycache__/__init__.cpython-314.pyc +0 -0
  10. features/user_dashboard/__pycache__/router.cpython-314.pyc +0 -0
  11. features/user_dashboard/repositories/__init__.py +0 -6
  12. features/user_dashboard/repositories/__pycache__/__init__.cpython-314.pyc +0 -0
  13. features/user_dashboard/repositories/__pycache__/deck_repo.cpython-314.pyc +0 -0
  14. features/user_dashboard/repositories/__pycache__/invite_repo.cpython-314.pyc +0 -0
  15. features/user_dashboard/repositories/__pycache__/subscription_repo.cpython-314.pyc +0 -0
  16. features/user_dashboard/repositories/deck_repo.py +0 -131
  17. features/user_dashboard/repositories/invite_repo.py +0 -122
  18. features/user_dashboard/repositories/subscription_repo.py +0 -66
  19. features/user_dashboard/router.py +0 -163
  20. features/user_dashboard/schemas/__init__.py +0 -10
  21. features/user_dashboard/schemas/__pycache__/__init__.cpython-314.pyc +0 -0
  22. features/user_dashboard/schemas/__pycache__/deck_schemas.cpython-314.pyc +0 -0
  23. features/user_dashboard/schemas/__pycache__/invite_schemas.cpython-314.pyc +0 -0
  24. features/user_dashboard/schemas/__pycache__/subscription_schemas.cpython-314.pyc +0 -0
  25. features/user_dashboard/schemas/deck_schemas.py +0 -36
  26. features/user_dashboard/schemas/invite_schemas.py +0 -31
  27. features/user_dashboard/schemas/subscription_schemas.py +0 -28
  28. features/user_dashboard/services/__init__.py +0 -6
  29. features/user_dashboard/services/__pycache__/__init__.cpython-314.pyc +0 -0
  30. features/user_dashboard/services/__pycache__/deck_service.cpython-314.pyc +0 -0
  31. features/user_dashboard/services/__pycache__/invite_service.cpython-314.pyc +0 -0
  32. features/user_dashboard/services/__pycache__/subscription_service.cpython-314.pyc +0 -0
  33. features/user_dashboard/services/deck_service.py +0 -161
  34. features/user_dashboard/services/invite_service.py +0 -178
  35. features/user_dashboard/services/subscription_service.py +0 -130
  36. features/user_dashboard/templates/dashboard.html +0 -261
  37. features/user_dashboard/utils/__init__.py +0 -10
  38. features/user_dashboard/utils/__pycache__/__init__.cpython-314.pyc +0 -0
  39. features/user_dashboard/utils/__pycache__/ai_prompt_builder.cpython-314.pyc +0 -0
  40. features/user_dashboard/utils/__pycache__/link_generator.cpython-314.pyc +0 -0
  41. features/user_dashboard/utils/__pycache__/validators.cpython-314.pyc +0 -0
  42. features/user_dashboard/utils/ai_prompt_builder.py +0 -80
  43. features/user_dashboard/utils/link_generator.py +0 -45
  44. features/user_dashboard/utils/validators.py +0 -84
  45. gameChange.py +0 -20
  46. main.py +0 -279
  47. paddle.py +0 -21
  48. room.py +0 -138
  49. slang.py +0 -49
__pycache__/database.cpython-314.pyc DELETED
Binary file (623 Bytes)
 
__pycache__/main.cpython-314.pyc DELETED
Binary file (19.3 kB)
 
__pycache__/room.cpython-314.pyc DELETED
Binary file (10.2 kB)
 
__pycache__/roomFriend.cpython-314.pyc DELETED
Binary file (10.2 kB)
 
database.py DELETED
@@ -1,6 +0,0 @@
1
- from supabase import Client, create_client
2
-
3
- SUPABASE_URL = "https://dihnaguoulqnhaamcnja.supabase.co"
4
- SUPABASE_KEY = "sb_publishable_U-EbpHE7lT98Wh6TM0oeug_v5G7uE1j"
5
-
6
- supabase: Client = create_client(SUPABASE_URL, SUPABASE_KEY)
 
 
 
 
 
 
 
features/__init__.py DELETED
@@ -1,2 +0,0 @@
1
- # Features package initialization
2
- __version__ = "1.0.0"
 
 
 
features/__pycache__/__init__.cpython-314.pyc DELETED
Binary file (165 Bytes)
 
features/user_dashboard/__init__.py DELETED
@@ -1,4 +0,0 @@
1
- """User Dashboard Feature Module"""
2
- from .router import router
3
-
4
- __all__ = ["router"]
 
 
 
 
 
features/user_dashboard/__pycache__/__init__.cpython-314.pyc DELETED
Binary file (255 Bytes)
 
features/user_dashboard/__pycache__/router.cpython-314.pyc DELETED
Binary file (10.6 kB)
 
features/user_dashboard/repositories/__init__.py DELETED
@@ -1,6 +0,0 @@
1
- """Repositories layer for user dashboard"""
2
- from .subscription_repo import SubscriptionRepo
3
- from .deck_repo import DeckRepo
4
- from .invite_repo import InviteRepo
5
-
6
- __all__ = ["SubscriptionRepo", "DeckRepo", "InviteRepo"]
 
 
 
 
 
 
 
features/user_dashboard/repositories/__pycache__/__init__.cpython-314.pyc DELETED
Binary file (407 Bytes)
 
features/user_dashboard/repositories/__pycache__/deck_repo.cpython-314.pyc DELETED
Binary file (6.35 kB)
 
features/user_dashboard/repositories/__pycache__/invite_repo.cpython-314.pyc DELETED
Binary file (6.04 kB)
 
features/user_dashboard/repositories/__pycache__/subscription_repo.cpython-314.pyc DELETED
Binary file (3.23 kB)
 
features/user_dashboard/repositories/deck_repo.py DELETED
@@ -1,131 +0,0 @@
1
- """Deck data access repository."""
2
- from datetime import datetime
3
- from typing import Dict, List, Optional
4
- from database import supabase
5
-
6
-
7
- class DeckRepo:
8
- """Repository for deck data operations."""
9
-
10
- TABLE_NAME = "paklik"
11
- WORDS_TABLE_NAME = "pakli_szavak"
12
-
13
- @staticmethod
14
- def create_deck(user_id: str, name: str, category: str, difficulty: Optional[str] = None) -> Optional[Dict]:
15
- """Create a new deck.
16
-
17
- Args:
18
- user_id: The user's UUID
19
- name: Deck name
20
- category: Word category
21
- difficulty: Difficulty level
22
-
23
- Returns:
24
- Created deck data or None
25
- """
26
- data = {
27
- "user_id": user_id,
28
- "nev": name,
29
- "kategoria": category,
30
- "nehezseg": difficulty or "medium",
31
- "letrehozva": datetime.now().isoformat()
32
- }
33
-
34
- response = supabase.table(DeckRepo.TABLE_NAME)\
35
- .insert(data)\
36
- .execute()
37
-
38
- if response.data:
39
- return response.data[0]
40
- return None
41
-
42
- @staticmethod
43
- def add_words(deck_id: str, words: List[str]) -> bool:
44
- """Add words to a deck.
45
-
46
- Args:
47
- deck_id: The deck's UUID
48
- words: List of words to add
49
-
50
- Returns:
51
- True if successful
52
- """
53
- for word in words:
54
- supabase.table(DeckRepo.WORDS_TABLE_NAME)\
55
- .insert({"pakli_id": deck_id, "szo": word.upper()})\
56
- .execute()
57
-
58
- return True
59
-
60
- @staticmethod
61
- def get_by_id(deck_id: str) -> Optional[Dict]:
62
- """Get deck by ID.
63
-
64
- Args:
65
- deck_id: The deck's UUID
66
-
67
- Returns:
68
- Deck data or None
69
- """
70
- response = supabase.table(DeckRepo.TABLE_NAME)\
71
- .select("*")\
72
- .eq("id", deck_id)\
73
- .execute()
74
-
75
- if response.data:
76
- return response.data[0]
77
- return None
78
-
79
- @staticmethod
80
- def get_words_by_deck(deck_id: str) -> List[str]:
81
- """Get all words for a deck.
82
-
83
- Args:
84
- deck_id: The deck's UUID
85
-
86
- Returns:
87
- List of words
88
- """
89
- response = supabase.table(DeckRepo.WORDS_TABLE_NAME)\
90
- .select("szo")\
91
- .eq("pakli_id", deck_id)\
92
- .execute()
93
-
94
- return [item["szo"] for item in response.data] if response.data else []
95
-
96
- @staticmethod
97
- def get_by_user(user_id: str, limit: int = 20) -> List[Dict]:
98
- """Get all decks for a user.
99
-
100
- Args:
101
- user_id: The user's UUID
102
- limit: Maximum number of decks to return
103
-
104
- Returns:
105
- List of deck data dicts
106
- """
107
- response = supabase.table(DeckRepo.TABLE_NAME)\
108
- .select("*")\
109
- .eq("user_id", user_id)\
110
- .order("letrehozva", desc=True)\
111
- .limit(limit)\
112
- .execute()
113
-
114
- return response.data if response.data else []
115
-
116
- @staticmethod
117
- def count_by_user(user_id: str) -> int:
118
- """Count total decks for a user.
119
-
120
- Args:
121
- user_id: The user's UUID
122
-
123
- Returns:
124
- Number of decks
125
- """
126
- response = supabase.table(DeckRepo.TABLE_NAME)\
127
- .select("id", count="exact")\
128
- .eq("user_id", user_id)\
129
- .execute()
130
-
131
- return response.count if response.count else 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/repositories/invite_repo.py DELETED
@@ -1,122 +0,0 @@
1
- """Invite data access repository."""
2
- from datetime import datetime, timedelta
3
- from typing import Dict, List, Optional
4
- from database import supabase
5
-
6
-
7
- class InviteRepo:
8
- """Repository for invite data operations."""
9
-
10
- TABLE_NAME = "meghivok"
11
-
12
- @staticmethod
13
- def create_invite(
14
- code: str,
15
- user_id: str,
16
- room_id: Optional[str] = None,
17
- expires_at: Optional[datetime] = None,
18
- max_uses: Optional[int] = None
19
- ) -> Optional[Dict]:
20
- """Create a new invite code.
21
-
22
- Args:
23
- code: Unique invite code
24
- user_id: Creator's user ID
25
- room_id: Optional room ID to join
26
- expires_at: Expiration datetime
27
- max_uses: Optional max uses
28
-
29
- Returns:
30
- Created invite data or None
31
- """
32
- data = {
33
- "kod": code,
34
- "letrehozo_id": user_id,
35
- "szoba_id": room_id,
36
- "lejart": expires_at.isoformat() if expires_at else None,
37
- "max_hasznalat": max_uses,
38
- "hasznalatok": 0,
39
- "letrehozva": datetime.now().isoformat()
40
- }
41
-
42
- response = supabase.table(InviteRepo.TABLE_NAME)\
43
- .insert(data)\
44
- .execute()
45
-
46
- if response.data:
47
- return response.data[0]
48
- return None
49
-
50
- @staticmethod
51
- def get_by_code(code: str) -> Optional[Dict]:
52
- """Get invite by code.
53
-
54
- Args:
55
- code: The invite code
56
-
57
- Returns:
58
- Invite data or None
59
- """
60
- response = supabase.table(InviteRepo.TABLE_NAME)\
61
- .select("*")\
62
- .eq("kod", code)\
63
- .execute()
64
-
65
- if response.data:
66
- return response.data[0]
67
- return None
68
-
69
- @staticmethod
70
- def increment_uses(code: str) -> bool:
71
- """Increment the use count for an invite.
72
-
73
- Args:
74
- code: The invite code
75
-
76
- Returns:
77
- True if successful
78
- """
79
- result = supabase.table(InviteRepo.TABLE_NAME)\
80
- .update({"hasznalatok": supabase.func.coalesce("hasznalatok", 0) + 1})\
81
- .eq("kod", code)\
82
- .execute()
83
-
84
- return result is not None
85
-
86
- @staticmethod
87
- def get_by_user(user_id: str, active_only: bool = True) -> List[Dict]:
88
- """Get all invites created by a user.
89
-
90
- Args:
91
- user_id: The user's UUID
92
- active_only: Only return active (non-expired) invites
93
-
94
- Returns:
95
- List of invite data dicts
96
- """
97
- query = supabase.table(InviteRepo.TABLE_NAME)\
98
- .select("*")\
99
- .eq("letrehozo_id", user_id)
100
-
101
- if active_only:
102
- query = query.gt("lejart", datetime.now().isoformat())
103
-
104
- response = query.order("letrehozva", desc=True).execute()
105
-
106
- return response.data if response.data else []
107
-
108
- @staticmethod
109
- def cleanup_expired() -> int:
110
- """Remove expired invites older than 7 days.
111
-
112
- Returns:
113
- Number of deleted records
114
- """
115
- cutoff = (datetime.now() - timedelta(days=7)).isoformat()
116
-
117
- result = supabase.table(InviteRepo.TABLE_NAME)\
118
- .delete()\
119
- .lt("lejart", cutoff)\
120
- .execute()
121
-
122
- return len(result.data) if result.data else 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/repositories/subscription_repo.py DELETED
@@ -1,66 +0,0 @@
1
- """Subscription data access repository."""
2
- from datetime import datetime
3
- from typing import Dict, Optional
4
- from database import supabase
5
-
6
-
7
- class SubscriptionRepo:
8
- """Repository for subscription data operations."""
9
-
10
- TABLE_NAME = "elofizetesek"
11
-
12
- @staticmethod
13
- def get_by_user_id(user_id: str) -> Optional[Dict]:
14
- """Fetch subscription by user ID.
15
-
16
- Args:
17
- user_id: The user's UUID
18
-
19
- Returns:
20
- Subscription data dict or None
21
- """
22
- response = supabase.table(SubscriptionRepo.TABLE_NAME)\
23
- .select("*")\
24
- .eq("user_id", user_id)\
25
- .execute()
26
-
27
- if response.data:
28
- return response.data[0]
29
- return None
30
-
31
- @staticmethod
32
- def get_user_profile(user_id: str) -> Optional[Dict]:
33
- """Fetch user profile (for is_premium flag).
34
-
35
- Args:
36
- user_id: The user's UUID
37
-
38
- Returns:
39
- Profile data dict or None
40
- """
41
- response = supabase.table("profilok")\
42
- .select("is_premium")\
43
- .eq("id", user_id)\
44
- .execute()
45
-
46
- if response.data:
47
- return response.data[0]
48
- return None
49
-
50
- @staticmethod
51
- def update_premium_status(user_id: str, is_premium: bool) -> bool:
52
- """Update user's premium status.
53
-
54
- Args:
55
- user_id: The user's UUID
56
- is_premium: New premium status
57
-
58
- Returns:
59
- True if successful
60
- """
61
- result = supabase.table("profilok")\
62
- .update({"is_premium": is_premium})\
63
- .eq("id", user_id)\
64
- .execute()
65
-
66
- return result is not None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/router.py DELETED
@@ -1,163 +0,0 @@
1
- """User Dashboard API Router."""
2
- from fastapi import APIRouter, Request, Cookie, HTTPException
3
- from fastapi.responses import HTMLResponse, JSONResponse
4
- from starlette.templating import Jinja2Templates
5
- from pydantic import ValidationError
6
-
7
- from .schemas.deck_schemas import DeckCreateRequest
8
- from .schemas.invite_schemas import InviteCreateRequest
9
- from .services.subscription_service import SubscriptionService
10
- from .services.deck_service import DeckService
11
- from .services.invite_service import InviteService
12
-
13
- router = APIRouter()
14
- templates = Jinja2Templates(directory="features/user_dashboard/templates")
15
-
16
-
17
- def get_user_id(request: Request, access_token: str = Cookie(None)) -> str:
18
- """Extract user ID from access token cookie."""
19
- if not access_token:
20
- raise HTTPException(status_code=401, detail="Bejelentkezés szükséges")
21
-
22
- try:
23
- from database import supabase
24
- user = supabase.auth.get_user(access_token)
25
- return user.user.id
26
- except Exception:
27
- raise HTTPException(status_code=401, detail="Érvénytelen munkamenet")
28
-
29
-
30
- def is_premium(user_id: str) -> bool:
31
- """Check if user has premium status."""
32
- from .repositories.subscription_repo import SubscriptionRepo
33
- profile = SubscriptionRepo.get_user_profile(user_id)
34
- return profile.get("is_premium", False) if profile else False
35
-
36
-
37
- # === Dashboard Pages ===
38
-
39
- @router.get("/dashboard", response_class=HTMLResponse)
40
- async def dashboard_page(request: Request, access_token: str = Cookie(None)):
41
- """Main dashboard page."""
42
- try:
43
- user_id = get_user_id(request, access_token)
44
- except HTTPException:
45
- return templates.TemplateResponse("base.html", {"request": request, "user": None})
46
-
47
- return templates.TemplateResponse("dashboard.html", {
48
- "request": request,
49
- "user_id": user_id
50
- })
51
-
52
-
53
- # === Subscription Endpoints ===
54
-
55
- @router.get("/dashboard/subscription", response_class=JSONResponse)
56
- async def get_subscription(access_token: str = Cookie(None)):
57
- """Get user's subscription status."""
58
- try:
59
- user_id = get_user_id(request=None, access_token=access_token)
60
- except HTTPException as e:
61
- return JSONResponse({"error": e.detail}, status_code=401)
62
-
63
- status = SubscriptionService.get_subscription_status(user_id)
64
- return JSONResponse(status.dict())
65
-
66
-
67
- @router.post("/dashboard/subscription/cancel", response_class=JSONResponse)
68
- async def cancel_subscription(access_token: str = Cookie(None)):
69
- """Cancel user's premium subscription."""
70
- try:
71
- user_id = get_user_id(request=None, access_token=access_token)
72
- except HTTPException as e:
73
- return JSONResponse({"error": e.detail}, status_code=401)
74
-
75
- result = SubscriptionService.cancel_subscription(user_id)
76
- return JSONResponse(result.dict())
77
-
78
-
79
- # === Deck Endpoints ===
80
-
81
- @router.post("/dashboard/deck", response_class=JSONResponse)
82
- async def create_deck(request: Request, access_token: str = Cookie(None)):
83
- """Create a new AI-generated deck."""
84
- try:
85
- user_id = get_user_id(request, access_token)
86
- except HTTPException as e:
87
- return JSONResponse({"error": e.detail}, status_code=401)
88
-
89
- try:
90
- body = await request.json()
91
- deck_request = DeckCreateRequest(**body)
92
- except ValidationError as e:
93
- return JSONResponse({"error": str(e)}, status_code=400)
94
-
95
- deck = DeckService.create_deck(user_id, deck_request, is_premium(user_id))
96
- if not deck:
97
- return JSONResponse({"error": "Nem sikerült létrehozni a paklit"}, status_code=500)
98
-
99
- return JSONResponse(deck.dict())
100
-
101
-
102
- @router.get("/dashboard/deck", response_class=JSONResponse)
103
- async def list_decks(access_token: str = Cookie(None)):
104
- """List all user's decks."""
105
- try:
106
- user_id = get_user_id(request=None, access_token=access_token)
107
- except HTTPException as e:
108
- return JSONResponse({"error": e.detail}, status_code=401)
109
-
110
- decks = DeckService.get_user_decks(user_id)
111
- return JSONResponse(decks.dict())
112
-
113
-
114
- @router.get("/dashboard/deck/{deck_id}", response_class=JSONResponse)
115
- async def get_deck(deck_id: str, access_token: str = Cookie(None)):
116
- """Get a specific deck."""
117
- deck = DeckService.get_deck(deck_id)
118
- if not deck:
119
- return JSONResponse({"error": "Pakli nem található"}, status_code=404)
120
-
121
- return JSONResponse(deck.dict())
122
-
123
-
124
- # === Invite Endpoints ===
125
-
126
- @router.post("/dashboard/invite", response_class=JSONResponse)
127
- async def create_invite(request: Request, access_token: str = Cookie(None)):
128
- """Create a new invite link."""
129
- try:
130
- user_id = get_user_id(request, access_token)
131
- except HTTPException as e:
132
- return JSONResponse({"error": e.detail}, status_code=401)
133
-
134
- try:
135
- body = await request.json()
136
- invite_request = InviteCreateRequest(**body)
137
- except ValidationError as e:
138
- return JSONResponse({"error": str(e)}, status_code=400)
139
-
140
- invite = InviteService.create_invite(user_id, invite_request)
141
- if not invite:
142
- return JSONResponse({"error": "Nem sikerült létrehozni a meghívót"}, status_code=500)
143
-
144
- return JSONResponse(invite.dict())
145
-
146
-
147
- @router.get("/dashboard/invite", response_class=JSONResponse)
148
- async def list_invites(access_token: str = Cookie(None)):
149
- """List all user's active invites."""
150
- try:
151
- user_id = get_user_id(request=None, access_token=access_token)
152
- except HTTPException as e:
153
- return JSONResponse({"error": e.detail}, status_code=401)
154
-
155
- invites = InviteService.get_user_invites(user_id)
156
- return JSONResponse([invite.dict() for invite in invites])
157
-
158
-
159
- @router.get("/dashboard/invite/{code}/validate", response_class=JSONResponse)
160
- async def validate_invite(code: str):
161
- """Validate an invite code."""
162
- result = InviteService.validate_invite(code)
163
- return JSONResponse(result.dict())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/schemas/__init__.py DELETED
@@ -1,10 +0,0 @@
1
- """Schemas layer for user dashboard"""
2
- from .subscription_schemas import SubscriptionResponse, UpgradeRequest
3
- from .deck_schemas import DeckCreateRequest, DeckResponse, DeckListResponse
4
- from .invite_schemas import InviteCreateRequest, InviteResponse, InviteValidateResponse
5
-
6
- __all__ = [
7
- "SubscriptionResponse", "UpgradeRequest",
8
- "DeckCreateRequest", "DeckResponse", "DeckListResponse",
9
- "InviteCreateRequest", "InviteResponse", "InviteValidateResponse"
10
- ]
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/schemas/__pycache__/__init__.cpython-314.pyc DELETED
Binary file (594 Bytes)
 
features/user_dashboard/schemas/__pycache__/deck_schemas.cpython-314.pyc DELETED
Binary file (3.23 kB)
 
features/user_dashboard/schemas/__pycache__/invite_schemas.cpython-314.pyc DELETED
Binary file (3.06 kB)
 
features/user_dashboard/schemas/__pycache__/subscription_schemas.cpython-314.pyc DELETED
Binary file (2.86 kB)
 
features/user_dashboard/schemas/deck_schemas.py DELETED
@@ -1,36 +0,0 @@
1
- """Deck data validation schemas."""
2
- from datetime import datetime
3
- from typing import Dict, List, Optional
4
- from pydantic import BaseModel, Field, validator
5
-
6
-
7
- class DeckCreateRequest(BaseModel):
8
- """Request model for creating a new AI-generated deck."""
9
- category: str = Field(..., description="Word category (szleng, matek, gamer)")
10
- difficulty: str = Field(default="medium", description="easy, medium, hard")
11
- word_count: int = Field(default=10, ge=5, le=50, description="Number of words (5-50)")
12
- ai_params: Optional[Dict] = Field(default=None, description="Custom AI parameters")
13
-
14
- @validator('category')
15
- def validate_category(cls, v):
16
- allowed = {"szleng", "matek", "gamer"}
17
- if v.lower() not in allowed:
18
- raise ValueError(f"Category must be one of: {allowed}")
19
- return v.lower()
20
-
21
-
22
- class DeckResponse(BaseModel):
23
- """Response model for a single deck."""
24
- id: str
25
- name: str
26
- category: str
27
- word_count: int
28
- words: List[str] = Field(default_factory=list)
29
- created_at: datetime
30
- difficulty: Optional[str] = None
31
-
32
-
33
- class DeckListResponse(BaseModel):
34
- """Response model for listing decks."""
35
- decks: List[DeckResponse] = Field(default_factory=list)
36
- total: int = 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/schemas/invite_schemas.py DELETED
@@ -1,31 +0,0 @@
1
- """Invite data validation schemas."""
2
- from datetime import datetime
3
- from typing import Optional
4
- from pydantic import BaseModel, Field
5
-
6
-
7
- class InviteCreateRequest(BaseModel):
8
- """Request model for creating an invite link."""
9
- room_id: Optional[str] = Field(None, description="Room ID to invite to")
10
- expires_in_hours: int = Field(default=24, ge=1, le=168, description="Expiration in hours (1-168)")
11
- max_uses: Optional[int] = Field(None, ge=1, le=100, description="Max uses (optional)")
12
-
13
-
14
- class InviteResponse(BaseModel):
15
- """Response model for a created invite."""
16
- code: str
17
- url: str
18
- expires_at: datetime
19
- max_uses: Optional[int] = None
20
- uses_remaining: Optional[int] = None
21
-
22
- class Config:
23
- json_encoders = {datetime: lambda v: v.isoformat() if v else None}
24
-
25
-
26
- class InviteValidateResponse(BaseModel):
27
- """Response model for invite validation."""
28
- valid: bool
29
- message: str
30
- room_info: Optional[dict] = None
31
- creator: Optional[str] = None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/schemas/subscription_schemas.py DELETED
@@ -1,28 +0,0 @@
1
- """Subscription data validation schemas."""
2
- from datetime import datetime
3
- from typing import Optional
4
- from pydantic import BaseModel, Field
5
-
6
-
7
- class SubscriptionResponse(BaseModel):
8
- """Response model for subscription status."""
9
- user_id: str
10
- status: str = Field(..., description="active, expired, trial, or none")
11
- tier: str = Field(..., description="free or premium")
12
- renewal_date: Optional[datetime] = None
13
- days_remaining: Optional[int] = None
14
-
15
- class Config:
16
- json_encoders = {datetime: lambda v: v.isoformat() if v else None}
17
-
18
-
19
- class UpgradeRequest(BaseModel):
20
- """Request model for upgrading subscription."""
21
- target_tier: str = Field(..., description="Target tier (premium)")
22
-
23
-
24
- class CancelSubscriptionResponse(BaseModel):
25
- """Response after cancellation."""
26
- success: bool
27
- message: str
28
- access_until: Optional[datetime] = None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/services/__init__.py DELETED
@@ -1,6 +0,0 @@
1
- """Services layer for user dashboard"""
2
- from .subscription_service import SubscriptionService
3
- from .deck_service import DeckService
4
- from .invite_service import InviteService
5
-
6
- __all__ = ["SubscriptionService", "DeckService", "InviteService"]
 
 
 
 
 
 
 
features/user_dashboard/services/__pycache__/__init__.cpython-314.pyc DELETED
Binary file (417 Bytes)
 
features/user_dashboard/services/__pycache__/deck_service.cpython-314.pyc DELETED
Binary file (6.98 kB)
 
features/user_dashboard/services/__pycache__/invite_service.cpython-314.pyc DELETED
Binary file (6.71 kB)
 
features/user_dashboard/services/__pycache__/subscription_service.cpython-314.pyc DELETED
Binary file (4.84 kB)
 
features/user_dashboard/services/deck_service.py DELETED
@@ -1,161 +0,0 @@
1
- """Deck generation business logic service."""
2
- import random
3
- from datetime import datetime
4
- from typing import Dict, List, Optional
5
-
6
- from ..repositories.deck_repo import DeckRepo
7
- from ..schemas.deck_schemas import DeckCreateRequest, DeckResponse, DeckListResponse
8
- from ..utils.ai_prompt_builder import build_deck_prompt, parse_ai_response
9
- from ..utils.validators import validate_user_id, validate_word_format
10
-
11
-
12
- class DeckService:
13
- """Service for AI deck generation business logic."""
14
-
15
- MAX_DECKS_FREE = 3
16
- MAX_DECKS_PREMIUM = 20
17
-
18
- @staticmethod
19
- def create_deck(
20
- user_id: str,
21
- request: DeckCreateRequest,
22
- is_premium: bool = False
23
- ) -> Optional[DeckResponse]:
24
- """Create a new AI-generated deck.
25
-
26
- Args:
27
- user_id: The user's UUID
28
- request: Deck creation request
29
- is_premium: Whether user is premium
30
-
31
- Returns:
32
- Created DeckResponse or None
33
- """
34
- is_valid, error = validate_user_id(user_id)
35
- if not is_valid:
36
- return None
37
-
38
- # Check deck limit
39
- deck_count = DeckRepo.count_by_user(user_id)
40
- max_decks = DeckService.MAX_DECKS_PREMIUM if is_premium else DeckService.MAX_DECKS_FREE
41
-
42
- if deck_count >= max_decks:
43
- return None
44
-
45
- # Generate deck name
46
- deck_name = f"{request.category.upper()} {datetime.now().strftime('%m.%d')}"
47
-
48
- # Create deck in database
49
- deck = DeckRepo.create_deck(
50
- user_id=user_id,
51
- name=deck_name,
52
- category=request.category,
53
- difficulty=request.difficulty
54
- )
55
-
56
- if not deck:
57
- return None
58
-
59
- # Generate words using AI (simulated for now)
60
- words = DeckService._generate_words(request)
61
-
62
- # Add words to deck
63
- if words:
64
- DeckRepo.add_words(deck["id"], words)
65
-
66
- return DeckResponse(
67
- id=deck["id"],
68
- name=deck_name,
69
- category=request.category,
70
- word_count=len(words),
71
- words=words,
72
- created_at=datetime.fromisoformat(deck["letrehozva"]) if deck.get("letrehozva") else datetime.now(),
73
- difficulty=request.difficulty
74
- )
75
-
76
- @staticmethod
77
- def get_deck(deck_id: str) -> Optional[DeckResponse]:
78
- """Get a deck by ID.
79
-
80
- Args:
81
- deck_id: The deck's UUID
82
-
83
- Returns:
84
- DeckResponse or None
85
- """
86
- deck = DeckRepo.get_by_id(deck_id)
87
- if not deck:
88
- return None
89
-
90
- words = DeckRepo.get_words_by_deck(deck_id)
91
-
92
- return DeckResponse(
93
- id=deck["id"],
94
- name=deck.get("nev", ""),
95
- category=deck.get("kategoria", ""),
96
- word_count=len(words),
97
- words=words,
98
- created_at=datetime.fromisoformat(deck["letrehozva"]) if deck.get("letrehozva") else datetime.now(),
99
- difficulty=deck.get("nehezseg")
100
- )
101
-
102
- @staticmethod
103
- def get_user_decks(user_id: str) -> DeckListResponse:
104
- """Get all decks for a user.
105
-
106
- Args:
107
- user_id: The user's UUID
108
-
109
- Returns:
110
- DeckListResponse with user's decks
111
- """
112
- decks = DeckRepo.get_by_user(user_id)
113
- total = DeckRepo.count_by_user(user_id)
114
-
115
- deck_responses = []
116
- for deck in decks:
117
- words = DeckRepo.get_words_by_deck(deck["id"])
118
- deck_responses.append(DeckResponse(
119
- id=deck["id"],
120
- name=deck.get("nev", ""),
121
- category=deck.get("kategoria", ""),
122
- word_count=len(words),
123
- words=words,
124
- created_at=datetime.fromisoformat(deck["letrehozva"]) if deck.get("letrehozva") else datetime.now(),
125
- difficulty=deck.get("nehezseg")
126
- ))
127
-
128
- return DeckListResponse(decks=deck_responses, total=total)
129
-
130
- @staticmethod
131
- def _generate_words(request: DeckCreateRequest) -> List[str]:
132
- """Generate words for a deck (simulated AI).
133
-
134
- In production, this would call an actual AI API.
135
- For now, it uses the prompt builder and returns sample words.
136
-
137
- Args:
138
- request: Deck creation request
139
-
140
- Returns:
141
- List of generated words
142
- """
143
- # Build AI prompt (for logging/future use)
144
- prompt = build_deck_prompt(
145
- category=request.category,
146
- difficulty=request.difficulty,
147
- word_count=request.word_count,
148
- custom_params=request.ai_params
149
- )
150
-
151
- # Simulated word generation based on category
152
- sample_words = {
153
- "szleng": ["CRING", "BASED", "VIBES", "SUSZE", "FAKEP", "SLAYY", "YEETZ", "BRUHS", "OKAY", "LMAOO"],
154
- "matek": ["PLUSZ", "MINUS", "OSZTO", "SZORO", "NÉGYZ", "GYÖKÖ", "TÖRT_", "TIZED", "EGÉSZ", "NULLA"],
155
- "gamer": ["NOOB_", "PROFI", "GANK_", "LOOT_", "QUEST", "BOSS_", "SKILL", "LEVEL", "XP___", "DROP_"]
156
- }
157
-
158
- words = sample_words.get(request.category, sample_words["szleng"])
159
-
160
- # Return requested number of words (or available)
161
- return words[:request.word_count]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/services/invite_service.py DELETED
@@ -1,178 +0,0 @@
1
- """Invite link business logic service."""
2
- from datetime import datetime, timedelta
3
- from typing import Dict, List, Optional
4
-
5
- from ..repositories.invite_repo import InviteRepo
6
- from ..schemas.invite_schemas import (
7
- InviteCreateRequest,
8
- InviteResponse,
9
- InviteValidateResponse
10
- )
11
- from ..utils.link_generator import generate_secure_code, build_invite_url, validate_code_format
12
- from ..utils.validators import validate_user_id, validate_invite_expiration
13
-
14
-
15
- class InviteService:
16
- """Service for invite link generation and validation."""
17
-
18
- DEFAULT_EXPIRY_HOURS = 24
19
- BASE_URL = "https://wordgame.example.com"
20
-
21
- @staticmethod
22
- def create_invite(
23
- user_id: str,
24
- request: InviteCreateRequest
25
- ) -> Optional[InviteResponse]:
26
- """Create a new invite link.
27
-
28
- Args:
29
- user_id: The user's UUID
30
- request: Invite creation request
31
-
32
- Returns:
33
- InviteResponse with invite details or None
34
- """
35
- is_valid, error = validate_user_id(user_id)
36
- if not is_valid:
37
- return None
38
-
39
- # Validate expiration
40
- is_valid, error = validate_invite_expiration(request.expires_in_hours)
41
- if not is_valid:
42
- return None
43
-
44
- # Generate unique code
45
- code = generate_secure_code(12)
46
-
47
- # Calculate expiration
48
- expires_at = datetime.now() + timedelta(hours=request.expires_in_hours)
49
-
50
- # Create invite in database
51
- invite = InviteRepo.create_invite(
52
- code=code,
53
- user_id=user_id,
54
- room_id=request.room_id,
55
- expires_at=expires_at,
56
- max_uses=request.max_uses
57
- )
58
-
59
- if not invite:
60
- return None
61
-
62
- return InviteResponse(
63
- code=code,
64
- url=build_invite_url(code, InviteService.BASE_URL),
65
- expires_at=expires_at,
66
- max_uses=request.max_uses,
67
- uses_remaining=request.max_uses
68
- )
69
-
70
- @staticmethod
71
- def validate_invite(code: str) -> InviteValidateResponse:
72
- """Validate an invite code.
73
-
74
- Args:
75
- code: The invite code to validate
76
-
77
- Returns:
78
- InviteValidateResponse with validation result
79
- """
80
- if not validate_code_format(code):
81
- return InviteValidateResponse(
82
- valid=False,
83
- message="Érvénytelen meghívó kód formátum"
84
- )
85
-
86
- invite = InviteRepo.get_by_code(code)
87
-
88
- if not invite:
89
- return InviteValidateResponse(
90
- valid=False,
91
- message="A meghívó kód nem található"
92
- )
93
-
94
- # Check expiration
95
- if invite.get("lejart"):
96
- try:
97
- expiry = datetime.fromisoformat(invite["lejart"])
98
- if datetime.now() > expiry:
99
- return InviteValidateResponse(
100
- valid=False,
101
- message="A meghívó kód lejárt"
102
- )
103
- except (ValueError, KeyError):
104
- pass
105
-
106
- # Check max uses
107
- max_uses = invite.get("max_hasznalat")
108
- uses = invite.get("hasznalatok", 0)
109
-
110
- if max_uses and uses >= max_uses:
111
- return InviteValidateResponse(
112
- valid=False,
113
- message="A meghívó kód felhasználásainak száma elérte a maximumot"
114
- )
115
-
116
- # Get room info if applicable
117
- room_info = None
118
- if invite.get("szoba_id"):
119
- room_info = {"room_id": invite["szoba_id"]}
120
-
121
- return InviteValidateResponse(
122
- valid=True,
123
- message="A meghívó kód érvényes",
124
- room_info=room_info,
125
- creator=invite.get("letrehozo_id", "")[:8] + "..."
126
- )
127
-
128
- @staticmethod
129
- def redeem_invite(code: str, redeemer_id: str) -> bool:
130
- """Redeem an invite code (increment use count).
131
-
132
- Args:
133
- code: The invite code
134
- redeemer_id: User redeeming the invite
135
-
136
- Returns:
137
- True if successful
138
- """
139
- validation = InviteService.validate_invite(code)
140
- if not validation.valid:
141
- return False
142
-
143
- return InviteRepo.increment_uses(code)
144
-
145
- @staticmethod
146
- def get_user_invites(user_id: str) -> List[InviteResponse]:
147
- """Get all active invites created by a user.
148
-
149
- Args:
150
- user_id: The user's UUID
151
-
152
- Returns:
153
- List of InviteResponse objects
154
- """
155
- invites = InviteRepo.get_by_user(user_id, active_only=True)
156
-
157
- responses = []
158
- for invite in invites:
159
- code = invite.get("kod", "")
160
- expires_at = None
161
- if invite.get("lejart"):
162
- try:
163
- expires_at = datetime.fromisoformat(invite["lejart"])
164
- except (ValueError, KeyError):
165
- pass
166
-
167
- max_uses = invite.get("max_hasznalat")
168
- uses = invite.get("hasznalatok", 0)
169
-
170
- responses.append(InviteResponse(
171
- code=code,
172
- url=build_invite_url(code, InviteService.BASE_URL),
173
- expires_at=expires_at,
174
- max_uses=max_uses,
175
- uses_remaining=(max_uses - uses) if max_uses else None
176
- ))
177
-
178
- return responses
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/services/subscription_service.py DELETED
@@ -1,130 +0,0 @@
1
- """Subscription business logic service."""
2
- from datetime import datetime, timedelta
3
- from typing import Dict, Optional
4
-
5
- from ..repositories.subscription_repo import SubscriptionRepo
6
- from ..schemas.subscription_schemas import SubscriptionResponse, CancelSubscriptionResponse
7
- from ..utils.validators import validate_user_id
8
-
9
-
10
- class SubscriptionService:
11
- """Service for subscription-related business logic."""
12
-
13
- TIER_NAMES = {"free": "Ingyenes", "premium": "Prémium"}
14
-
15
- @staticmethod
16
- def get_subscription_status(user_id: str) -> SubscriptionResponse:
17
- """Get user's subscription status.
18
-
19
- Args:
20
- user_id: The user's UUID
21
-
22
- Returns:
23
- SubscriptionResponse with current status
24
- """
25
- is_valid, error = validate_user_id(user_id)
26
- if not is_valid:
27
- return SubscriptionResponse(
28
- user_id="",
29
- status="none",
30
- tier="free"
31
- )
32
-
33
- # Check profile for premium status
34
- profile = SubscriptionRepo.get_user_profile(user_id)
35
- is_premium = profile.get("is_premium", False) if profile else False
36
-
37
- # Check for active subscription
38
- subscription = SubscriptionRepo.get_by_user_id(user_id)
39
-
40
- status = "none"
41
- renewal_date = None
42
- days_remaining = None
43
-
44
- if is_premium:
45
- status = "active"
46
- if subscription and subscription.get("lejart"):
47
- try:
48
- renewal_date = datetime.fromisoformat(subscription["lejart"])
49
- days_remaining = (renewal_date - datetime.now()).days
50
- except (ValueError, KeyError):
51
- pass
52
-
53
- return SubscriptionResponse(
54
- user_id=user_id,
55
- status=status,
56
- tier="premium" if is_premium else "free",
57
- renewal_date=renewal_date,
58
- days_remaining=days_remaining if days_remaining and days_remaining > 0 else None
59
- )
60
-
61
- @staticmethod
62
- def cancel_subscription(user_id: str) -> CancelSubscriptionResponse:
63
- """Cancel user's premium subscription.
64
-
65
- Args:
66
- user_id: The user's UUID
67
-
68
- Returns:
69
- CancelSubscriptionResponse with result
70
- """
71
- is_valid, error = validate_user_id(user_id)
72
- if not is_valid:
73
- return CancelSubscriptionResponse(
74
- success=False,
75
- message="Érvénytelen felhasználó ID"
76
- )
77
-
78
- # Get current subscription to find access end date
79
- subscription = SubscriptionRepo.get_by_user_id(user_id)
80
- access_until = None
81
-
82
- if subscription and subscription.get("lejart"):
83
- try:
84
- access_until = datetime.fromisoformat(subscription["lejart"])
85
- except (ValueError, KeyError):
86
- pass
87
-
88
- # In a real implementation, we would process the cancellation
89
- # For now, we just return success
90
- return CancelSubscriptionResponse(
91
- success=True,
92
- message="Előfizetés sikeresen lemondva. A prémium hozzáférés a lejáratig él.",
93
- access_until=access_until
94
- )
95
-
96
- @staticmethod
97
- def get_upgrade_options(user_id: str) -> Dict:
98
- """Get available upgrade options for user.
99
-
100
- Args:
101
- user_id: The user's UUID
102
-
103
- Returns:
104
- Dict with upgrade options
105
- """
106
- status = SubscriptionService.get_subscription_status(user_id)
107
-
108
- if status.tier == "premium":
109
- return {
110
- "can_upgrade": False,
111
- "message": "Már prémium tag vagy!",
112
- "current_benefits": [
113
- "Korlátlan szobaméret",
114
- "Egyedi ranglétra ikon",
115
- "5 extra kategória",
116
- "Hirdetésmentes élmény"
117
- ]
118
- }
119
-
120
- return {
121
- "can_upgrade": True,
122
- "message": "Válts prémiumra a teljes élményért!",
123
- "price": "1.490 Ft",
124
- "benefits": [
125
- "Korlátlan szobaméret",
126
- "Egyedi ranglétra ikon",
127
- "5 extra kategória",
128
- "Hirdetésmentes élmény"
129
- ]
130
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/templates/dashboard.html DELETED
@@ -1,261 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="hu" class="h-full bg-gray-900 text-white">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Felhasználói Irányítópult | Szó-Kavalkád</title>
7
- <script src="https://cdn.tailwindcss.com"></script>
8
- </head>
9
- <body class="flex flex-col h-full bg-gray-900 text-white font-sans">
10
- <header class="border-b border-gray-800 bg-gray-950 px-6 py-4 flex justify-between items-center">
11
- <h1 class="text-2xl font-black tracking-wider text-green-500">SZÓ-KAVALKÁD</h1>
12
- <a href="/" class="text-gray-400 hover:text-white transition text-sm">← Vissza a főoldalra</a>
13
- </header>
14
-
15
- <main class="flex-1 p-6 overflow-y-auto">
16
- <div class="max-w-6xl mx-auto">
17
- <h2 class="text-3xl font-bold mb-6 text-white">Felhasználói Irányítópult</h2>
18
-
19
- <!-- Dashboard Grid -->
20
- <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
21
- <!-- Subscription Card -->
22
- <div class="bg-gray-950 border border-gray-800 rounded-xl p-6 shadow-xl">
23
- <div class="flex items-center gap-3 mb-4">
24
- <span class="text-2xl">👑</span>
25
- <h3 class="text-lg font-bold text-amber-400">Előfizetés</h3>
26
- </div>
27
- <div id="subscription-status" class="text-gray-300">
28
- <p class="text-sm">Betöltés...</p>
29
- </div>
30
- </div>
31
-
32
- <!-- Decks Card -->
33
- <div class="bg-gray-950 border border-gray-800 rounded-xl p-6 shadow-xl">
34
- <div class="flex items-center gap-3 mb-4">
35
- <span class="text-2xl">🃏</span>
36
- <h3 class="text-lg font-bold text-blue-400">Saját Paklik</h3>
37
- </div>
38
- <div id="decks-summary" class="text-gray-300">
39
- <p class="text-sm">Betöltés...</p>
40
- </div>
41
- </div>
42
-
43
- <!-- Invites Card -->
44
- <div class="bg-gray-950 border border-gray-800 rounded-xl p-6 shadow-xl">
45
- <div class="flex items-center gap-3 mb-4">
46
- <span class="text-2xl">🔗</span>
47
- <h3 class="text-lg font-bold text-purple-400">Meghívók</h3>
48
- </div>
49
- <div id="invites-summary" class="text-gray-300">
50
- <p class="text-sm">Betöltés...</p>
51
- </div>
52
- </div>
53
- </div>
54
-
55
- <!-- Detailed Sections -->
56
- <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
57
- <!-- Deck Creator -->
58
- <div class="bg-gray-950 border border-gray-800 rounded-xl p-6 shadow-xl">
59
- <h3 class="text-xl font-bold text-blue-400 mb-4">Új Pakli Létrehozása</h3>
60
- <form id="deck-form" class="space-y-4">
61
- <div>
62
- <label class="block text-xs font-bold uppercase tracking-wider text-gray-400 mb-1">Kategória</label>
63
- <select name="category" class="w-full bg-gray-900 border border-gray-800 rounded-lg py-2.5 px-3 text-sm text-white focus:outline-none focus:border-blue-500">
64
- <option value="szleng">🔥 Szleng</option>
65
- <option value="matek">🔢 Matek</option>
66
- <option value="gamer">🎮 Gamer</option>
67
- </select>
68
- </div>
69
- <div>
70
- <label class="block text-xs font-bold uppercase tracking-wider text-gray-400 mb-1">Nehézség</label>
71
- <select name="difficulty" class="w-full bg-gray-900 border border-gray-800 rounded-lg py-2.5 px-3 text-sm text-white focus:outline-none focus:border-blue-500">
72
- <option value="easy">Könnyű</option>
73
- <option value="medium" selected>Közepes</option>
74
- <option value="hard">Nehéz</option>
75
- </select>
76
- </div>
77
- <div>
78
- <label class="block text-xs font-bold uppercase tracking-wider text-gray-400 mb-1">Szavak száma (5-50)</label>
79
- <input type="number" name="word_count" value="10" min="5" max="50" class="w-full bg-gray-900 border border-gray-800 rounded-lg py-2.5 px-3 text-sm text-white focus:outline-none focus:border-blue-500">
80
- </div>
81
- <button type="submit" class="w-full py-3 bg-blue-600 hover:bg-blue-500 font-bold rounded-lg text-sm uppercase tracking-wider transition cursor-pointer text-white border-0">
82
- Pakli létrehozása
83
- </button>
84
- </form>
85
- <div id="deck-result" class="mt-4"></div>
86
- </div>
87
-
88
- <!-- Invite Generator -->
89
- <div class="bg-gray-950 border border-gray-800 rounded-xl p-6 shadow-xl">
90
- <h3 class="text-xl font-bold text-purple-400 mb-4">Meghívó Link Generálása</h3>
91
- <form id="invite-form" class="space-y-4">
92
- <div>
93
- <label class="block text-xs font-bold uppercase tracking-wider text-gray-400 mb-1">Lejárat (óra)</label>
94
- <input type="number" name="expires_in_hours" value="24" min="1" max="168" class="w-full bg-gray-900 border border-gray-800 rounded-lg py-2.5 px-3 text-sm text-white focus:outline-none focus:border-purple-500">
95
- </div>
96
- <div>
97
- <label class="block text-xs font-bold uppercase tracking-wider text-gray-400 mb-1">Max felhasználás (opcionális)</label>
98
- <input type="number" name="max_uses" placeholder="Korlátlan" min="1" max="100" class="w-full bg-gray-900 border border-gray-800 rounded-lg py-2.5 px-3 text-sm text-white focus:outline-none focus:border-purple-500">
99
- </div>
100
- <button type="submit" class="w-full py-3 bg-purple-600 hover:bg-purple-500 font-bold rounded-lg text-sm uppercase tracking-wider transition cursor-pointer text-white border-0">
101
- Meghívó létrehozása
102
- </button>
103
- </form>
104
- <div id="invite-result" class="mt-4"></div>
105
- </div>
106
- </div>
107
- </div>
108
- </main>
109
-
110
- <script>
111
- // Load dashboard data on page load
112
- document.addEventListener('DOMContentLoaded', function() {
113
- loadSubscriptionStatus();
114
- loadDecksSummary();
115
- loadInvitesSummary();
116
- });
117
-
118
- // Subscription Status
119
- async function loadSubscriptionStatus() {
120
- try {
121
- const response = await fetch('/dashboard/subscription');
122
- const data = await response.json();
123
-
124
- const statusEl = document.getElementById('subscription-status');
125
- if (data.tier === 'premium') {
126
- statusEl.innerHTML = `
127
- <p class="text-lg font-bold text-amber-400">Prémium Tag</p>
128
- <p class="text-xs text-gray-500 mt-1">Napok hátra: ${data.days_remaining || '∞'}</p>
129
- `;
130
- } else {
131
- statusEl.innerHTML = `
132
- <p class="text-lg font-bold text-gray-400">Ingyenes</p>
133
- <a href="/premium" class="text-xs text-amber-400 hover:underline mt-1 inline-block">Prémiumra váltás →</a>
134
- `;
135
- }
136
- } catch (error) {
137
- console.error('Error loading subscription:', error);
138
- }
139
- }
140
-
141
- // Decks Summary
142
- async function loadDecksSummary() {
143
- try {
144
- const response = await fetch('/dashboard/deck');
145
- const data = await response.json();
146
-
147
- const summaryEl = document.getElementById('decks-summary');
148
- summaryEl.innerHTML = `
149
- <p class="text-3xl font-bold text-blue-400">${data.total}</p>
150
- <p class="text-xs text-gray-500 mt-1">pakli létrehozva</p>
151
- `;
152
- } catch (error) {
153
- console.error('Error loading decks:', error);
154
- }
155
- }
156
-
157
- // Invites Summary
158
- async function loadInvitesSummary() {
159
- try {
160
- const response = await fetch('/dashboard/invite');
161
- const data = await response.json();
162
-
163
- const summaryEl = document.getElementById('invites-summary');
164
- summaryEl.innerHTML = `
165
- <p class="text-3xl font-bold text-purple-400">${data.length}</p>
166
- <p class="text-xs text-gray-500 mt-1">aktív meghívó</p>
167
- `;
168
- } catch (error) {
169
- console.error('Error loading invites:', error);
170
- }
171
- }
172
-
173
- // Deck Form Submission
174
- document.getElementById('deck-form').addEventListener('submit', async function(e) {
175
- e.preventDefault();
176
-
177
- const formData = new FormData(this);
178
- const data = {
179
- category: formData.get('category'),
180
- difficulty: formData.get('difficulty'),
181
- word_count: parseInt(formData.get('word_count'))
182
- };
183
-
184
- try {
185
- const response = await fetch('/dashboard/deck', {
186
- method: 'POST',
187
- headers: { 'Content-Type': 'application/json' },
188
- body: JSON.stringify(data)
189
- });
190
-
191
- const result = await response.json();
192
- const resultEl = document.getElementById('deck-result');
193
-
194
- if (response.ok) {
195
- resultEl.innerHTML = `
196
- <div class="p-4 bg-green-900/40 border border-green-500/30 rounded text-center">
197
- <p class="text-green-400 font-bold">✅ Pakli létrehozva!</p>
198
- <p class="text-xs text-gray-400 mt-1">${result.word_count} szó a "${result.name}" pakliban</p>
199
- </div>
200
- `;
201
- } else {
202
- resultEl.innerHTML = `
203
- <div class="p-4 bg-red-900/40 border border-red-500/30 rounded text-center">
204
- <p class="text-red-400 font-bold">❌ Hiba: ${result.error}</p>
205
- </div>
206
- `;
207
- }
208
- } catch (error) {
209
- console.error('Error creating deck:', error);
210
- }
211
- });
212
-
213
- // Invite Form Submission
214
- document.getElementById('invite-form').addEventListener('submit', async function(e) {
215
- e.preventDefault();
216
-
217
- const formData = new FormData(this);
218
- const data = {
219
- expires_in_hours: parseInt(formData.get('expires_in_hours'))
220
- };
221
-
222
- const maxUses = formData.get('max_uses');
223
- if (maxUses) {
224
- data.max_uses = parseInt(maxUses);
225
- }
226
-
227
- try {
228
- const response = await fetch('/dashboard/invite', {
229
- method: 'POST',
230
- headers: { 'Content-Type': 'application/json' },
231
- body: JSON.stringify(data)
232
- });
233
-
234
- const result = await response.json();
235
- const resultEl = document.getElementById('invite-result');
236
-
237
- if (response.ok) {
238
- resultEl.innerHTML = `
239
- <div class="p-4 bg-purple-900/40 border border-purple-500/30 rounded">
240
- <p class="text-purple-400 font-bold mb-2">✅ Meghívó létrehozva!</p>
241
- <div class="flex items-center gap-2 bg-gray-900 p-2 rounded">
242
- <input type="text" readonly value="${result.url}" class="flex-1 bg-transparent text-xs text-gray-300 truncate">
243
- <button onclick="navigator.clipboard.writeText('${result.url}')" class="px-3 py-1 bg-purple-600 hover:bg-purple-500 rounded text-xs font-bold transition">Másol</button>
244
- </div>
245
- <p class="text-xs text-gray-500 mt-2">Lejár: ${new Date(result.expires_at).toLocaleString()}</p>
246
- </div>
247
- `;
248
- } else {
249
- resultEl.innerHTML = `
250
- <div class="p-4 bg-red-900/40 border border-red-500/30 rounded text-center">
251
- <p class="text-red-400 font-bold">❌ Hiba: ${result.error}</p>
252
- </div>
253
- `;
254
- }
255
- } catch (error) {
256
- console.error('Error creating invite:', error);
257
- }
258
- });
259
- </script>
260
- </body>
261
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/utils/__init__.py DELETED
@@ -1,10 +0,0 @@
1
- """Utilities layer for user dashboard"""
2
- from .link_generator import generate_secure_code, build_invite_url
3
- from .ai_prompt_builder import build_deck_prompt, parse_ai_response
4
- from .validators import validate_user_id, validate_word_format, validate_date_range
5
-
6
- __all__ = [
7
- "generate_secure_code", "build_invite_url",
8
- "build_deck_prompt", "parse_ai_response",
9
- "validate_user_id", "validate_word_format", "validate_date_range"
10
- ]
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/utils/__pycache__/__init__.cpython-314.pyc DELETED
Binary file (561 Bytes)
 
features/user_dashboard/utils/__pycache__/ai_prompt_builder.cpython-314.pyc DELETED
Binary file (3.52 kB)
 
features/user_dashboard/utils/__pycache__/link_generator.cpython-314.pyc DELETED
Binary file (2.79 kB)
 
features/user_dashboard/utils/__pycache__/validators.cpython-314.pyc DELETED
Binary file (3.53 kB)
 
features/user_dashboard/utils/ai_prompt_builder.py DELETED
@@ -1,80 +0,0 @@
1
- """AI prompt construction for deck generation."""
2
- from typing import Dict, List, Optional
3
-
4
-
5
- def build_deck_prompt(
6
- category: str,
7
- difficulty: str = "medium",
8
- word_count: int = 10,
9
- custom_params: Optional[Dict] = None
10
- ) -> str:
11
- """Build an AI prompt for generating word decks.
12
-
13
- Args:
14
- category: Word category (szleng, matek, gamer, etc.)
15
- difficulty: Difficulty level (easy, medium, hard)
16
- word_count: Number of words to generate
17
- custom_params: Additional parameters for AI
18
-
19
- Returns:
20
- Formatted AI prompt string
21
- """
22
- category_descriptions = {
23
- "szleng": "Hungarian slang expressions",
24
- "matek": "Mathematical terms and symbols",
25
- "gamer": "Gaming and geek culture terms"
26
- }
27
-
28
- difficulty_instructions = {
29
- "easy": "common, well-known words",
30
- "medium": "moderately challenging words",
31
- "hard": "obscure, expert-level terms"
32
- }
33
-
34
- category_desc = category_descriptions.get(category, f"{category} related words")
35
- difficulty_inst = difficulty_instructions.get(difficulty, difficulty_instructions["medium"])
36
-
37
- prompt = (
38
- f"Generate {word_count} unique 5-character words related to {category_desc}. "
39
- f"Use {difficulty_inst}. "
40
- f"Each word must be exactly 5 characters long, contain only letters, "
41
- f"and be valid Hungarian or English words."
42
- )
43
-
44
- if custom_params:
45
- for key, value in custom_params.items():
46
- prompt += f" {key}: {value}."
47
-
48
- return prompt
49
-
50
-
51
- def parse_ai_response(response_text: str) -> List[str]:
52
- """Parse AI response into a list of words.
53
-
54
- Args:
55
- response_text: Raw AI response text
56
-
57
- Returns:
58
- List of validated words
59
- """
60
- words = []
61
-
62
- # Try to extract words from common formats
63
- lines = response_text.strip().split('\n')
64
- for line in lines:
65
- # Remove numbering, bullets, commas
66
- cleaned = line.strip().strip('•-*').strip()
67
- if ',' in cleaned:
68
- parts = [p.strip() for p in cleaned.split(',')]
69
- words.extend(parts)
70
- elif cleaned:
71
- words.append(cleaned)
72
-
73
- # Filter valid 5-letter words
74
- valid_words = []
75
- for word in words:
76
- word = word.upper().strip()
77
- if len(word) == 5 and word.isalpha():
78
- valid_words.append(word)
79
-
80
- return list(set(valid_words)) # Remove duplicates
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/utils/link_generator.py DELETED
@@ -1,45 +0,0 @@
1
- """Secure link and code generation utilities."""
2
- import secrets
3
- import string
4
- from datetime import datetime, timedelta
5
- from typing import Optional
6
-
7
-
8
- def generate_secure_code(length: int = 12) -> str:
9
- """Generate a cryptographically secure URL-safe code.
10
-
11
- Args:
12
- length: Length of the generated code (default 12)
13
-
14
- Returns:
15
- A secure random code string
16
- """
17
- alphabet = string.ascii_letters + string.digits
18
- return ''.join(secrets.choice(alphabet) for _ in range(length))
19
-
20
-
21
- def build_invite_url(code: str, base_url: str = "https://wordgame.example.com") -> str:
22
- """Build a full invite URL from a code.
23
-
24
- Args:
25
- code: The invite code
26
- base_url: Base URL of the application
27
-
28
- Returns:
29
- Full invite URL
30
- """
31
- return f"{base_url}/invite/{code}"
32
-
33
-
34
- def validate_code_format(code: str) -> bool:
35
- """Validate invite code format.
36
-
37
- Args:
38
- code: Code to validate
39
-
40
- Returns:
41
- True if valid format, False otherwise
42
- """
43
- if not code or len(code) < 8:
44
- return False
45
- return all(c in string.ascii_letters + string.digits for c in code)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
features/user_dashboard/utils/validators.py DELETED
@@ -1,84 +0,0 @@
1
- """Shared validation utilities."""
2
- import re
3
- from datetime import datetime, timedelta
4
- from typing import Optional, Tuple
5
-
6
-
7
- def validate_user_id(user_id: str) -> Tuple[bool, Optional[str]]:
8
- """Validate a user ID format.
9
-
10
- Args:
11
- user_id: User ID to validate
12
-
13
- Returns:
14
- Tuple of (is_valid, error_message)
15
- """
16
- if not user_id:
17
- return False, "User ID is required"
18
- if not isinstance(user_id, str) or len(user_id) < 10:
19
- return False, "Invalid user ID format"
20
- return True, None
21
-
22
-
23
- def validate_word_format(word: str) -> Tuple[bool, Optional[str]]:
24
- """Validate a word format (5 letters only).
25
-
26
- Args:
27
- word: Word to validate
28
-
29
- Returns:
30
- Tuple of (is_valid, error_message)
31
- """
32
- if not word:
33
- return False, "Word cannot be empty"
34
- if len(word) != 5:
35
- return False, f"Word must be exactly 5 characters (got {len(word)})"
36
- if not word.isalpha():
37
- return False, "Word must contain only letters"
38
- return True, None
39
-
40
-
41
- def validate_date_range(
42
- start_date: Optional[datetime] = None,
43
- end_date: Optional[datetime] = None
44
- ) -> Tuple[bool, Optional[str]]:
45
- """Validate date range logic.
46
-
47
- Args:
48
- start_date: Start date (defaults to now)
49
- end_date: End date to validate
50
-
51
- Returns:
52
- Tuple of (is_valid, error_message)
53
- """
54
- if end_date is None:
55
- return True, None
56
-
57
- if start_date is None:
58
- start_date = datetime.now()
59
-
60
- if end_date <= start_date:
61
- return False, "End date must be after start date"
62
-
63
- # Max 1 year in the future
64
- max_date = start_date + timedelta(days=365)
65
- if end_date > max_date:
66
- return False, "End date cannot be more than 1 year in the future"
67
-
68
- return True, None
69
-
70
-
71
- def validate_invite_expiration(hours: int) -> Tuple[bool, Optional[str]]:
72
- """Validate invite expiration hours.
73
-
74
- Args:
75
- hours: Expiration time in hours
76
-
77
- Returns:
78
- Tuple of (is_valid, error_message)
79
- """
80
- if hours < 1:
81
- return False, "Expiration must be at least 1 hour"
82
- if hours > 168: # 1 week
83
- return False, "Expiration cannot exceed 1 week (168 hours)"
84
- return True, None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
gameChange.py DELETED
@@ -1,20 +0,0 @@
1
- from fastapi import Request, APIRouter
2
- from fastapi.responses import HTMLResponse
3
- from starlette.templating import Jinja2Templates
4
- from database import supabase
5
-
6
- router = APIRouter()
7
- templates = Jinja2Templates(directory="templates")
8
-
9
- @router.get("/jatek-valaszto", response_class=HTMLResponse)
10
- async def jatek_valaszto(request: Request):
11
- return templates.TemplateResponse(request=request, name="jatek-valaszto.html")
12
-
13
- @router.get("/jatek/{kategoria}", response_class=HTMLResponse)
14
- async def indit_jatek(request: Request, kategoria: str):
15
- # Szó lekérése adatbázisból (opcionális biztonsági ellenőrzés vagy előkészítés)
16
- response = supabase.table("szavak").select("szo").eq("kategoria", kategoria).execute()
17
-
18
- return ""
19
- ## SUPABASE give back the kategori btns
20
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
main.py DELETED
@@ -1,279 +0,0 @@
1
- import os
2
- import json
3
- # main.py felső importok közé:
4
-
5
- # Az app = FastAPI() deklaráció alá:
6
- from collections import Counter
7
- from fastapi import FastAPI, Request, Form, Header, HTTPException, Cookie, Response
8
- from fastapi.responses import HTMLResponse, RedirectResponse
9
- from starlette.templating import Jinja2Templates
10
- from database import supabase
11
-
12
- from room import router as room_router
13
- from slang import router as slang_router
14
- from gameChange import router as gameChange_router
15
- from paddle import router as paddle_router
16
- from features.user_dashboard import router as dashboard_router
17
-
18
-
19
- app = FastAPI()
20
- templates = Jinja2Templates(directory="templates")
21
- app.include_router(room_router)
22
- app.include_router(slang_router)
23
- app.include_router(paddle_router)
24
- app.include_router(gameChange_router)
25
- app.include_router(dashboard_router)
26
-
27
- KATEGORIA_NEVEK = {
28
- "szleng": "🔥 MAI SZLENG",
29
- "matek": "🔢 MATEK MOD",
30
- "gamer": "🎮 GAMER SPEC"
31
- }
32
-
33
-
34
-
35
- @app.get("/", response_class=HTMLResponse)
36
- async def index(request: Request, access_token: str = Cookie(None)):
37
- user = await get_current_user(access_token)
38
- return templates.TemplateResponse(
39
- request=request,
40
- name="base.html",
41
- context={"user": user}
42
- )
43
-
44
-
45
- @app.post("/ellenorzes", response_class=HTMLResponse)
46
- async def ellenoriz_tipp(request: Request, tipp: str = Form(...), sor: int = Form(...), kategoria: str = Form("szleng")):
47
- tipp = tipp.upper()
48
-
49
- # Dinamikus szólekérés a Supabase 'szavak' táblából
50
- response = supabase.table("szavak").select("szo").eq("kategoria", kategoria).execute()
51
- if response.data:
52
- megfejtes = response.data[0]["szo"].upper()
53
- else:
54
- megfejtes = "CRING" # Fallback ha üres a tábla
55
-
56
- n = len(megfejtes)
57
- if len(tipp) != n:
58
- return HTMLResponse(content="<div class='text-red-500 font-bold'>HIBA: Hibás karakterhossz!</div>")
59
-
60
- statuszok = ["szurke"] * n
61
- megfejtes_szamlalo = Counter(megfejtes)
62
-
63
- for i in range(n):
64
- if tipp[i] == megfejtes[i]:
65
- statuszok[i] = "zold"
66
- megfejtes_szamlalo[tipp[i]] -= 1
67
-
68
- for i in range(n):
69
- if statuszok[i] != "zold":
70
- if megfejtes_szamlalo.get(tipp[i], 0) > 0:
71
- statuszok[i] = "sarga"
72
- megfejtes_szamlalo[tipp[i]] -= 1
73
-
74
- grid_style = f'style="grid-template-columns: repeat({n}, minmax(0, 1fr));"'
75
- html_valasz = f'<div class="wordle-sor grid gap-2 w-full animate-bounce" {grid_style}>'
76
-
77
- for i in range(n):
78
- szin_class = "bg-gray-800 border-gray-900 text-gray-400"
79
- if statuszok[i] == "zold":
80
- szin_class = "bg-green-600 border-green-700 text-white scale-105"
81
- elif statuszok[i] == "sarga":
82
- szin_class = "bg-yellow-500 border-yellow-600 text-white"
83
-
84
- html_valasz += f'<div class="wordle-cella flex items-center justify-center text-2xl font-bold uppercase border-2 rounded select-none aspect-square {szin_class}">{tipp[i]}</div>'
85
- html_valasz += '</div>'
86
-
87
- if tipp == megfejtes:
88
- html_valasz += f"""
89
- <div hx-swap-oob="beforeend:#jatek-terulet">
90
- <div class="mt-4 p-4 bg-green-900/40 border border-green-500/30 rounded text-center w-full max-w-md">
91
- <p class="font-bold text-green-400 text-lg">🎉 GRATULÁLUNK! Sikerült!</p>
92
- <p class="text-xs text-gray-400 mt-1">Mentés a ranglétrára funkció hamarosan...</p>
93
- </div>
94
- </div>
95
- """
96
- return HTMLResponse(content=html_valasz)
97
-
98
- @app.get("/rangletra", response_class=HTMLResponse)
99
- async def rangletra(request: Request, kat: str = "szleng"):
100
- # Valódi adatok lekérése a Supabase 'rangletra' táblából
101
- # Rendezés: pontszám szerint csökkenő, idő szerint növekvő
102
- response = (
103
- supabase.table("rangletra")
104
- .select("username, pontszam, ido_masodperc, is_premium")
105
- .eq("kategoria", kat)
106
- .order("pontszam", descending=True)
107
- .order("ido_masodperc", descending=False)
108
- .execute()
109
- )
110
-
111
- # Adatok átalakítása a meglévő Jinja2 sablon struktúrájához (nev, ido, pont, is_premium)
112
- lista = []
113
- for item in response.data:
114
- lista.append({
115
- "nev": item.get("username"),
116
- "ido": item.get("ido_masodperc"),
117
- "pont": item.get("pontszam"),
118
- "is_premium": item.get("is_premium", False)
119
- })
120
-
121
- toplista_adatok = list(enumerate(lista, start=1))
122
-
123
- return templates.TemplateResponse(
124
- request=request,
125
- name="rangletra.html",
126
- context={"toplista": toplista_adatok}
127
- )
128
-
129
- @app.get("/premium", response_class=HTMLResponse)
130
- async def premium_oldal(request: Request):
131
- html_tartalom = """
132
- <div class="w-full max-w-md bg-gray-950 border border-amber-500/30 rounded-xl p-6 text-center shadow-2xl animate-fade-in mx-auto">
133
- <h2 class="text-3xl font-black text-amber-400 mb-2">�� Csatlakozz a Prémiumhoz</h2>
134
- <p class="text-gray-400 text-sm mb-6">Tüntesd el a hirdetéseket, kapj egy egyedi ikont a ranglétrán és nyiss ki +5 titkos kategóriát!</p>
135
- <div class="bg-gray-900 p-4 rounded-lg mb-6 border border-gray-800">
136
- <span class="text-xs uppercase font-bold tracking-wider text-amber-500">Egyszeri díj (Örök tagság)</span>
137
- <div class="text-3xl font-black text-white mt-1">1.490 Ft</div>
138
- </div>
139
- <button onclick="alert('Itt nyílna meg a Paddle fizetési kapu!')" class="w-full py-4 bg-gradient-to-r from-amber-500 via-yellow-500 to-amber-600 text-gray-950 font-black rounded-lg shadow-lg hover:brightness-110 active:scale-98 transition cursor-pointer uppercase tracking-wider text-sm">Vásárlás most</button>
140
- </div>
141
- """
142
- return HTMLResponse(content=html_tartalom)
143
-
144
- # BEJELENTKEZÉSI OLDAL (Lekéri a formot)
145
- @app.get("/login", response_class=HTMLResponse)
146
- async def login_page(request: Request):
147
- return templates.TemplateResponse(request=request, name="login.html")
148
-
149
- # REGISZTRÁCIÓS OLDAL (Lekéri a formot)
150
- @app.get("/register", response_class=HTMLResponse)
151
- async def register_page(request: Request):
152
- return templates.TemplateResponse(request=request, name="register.html")
153
-
154
- # REGISZTRÁCIÓ FELDOLGOZÁSA
155
- @app.post("/auth/register", response_class=HTMLResponse)
156
- async def auth_register(request: Request, email: str = Form(...), password: str = Form(...)):
157
- try:
158
- # Regisztráció a Supabase Auth-ba
159
- res = supabase.auth.sign_up({"email": email, "password": password})
160
-
161
- # Ha a Supabase-ben be van kapcsolva az email megerősítés, akkor szólni kell neki
162
- return HTMLResponse(content="""
163
- <div class="p-4 bg-green-900/40 border border-green-500/30 rounded text-center text-green-400">
164
- 🎉 Regisztráció sikeres! Ellenőrizd az email fiókodat a visszaigazoló linkért!
165
- <div class="mt-2"><button hx-get="/login" hx-target="#jatek-terulet" class="text-white underline font-bold">Ugrás a bejelentkezéshez</button></div>
166
- </div>
167
- """)
168
- except AuthApiError as e:
169
- return HTMLResponse(content=f"<div class='text-red-500 font-bold text-center p-2 bg-red-950/30 border border-red-500/30 rounded'>{e.message}</div>")
170
-
171
- # BEJELENTKEZÉS FELDOLGOZÁSA
172
- @app.post("/auth/login", response_class=HTMLResponse)
173
- async def auth_login(request: Request, response: Response, email: str = Form(...), password: str = Form(...)):
174
- try:
175
- # Hitelesítés Supabase-zel
176
- res = supabase.auth.sign_in_with_password({"email": email, "password": password})
177
-
178
- # Kivesszük az access tokent
179
- token = res.session.access_token
180
-
181
- # Beállítjuk a biztonságos HTTP-only cookie-t
182
- response = HTMLResponse(content="<script>window.location.reload();</script>")
183
- response.set_cookie(
184
- key="access_token",
185
- value=token,
186
- httponly=True,
187
- max_age=3600, # 1 óra
188
- expires=3600,
189
- samesite="lax",
190
- secure=False # Élesben (HTTPS) állítsd True-ra!
191
- )
192
- return response
193
- except AuthApiError as e:
194
- return HTMLResponse(content=f"<div class='text-red-500 font-bold text-center p-2 bg-red-950/30 border border-red-500/30 rounded'>{e.message}</div>")
195
-
196
- # KIJELENTKEZÉS
197
- @app.get("/auth/logout")
198
- async def auth_logout(response: Response):
199
- try:
200
- supabase.auth.sign_out()
201
- except:
202
- pass
203
- # Töröljük a cookie-t és frissítjük az oldalt
204
- response = RedirectResponse(url="/", status_code=303)
205
- response.delete_cookie(key="access_token")
206
- return response
207
-
208
- # ELFELEJTETT JELSZÓ OLDAL (Form lekérése)
209
- @app.get("/forgot-password", response_class=HTMLResponse)
210
- async def forgot_password_page(request: Request):
211
- return templates.TemplateResponse(request=request, name="forgot-password.html")
212
-
213
- # HELYREÁLLÍTÓ EMAIL KIKÜLDÉSE
214
- @app.post("/auth/forgot-password", response_class=HTMLResponse)
215
- async def auth_forgot_password(request: Request, email: str = Form(...)):
216
- try:
217
- # A Supabase küldi a Mailgunon át. A redirectTo az az URL, ahová a link kattintás után visz.
218
- supabase.auth.reset_password_email(
219
- email=email,
220
- options={"redirect_to": "http://127.0.0.1:8030/reset-password"}
221
- )
222
- return HTMLResponse(content="""
223
- <div class="p-4 bg-green-900/40 border border-green-500/30 rounded text-center text-green-400 text-sm">
224
- ✉️ Ha a megadott email cím létezik, kiküldtük a jelszó-visszaállító linket!
225
- </div>
226
- """)
227
- except AuthApiError as e:
228
- return HTMLResponse(content=f"<div class='text-red-500 font-bold text-center p-2 bg-red-950/30 border border-red-500/30 rounded text-sm'>{e.message}</div>")
229
-
230
- # ÚJ JELSZÓ MEGADÁSA OLDAL (Ide érkezik a felhasználó a mailből)
231
- @app.get("/reset-password", response_class=HTMLResponse)
232
- async def reset_password_page(request: Request):
233
- # Amikor a user a linkre kattint, a Supabase egy access_token-t (vagy #error-t) tesz az URL-be.
234
- # Ezt a base.html-nek és a formnak kell kezelnie.
235
- return templates.TemplateResponse(request=request, name="reset-password.html")
236
-
237
- # ÚJ JELSZÓ MENTÉSE
238
- @app.post("/auth/reset-password", response_class=HTMLResponse)
239
- async def auth_reset_password(request: Request, password: str = Form(...), access_token: str = Form(...)):
240
- try:
241
- # Frissítjük a jelszót az URL-ből kinyert token segítségével
242
- supabase.auth.update_user(
243
- {"password": password},
244
- options={"access_token": access_token}
245
- )
246
- return HTMLResponse(content="""
247
- <div class="p-4 bg-green-900/40 border border-green-500/30 rounded text-center text-green-400 text-sm">
248
- 🎉 A jelszavad sikeresen megváltozott!
249
- <div class="mt-2">
250
- <button hx-get="/login" hx-target="#jatek-terulet" class="text-white underline font-bold bg-transparent border-0 cursor-pointer">Ugrás a bejelentkezéshez</button>
251
- </div>
252
- </div>
253
- """)
254
- except AuthApiError as e:
255
- return HTMLResponse(content=f"<div class='text-red-500 font-bold text-center p-2 bg-red-950/30 border border-red-500/30 rounded text-sm'>{e.message}</div>")
256
-
257
- # Segédfüggvény az aktuális felhasználó lekéréséhez cookie-ból
258
- async def get_current_user(access_token: str = Cookie(None)):
259
- if not access_token:
260
- return None
261
- try:
262
- # Ellenőrizzük a tokent a Supabase-nél
263
- user_response = supabase.auth.get_user(access_token)
264
- return user_response.user
265
- except Exception:
266
- return None
267
-
268
- def ment_rangletra_pont(user_nev: str, elert_pont: int, ido: int, kategoria: str):
269
- data = {
270
- "username": user_nev,
271
- "pontszam": elert_pont,
272
- "ido_masodperc": ido,
273
- "kategoria": kategoria
274
- }
275
- supabase.table("rangletra").insert(data).execute()
276
-
277
- if __name__ == "__main__":
278
- import uvicorn
279
- uvicorn.run("main:app", host="127.0.0.1", port=8030, reload=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
paddle.py DELETED
@@ -1,21 +0,0 @@
1
- import json
2
-
3
- from fastapi import FastAPI, Request, Form, Header, HTTPException, Cookie, Response, APIRouter
4
- from database import supabase
5
-
6
- router = APIRouter()
7
-
8
- @router.post("/paddle-webhook")
9
- async def paddle_webhook(request: Request, paddle_signature: str = Header(None)):
10
- payload_raw = await request.body()
11
- payload = json.loads(payload_raw)
12
-
13
- event_type = payload.get("event_type")
14
-
15
- if event_type == "transaction.completed":
16
- user_id = payload["data"]["custom_data"].get("user_id")
17
- if user_id:
18
- supabase.table("profilok").update({"is_premium": True}).eq("id", user_id).execute()
19
- print(f"Felhasználó {user_id} sikeresen prémiumra váltott!")
20
-
21
- return {"status": "success"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
room.py DELETED
@@ -1,138 +0,0 @@
1
- import string
2
- import random
3
-
4
- from fastapi import Cookie, Form
5
- from fastapi import APIRouter, Request, Form, Cookie
6
- from fastapi.responses import HTMLResponse
7
- from database import supabase
8
-
9
- router = APIRouter()
10
-
11
- def generate_room_code():
12
- return ''.join(random.choices(string.ascii_uppercase + string.digits, k=6))
13
-
14
-
15
- # 1. SZOBA LÉTREHOZÁSA
16
- @router.post("/szoba/letrehozas", response_class=HTMLResponse)
17
- async def letrehoz_szoba(request: Request, access_token: str = Cookie(None)):
18
- if not access_token:
19
- return HTMLResponse(content="<div class='text-red-500 font-bold text-center p-3 bg-red-950/30 border border-red-500/30 rounded'>HIBA: Bejelentkezés szükséges!</div>", status_code=401)
20
-
21
- try:
22
- user_res = supabase.auth.get_user(access_token)
23
- user_id = user_res.user.id
24
- except Exception:
25
- return HTMLResponse(content="<div class='text-red-500 font-bold text-center p-3 bg-red-950/30 border border-red-500/30 rounded'>HIBA: Érvénytelen munkamenet!</div>", status_code=401)
26
-
27
- kod = generate_room_code()
28
-
29
- szoba_data = {"tulajdonos_id": str(user_id), "kod": kod}
30
- szoba_res = supabase.table("szobak").insert(szoba_data).execute()
31
-
32
- if not szoba_res.data:
33
- return HTMLResponse(content="<div class='text-red-500 font-bold text-center p-3 bg-red-950/30 border border-red-500/30 rounded'>HIBA: Adatbázis hiba történt!</div>", status_code=500)
34
-
35
- szoba_id = szoba_res.data[0]["id"]
36
-
37
- tag_data = {"szoba_id": szoba_id, "user_id": str(user_id)}
38
- supabase.table("szoba_tagok").insert(tag_data).execute()
39
-
40
- html_lobby = f"""
41
- <div class="w-full max-w-md bg-gray-950 border border-gray-800 rounded-xl p-6 text-center shadow-xl animate-fade-in mx-auto">
42
- <h3 class="text-xl font-black text-green-400 mb-2">VÁRÓTEREM (LOBBY)</h3>
43
- <p class="text-gray-400 text-sm mb-4">Oszd meg a kódot a barátaiddal:</p>
44
- <div class="bg-gray-900 border border-gray-800 rounded-lg py-3 text-2xl font-mono font-black tracking-widest text-white mb-6 select-all">
45
- {kod}
46
- </div>
47
- <div class="text-left border-t border-gray-900 pt-4">
48
- <h4 class="text-xs font-bold uppercase tracking-wider text-gray-500 mb-2">Csatlakozott tagok:</h4>
49
- <div id="lobby-tagok" hx-get="/szoba/statusz/{szoba_id}" hx-trigger="every 3s" class="flex flex-col gap-2 text-sm text-gray-300">
50
- <div class="p-2 bg-gray-900/50 rounded border border-gray-900 font-semibold text-green-400">👑 {str(user_id)[:8]}... (Tulajdonos)</div>
51
- </div>
52
- </div>
53
- </div>
54
- """
55
- return HTMLResponse(content=html_lobby)
56
-
57
- # 2. CSATLAKOZÁS SZOBAHÁZ
58
- @router.post("/szoba/csatlakozas", response_class=HTMLResponse)
59
- async def csatlakozik_szoba(request: Request, szoba_kod: str = Form(...), access_token: str = Cookie(None)):
60
- if not access_token:
61
- return HTMLResponse(content="<div class='text-red-500 font-bold text-center p-3 bg-red-950/30 border border-red-500/30 rounded'>HIBA: Bejelentkezés szükséges!</div>", status_code=401)
62
-
63
- try:
64
- user_res = supabase.auth.get_user(access_token)
65
- user_id = user_res.user.id
66
- except Exception:
67
- return HTMLResponse(content="<div class='text-red-500 font-bold text-center p-3 bg-red-950/30 border border-red-500/30 rounded'>HIBA: Érvénytelen munkamenet!</div>", status_code=401)
68
-
69
- szoba_res = supabase.table("szobak").select("id", "tulajdonos_id").eq("kod", szoba_kod.upper().strip()).execute()
70
- if not szoba_res.data:
71
- return HTMLResponse(content="<div class='text-red-500 font-bold text-sm bg-red-950/30 p-3 rounded border border-red-500/30 text-center'>HIBA: A megadott szobakód nem létezik!</div>")
72
-
73
- szoba = szoba_res.data[0]
74
- szoba_id = szoba["id"]
75
- tulajdonos_id = szoba["tulajdonos_id"]
76
-
77
- tagok_count_res = supabase.table("szoba_tagok").select("id").eq("szoba_id", szoba_id).execute()
78
- jelenlegi_tagok_szama = len(tagok_count_res.data) if tagok_count_res.data else 0
79
-
80
- if jelenlegi_tagok_szama >= 4:
81
- profil_res = supabase.table("profilok").select("is_premium").eq("id", tulajdonos_id).execute()
82
- is_premium = False
83
- if profil_res.data:
84
- is_premium = profil_res.data[0].get("is_premium", False)
85
-
86
- if not is_premium:
87
- return HTMLResponse(content="""
88
- <div class="p-4 bg-amber-950/40 border border-amber-500/30 rounded text-center text-amber-400 text-sm w-full max-w-md mx-auto">
89
- 👑 A szoba elérte a maximum 4 fős limitet! 4-nél több játékos fogadásához a szoba létrehozójának <strong>Prémium</strong> tagsággal kell rendelkeznie.
90
- </div>
91
- """)
92
-
93
- check_tag = supabase.table("szoba_tagok").select("id").eq("szoba_id", szoba_id).eq("user_id", str(user_id)).execute()
94
- if not check_tag.data:
95
- supabase.table("szoba_tagok").insert({"szoba_id": szoba_id, "user_id": str(user_id)}).execute()
96
-
97
- tagok_res = supabase.table("szoba_tagok").select("user_id").eq("szoba_id", szoba_id).execute()
98
-
99
- html_lobby = f"""
100
- <div class="w-full max-w-md bg-gray-950 border border-gray-800 rounded-xl p-6 text-center shadow-xl animate-fade-in mx-auto">
101
- <h3 class="text-xl font-black text-green-400 mb-2">VÁRÓTEREM (LOBBY)</h3>
102
- <p class="text-gray-400 text-sm mb-4">Sikeresen csatlakoztál a szobához!</p>
103
- <div class="bg-gray-900 border border-gray-800 rounded-lg py-3 text-2xl font-mono font-black tracking-widest text-white mb-6">
104
- {szoba_kod.upper().strip()}
105
- </div>
106
- <div class="text-left border-t border-gray-900 pt-4">
107
- <h4 class="text-xs font-bold uppercase tracking-wider text-gray-500 mb-2">Csatlakozott tagok:</h4>
108
- <div id="lobby-tagok" hx-get="/szoba/statusz/{szoba_id}" hx-trigger="every 3s" class="flex flex-col gap-2 text-sm text-gray-300">
109
- """
110
- for t in tagok_res.data:
111
- prefix = "👑 " if t["user_id"] == tulajdonos_id else "👤 "
112
- color = "text-green-400 font-semibold" if t["user_id"] == tulajdonos_id else "text-gray-300"
113
- html_lobby += f'<div class="p-2 bg-gray-900/50 rounded border border-gray-900 {color}">{prefix} {t["user_id"][:8]}...</div>'
114
-
115
- html_lobby += """
116
- </div>
117
- </div>
118
- </div>
119
- """
120
- return HTMLResponse(content=html_lobby)
121
-
122
- # 3. LOBBY STATUSZ POLLED VÉGPONT
123
- @router.get("/szoba/statusz/{szoba_id}", response_class=HTMLResponse)
124
- async def szoba_statusz(szoba_id: str):
125
- szoba_res = supabase.table("szobak").select("tulajdonos_id").eq("id", szoba_id).execute()
126
- if not szoba_res.data:
127
- return HTMLResponse(content="Szoba nem létezik", status_code=404)
128
-
129
- tulajdonos_id = szoba_res.data[0]["tulajdonos_id"]
130
- tagok_res = supabase.table("szoba_tagok").select("user_id").eq("szoba_id", szoba_id).execute()
131
-
132
- html_valasz = ""
133
- for t in tagok_res.data:
134
- prefix = "👑 " if t["user_id"] == tulajdonos_id else "👤 "
135
- color = "text-green-400 font-semibold" if t["user_id"] == tulajdonos_id else "text-gray-300"
136
- html_valasz += f'<div class="p-2 bg-gray-900/50 rounded border border-gray-900 {color}">{prefix} {t["user_id"][:8]}...</div>'
137
-
138
- return HTMLResponse(content=html_valasz)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
slang.py DELETED
@@ -1,49 +0,0 @@
1
- import httpx
2
- from fastapi import APIRouter
3
- from fastapi.responses import HTMLResponse
4
- from database import supabase
5
-
6
- router = APIRouter()
7
-
8
- SLANG_URL = "https://raw.githubusercontent.com/Ashpex/Slang-Word/refs/heads/master/slang.txt"
9
-
10
-
11
- @router.post("/szoba/import/szleng", response_class=HTMLResponse)
12
- async def import_szleng_kifejezesek():
13
- async with httpx.AsyncClient() as client:
14
- try:
15
- response = await client.get(SLANG_URL)
16
- response.raise_for_status()
17
- except Exception as e:
18
- return HTMLResponse(content=f"<div class='text-red-500 font-bold p-3 bg-red-950/30 border border-red-500/30 rounded text-sm'>Letöltési hiba: {str(e)}</div>", status_code=500)
19
-
20
- sorok = response.text.splitlines()
21
- szurt_szavak = set()
22
-
23
- for sor in sorok:
24
- if not sor.strip():
25
- continue
26
- reszek = sor.split("`")
27
- if reszek:
28
- nyers_szo = reszek[0].strip().upper()
29
- if len(nyers_szo) == 5 and nyers_szo.isalpha():
30
- szurt_szavak.add(nyers_szo)
31
-
32
- if not szurt_szavak:
33
- return HTMLResponse(content="<div class='text-amber-400 p-3 bg-amber-950/30 border border-amber-500/30 rounded text-sm'>Nem található megfelelő 5 betűs kifejezés.</div>")
34
-
35
- sikeres = 0
36
- # Csomagonkénti beszúrás a túlterhelés elkerülésére, hibák elnyomásával
37
- for szo in szurt_szavak:
38
- try:
39
- supabase.table("szavak").insert({"szo": szo, "kategoria": "szleng"}).execute()
40
- sikeres += 1
41
- except Exception:
42
- # Ha már létezik a szó, a Supabase hibát dob, amit itt átugrunk
43
- continue
44
-
45
- return HTMLResponse(content=f"""
46
- <div class="p-4 bg-green-900/40 border border-green-500/30 rounded text-center text-green-400 text-sm">
47
- 🎉 Szinkronizáció kész! {sikeres} új egyedi szleng rögzítve a 'szavak' táblában.
48
- </div>
49
- """)