Admin: paged user list with a dialog; creators manage famous people
CI / test (push) Successful in 1m55s
CI / build (push) Skipped
CI / deploy (push) Skipped

- The user list pages (25 per page, with the total from the backend); roles,
  packages and single units are set in a dialog instead of in the row.
- Creators may add, edit and publish famous people and rewrite their
  portraits (own regenerate route); they delete only their own. The rest of
  the admin stays closed to them; the header links them to their page.
- No free-horoscope offer on the star sign and famous people lists.
- .table-wrap is a containing block, so .sr-only text inside it no longer
  widens the page on phones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-23 09:04:51 +00:00
co-authored by Claude Opus 5.5
parent 26c5bb2746
commit 8d9c50cb02
18 changed files with 541 additions and 217 deletions
+62
View File
@@ -3099,3 +3099,65 @@ async fn admins_publish_famous_people_with_a_photo(pool: PgPool) {
assert_eq!(left["celebrities"].as_array().unwrap().len(), 1);
assert_eq!(left["celebrities"][0]["id"].as_str(), Some(second.as_str()));
}
#[sqlx::test(migrator = "db::MIGRATOR")]
async fn creators_add_famous_people_but_nothing_else_of_the_admin(pool: PgPool) {
let app = TestApp::new(pool.clone()).await;
let admin = app.register("admin@example.com", "Admin").await;
let writer = app.register("szerzo@example.com", "Szerző").await;
sqlx::query("UPDATE users SET roles = '{user,creator}' WHERE email = 'szerzo@example.com'")
.execute(&pool)
.await
.unwrap();
let birth = json!({"date": "1926-06-01", "time": "09:30", "country": "HU", "place": "Szeged"});
// the famous people: add, edit, see the draft, rewrite the analysis, delete their own
let r = app.post("/v1/admin/celebrities", Some(&writer), json!({"name": "Teszt Elek", "birth": birth})).await;
assert_eq!(r.status, StatusCode::CREATED, "{}", r.body);
let id = r.body["id"].as_str().unwrap().to_string();
let analysis_id = r.body["analysis"]["id"].as_str().unwrap().to_string();
assert!(r.body["created_by"].is_string());
let r = app.call("PATCH", &format!("/v1/admin/celebrities/{id}"), Some(&writer), Some(json!({"subtitle": "író"}))).await;
assert_eq!(r.status, StatusCode::OK, "{}", r.body);
assert_eq!(app.get("/v1/public/celebrities/teszt-elek", Some(&writer)).await.status, StatusCode::OK);
let regenerate = format!("/v1/admin/celebrities/{id}/analysis/regenerate");
let r = app.post(&regenerate, Some(&writer), json!({})).await;
assert_eq!(r.status, StatusCode::CONFLICT, "still pending: {}", r.body);
sqlx::query("UPDATE analyses SET status = 'done', content = '{}', completed_at = now() WHERE id = $1::uuid")
.bind(&analysis_id)
.execute(&pool)
.await
.unwrap();
let r = app.post(&regenerate, Some(&writer), json!({})).await;
assert_eq!((r.status, r.body["status"].as_str()), (StatusCode::OK, Some("pending")), "{}", r.body);
assert_eq!(r.body["id"].as_str(), Some(analysis_id.as_str()));
// someone else's famous person: edited, but only an admin deletes it
let r = app.post("/v1/admin/celebrities", Some(&admin), json!({"name": "Admin Ádám", "birth": birth})).await;
let others = r.body["id"].as_str().unwrap().to_string();
let r = app.call("DELETE", &format!("/v1/admin/celebrities/{others}"), Some(&writer), None).await;
assert_eq!(r.status, StatusCode::FORBIDDEN);
let r = app.call("DELETE", &format!("/v1/admin/celebrities/{id}"), Some(&writer), None).await;
assert_eq!(r.status, StatusCode::NO_CONTENT);
// the rest of the admin stays closed
for uri in ["/v1/admin/users", "/v1/admin/prompts", "/v1/admin/errors"] {
assert_eq!(app.get(uri, Some(&writer)).await.status, StatusCode::FORBIDDEN, "{uri}");
}
let r = app.post(&format!("/v1/admin/analyses/{analysis_id}/regenerate"), Some(&writer), json!({})).await;
assert_eq!(r.status, StatusCode::FORBIDDEN);
}
#[sqlx::test(migrator = "db::MIGRATOR")]
async fn the_user_list_pages_with_a_total(pool: PgPool) {
let app = TestApp::new(pool.clone()).await;
let admin = app.register("admin@example.com", "Admin").await;
for i in 0..4 {
app.register(&format!("lap{i}@example.com"), "Lapozó").await;
}
let r = app.get("/v1/admin/users?limit=2&offset=2", Some(&admin)).await;
assert_eq!(r.status, StatusCode::OK, "{}", r.body);
assert_eq!((r.body["total"].as_i64(), r.body["users"].as_array().unwrap().len()), (Some(5), 2));
let r = app.get("/v1/admin/users?q=lap&limit=3&offset=3", Some(&admin)).await;
assert_eq!((r.body["total"].as_i64(), r.body["users"].as_array().unwrap().len()), (Some(4), 1));
}