forked from retoor/devplacepy
feat: add threaded comments with polymorphic targets and slug-based routing
Introduce `load_comments` helper supporting polymorphic target types (post, project, bug) with nested parent-child threading. Refactor comment creation to use `target_type`/`target_uid` and `resolve_target_redirect` for correct redirects. Replace raw UID-based post/project routes with slug-aware resolution via `resolve_post`/`resolve_project` and `make_combined_slug`. Update SEO, sitemap, and FAB styling to use slugs and hardcoded red accent. Add reusable `_comment_section.html` template.
This commit is contained in:
+9
-6
@@ -6,6 +6,11 @@ PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
||||
BASE_URL = "http://127.0.0.1:10501"
|
||||
SCREENSHOT_DIR = Path("/tmp/devplace_test_screenshots")
|
||||
|
||||
_TEST_DB = tempfile.NamedTemporaryFile(suffix=".db", delete=False)
|
||||
_TEST_DB.close()
|
||||
os.environ["DEVPLACE_DATABASE_URL"] = f"sqlite:///{_TEST_DB.name}"
|
||||
os.environ["SECRET_KEY"] = "test-secret-key"
|
||||
|
||||
|
||||
def save_failure_screenshot(page, test_name):
|
||||
SCREENSHOT_DIR.mkdir(parents=True, exist_ok=True)
|
||||
@@ -32,21 +37,19 @@ def pytest_runtest_makereport(item, call):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def test_db_path():
|
||||
tmp = tempfile.NamedTemporaryFile(suffix=".db", delete=False)
|
||||
tmp.close()
|
||||
yield tmp.name
|
||||
yield _TEST_DB.name
|
||||
try:
|
||||
os.unlink(tmp.name)
|
||||
os.unlink(_TEST_DB.name)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def app_server(test_db_path):
|
||||
env = os.environ.copy()
|
||||
env["DEVPLACE_DATABASE_URL"] = f"sqlite:///{test_db_path}"
|
||||
env["SECRET_KEY"] = "test-secret-key"
|
||||
env["PYTHONUNBUFFERED"] = "1"
|
||||
proc = subprocess.Popen(
|
||||
[sys.executable, "-m", "uvicorn", "devplacepy.main:app",
|
||||
|
||||
Reference in New Issue
Block a user