|
| 1 | +import os |
1 | 2 | import typing as tp |
2 | 3 | import uuid |
3 | 4 | from collections.abc import AsyncGenerator |
4 | 5 | from contextlib import asynccontextmanager |
5 | 6 |
|
| 7 | +os.environ["ADMIN_USER_MODEL"] = "User" |
| 8 | +os.environ["ADMIN_USER_MODEL_USERNAME_FIELD"] = "username" |
| 9 | +os.environ["ADMIN_SECRET_KEY"] = "secret" |
| 10 | + |
6 | 11 | from fastapi import FastAPI |
7 | 12 | from fastapi.middleware.cors import CORSMiddleware |
8 | 13 | from models import BaseEvent, Event, Tournament, User, db |
@@ -76,14 +81,9 @@ class BaseEventModelAdmin(PonyORMModelAdmin): |
76 | 81 | @register(Event) |
77 | 82 | class EventModelAdmin(PonyORMModelAdmin): |
78 | 83 | actions = ("make_is_active", "make_is_not_active") |
79 | | - list_display = ( |
80 | | - "id", |
81 | | - "name_with_price", |
82 | | - "rating", |
83 | | - "event_type", |
84 | | - "is_active", |
85 | | - "started", |
86 | | - ) |
| 84 | + list_display = ("id", "tournament", "name_with_price", "rating", "event_type", "is_active", "started") |
| 85 | + list_filter = ("tournament", "event_type", "is_active") |
| 86 | + search_fields = ("name", "tournament__name") |
87 | 87 |
|
88 | 88 | @action(description="Make event active") |
89 | 89 | @db_session |
@@ -115,7 +115,8 @@ def name_with_price(self, obj): |
115 | 115 |
|
116 | 116 |
|
117 | 117 | def init_db(): |
118 | | - db.bind(provider="sqlite", filename=":memory:", create_db=True) |
| 118 | + # Use shared in-memory sqlite DB so tables are visible across connections/threads. |
| 119 | + db.bind(provider="sqlite", filename=":sharedmemory:", create_db=True) |
119 | 120 | db.generate_mapping(create_tables=True) |
120 | 121 |
|
121 | 122 |
|
|
0 commit comments