forked from retoor/devplacepy
docs: document DEVPLACE_DISABLE_SERVICES env var, news router, modal class toggle, and news service behavior
This commit is contained in:
+55
-3
@@ -18,6 +18,8 @@ POST_UIDS = []
|
||||
POST_SLUGS = []
|
||||
PROJECT_UIDS = []
|
||||
COMMENT_UIDS = []
|
||||
NEWS_UIDS = []
|
||||
NEWS_SLUGS = []
|
||||
TOPICS = ["devlog", "showcase", "question", "rant", "fun", "random"]
|
||||
PROJECT_TYPES = ["game", "game_asset", "software", "mobile_app", "website"]
|
||||
AVATAR_STYLES = [
|
||||
@@ -148,6 +150,28 @@ def seed_data(environment, **kwargs):
|
||||
except Exception as e:
|
||||
logger.warning(f"Create seed project failed: {e}")
|
||||
|
||||
# ── Seed news articles (direct DB insert) ───────────────────
|
||||
try:
|
||||
from devplacepy.database import get_table, init_db
|
||||
from devplacepy.utils import make_combined_slug
|
||||
init_db()
|
||||
news_table = get_table("news")
|
||||
for i in range(3):
|
||||
title = f"Locust news article {i} {uuid.uuid4().hex[:4]}"
|
||||
article_uid = str(uuid.uuid4())
|
||||
slug = make_combined_slug(title, article_uid)
|
||||
news_table.insert({
|
||||
"uid": article_uid, "slug": slug, "title": title,
|
||||
"external_id": f"locust_seed_{i}", "grade": 8,
|
||||
"status": "published", "show_on_landing": 1,
|
||||
"source_name": "Locust", "synced_at": "2026-01-01T00:00:00",
|
||||
"description": "Locust seed article for load testing.",
|
||||
})
|
||||
NEWS_UIDS.append(article_uid)
|
||||
NEWS_SLUGS.append(slug)
|
||||
except Exception as e:
|
||||
logger.warning(f"Seed news articles failed: {e}")
|
||||
|
||||
# ── Harvest UIDs from HTML responses ──────────────────────
|
||||
# projects sidebar: /projects?user_uid={uuid}
|
||||
# project cards: /votes/project/{uuid}
|
||||
@@ -251,6 +275,23 @@ class DevPlaceUser(HttpUser):
|
||||
random.choice(["/auth/signup", "/auth/login"]), name="auth/form"
|
||||
)
|
||||
|
||||
@task(3)
|
||||
def view_news(self):
|
||||
self.client.get("/news", name="news")
|
||||
|
||||
@task(2)
|
||||
def view_news_detail(self):
|
||||
slugs = NEWS_SLUGS if NEWS_SLUGS else NEWS_UIDS
|
||||
if not slugs:
|
||||
return
|
||||
self.client.get(
|
||||
f"/news/{random.choice(slugs)}", name="news/[slug]"
|
||||
)
|
||||
|
||||
@task(1)
|
||||
def view_bugs(self):
|
||||
self.client.get("/bugs", name="bugs")
|
||||
|
||||
# ── auth flows ──────────────────────────────────────────────
|
||||
|
||||
@task(1)
|
||||
@@ -389,7 +430,18 @@ class DevPlaceUser(HttpUser):
|
||||
# ── static / media ──────────────────────────────────────────
|
||||
|
||||
@task(2)
|
||||
def view_avatar(self):
|
||||
style = random.choice(AVATAR_STYLES)
|
||||
def view_multiavatar(self):
|
||||
seed = random.choice(ALL_USERNAMES) if ALL_USERNAMES else "anon"
|
||||
self.client.get(f"/avatar/{style}/{seed}", name="avatar/[style]/[seed]")
|
||||
self.client.get(
|
||||
f"/avatar/multiavatar/{seed}?size=32", name="avatar/multiavatar"
|
||||
)
|
||||
|
||||
@task(1)
|
||||
def comment_on_news(self):
|
||||
if not NEWS_UIDS:
|
||||
return
|
||||
self.client.post("/comments/create", data={
|
||||
"content": f"News comment {uuid.uuid4().hex[:6]} " * 2,
|
||||
"target_uid": random.choice(NEWS_UIDS),
|
||||
"target_type": "news",
|
||||
}, name="comments/news")
|
||||
|
||||
Reference in New Issue
Block a user